无法调整 R 中 tm 包中的 findAssocs()

Unable to tweak the findAssocs() in tm package in R

我试图找到前 10 个常用词与输入文本中其余常用词之间的关联。

当我查看 findAssocs() 的单个输出时:

findAssocs(dtm, "good", corlimit=0.4)

它通过打印单词 'good' 来清楚地给出输出,其中已寻求关联。

$good
 better     got    hook    next content     fit  person 
   0.44    0.44    0.44    0.44    0.43    0.43    0.43 

但是当我尝试为具有前 10 个单词的字符向量自动执行此过程时:

t10 <- c("busi", "entertain", "topic", "interact", "track", "content", "paper", "media", "game", "good")

输出是每个元素的相关列表,但没有搜索关联的单词。示例输出如下(请注意 t10[i] 处的单词未打印,不像上面单独输出 'good' 清楚地打印):

for(i in 1:10) {

   t10_words[i] <- as.list(findAssocs(dtm, t10[i], corlimit=0.4))
}


> t10_words
[[1]]
   littl descript  disrupt    enter    model 
    0.50     0.48     0.48     0.48     0.48 

[[2]]
  immers    anyth   effect     full holodeck      iot  problem      say startrek     such  suspect      wow 
    0.68     0.48     0.48     0.48     0.48     0.48     0.48     0.48     0.48     0.48     0.48     0.48 

[[3]]
         area        captur          give        overal          like          alon          avid         begin 
         0.51          0.47          0.47          0.47          0.44          0.43          0.43          0.43 
      circuit         cloud collaboration      communic     communiti        concis        confus         defin 
         0.43          0.43          0.43          0.43          0.43          0.43          0.43          0.43 
      discord        doesnt          drop enablesupport        esport         event         everi       everyon 
         0.43          0.43          0.43          0.43          0.43          0.43          0.43          0.43 

如何将输出与实际关联词一起打印出来?

有人可以帮我解决这个问题吗?

谢谢。

在您的 运行 循环之后,添加以下代码:

names(t10_words) <- t10

这将使用 t10 中指定的词来命名列表。