我正在尝试将LDA与三字母组合而不是单个单词组合使用。我实质上是将三字母组合词视为一个单词。我必须在下面的代码。
MD_notes_phrases <- MD_notes %>%
group_by(status) %>%
unnest_tokens(trigram, text, token = "ngrams", n = 3) %>%
separate(trigram, c("word1", "word2", "word3"), sep = " ") %>%
filter(!word1 %in% stop_words$word,
!word1 %in% removedWords$word,
!word2 %in% stop_words$word,
!word2 %in% removedWords$word,
!word3 %in% stop_words$word,
!word3 %in% removedWords$word) %>%
mutate(phrase = paste(word1,word2,word3,sep = " "))
DTM <- MD_notes_phrases %>%
cast_dtm(document = status,term = phrase,n)
但是,当我尝试使用cast_dtm函数创建文档术语矩阵时,出现以下错误:
Error in .M.kind(x) : not yet implemented for matrix with typeof NULL
感谢您的帮助。如果这是方法问题而不是代码问题,我会提前道歉。