2016-07-14 93 views
2

我正在使用R的twitter數據,並試圖從推文中刪除所有正確的英文單詞。這個想法是看一下我記錄的特定人羣的口語縮寫,拼寫錯誤和俚語。從R的推文中刪除正確的英文單詞

例子:

tweet <- c("Trying to find the solution frustrated af") 

上述操作後,我想只有「AF」

我想洗鳴叫對字典(我將下載),但有一定是一個更簡單的選擇。在Python中的任何解決方案也將有所幫助。

+2

沒有嘗試R中使用'aspell'? –

回答

0

另一箇中的hunspell使用基於解決方案,而新&有趣package

# install.packages("hunspell") # uncomment & run if needed 
library(hunspell) 
tweet <- c("Trying to find the solution frustrated af") 
(tokens <- strsplit(tweet, " ")[[1]]) 
# [1] "Trying"  "to"   "find"  "the"  "solution" "frustrated" "af"   
tokens[!hunspell_check(tokens), dict = "en_US"] 
# [1] "af"