0
我試圖在R
中使用DocumentTermMatrix
,使用參數control = list()
將術語限制爲預定義的基於文本的表情符號列表(:D,:),:(,等等。)。但是,dtm不會吸取某些表情符號(如":D"
或":)"
),但其他一些工作正常(":))"
)。我的代碼:在R中保留標點符號文檔術語表
text = c(":D", ":))")
corpus <- Corpus(VectorSource(text)
corpus = tm_map(corpus, PlainTextDocument)
dtm = DocumentTermMatrix(corpus, list(dictionary = c(":D" , ":))")))
emojidf <- as.data.frame(as.matrix(dtm))
:D :))
1 0 0
2 0 1
爲了解決這個問題,我可以用content_transformer
和gsub
改變問題的表情符號,來話。但是,我想知道如何DocumentTermMatrix
甚至Corpus
作爲單詞處理標點符號。
感謝您對'tolower'的默認設置!我計算出了3個字母的下界,但並不認爲tolower會嵌入在dtm中,因爲我通常在tm_map之前使用dtm – huydinh282