单词关联 - findAssocs 和数字 (0)

word association - findAssocs and numeric (0)

我刚刚开始掌握 R 中的 tm 包。

可能是一个简单的问题,但我试图使用 findAssocs 函数来了解我的客户查询洞察文档中的单词关联,但我似乎无法让 findAssocs 正常工作.

当我使用以下内容时:

findAssocs(dtm, words, corlimit = 0.30)
 $population
  numeric(0)

 $migration
 numeric(0)

这是什么意思? Words是一个667字的特征向量,一定有相关关系吧?

考虑以下示例:

library(tm)
corp <- VCorpus(VectorSource(
          c("hello world", "hello another World ", "and hello yet another world")))
tdm <- TermDocumentMatrix(corp)
inspect(tdm)
#          Docs
# Terms     1 2 3
#   and     0 0 1
#   another 0 1 1
#   hello   1 1 1
#   world   1 1 1
#   yet     0 0 1

现在考虑

findAssocs(x=tdm, terms=c("hello", "yet"), corlimit=.4)
# $hello
# numeric(0)
# 
# $yet
#     and another 
#     1.0     0.5 

据我了解,findAssocs 着眼于 hello 与除 helloyet 之外的所有事物的相关性,以及 yet 与所有事物的相关性helloyet 除外。 yetand的相关系数为1.0,高于0.4的下限。 yet 也出现在所有包含 another 的文档中的 50% - 这也高于我们的 0.4 限制。

这是展示此内容的另一个示例:

findAssocs(x=tdm, terms=c("yet", "another"), corlimit=0)
# $yet
# and 
#   1 
# 
# $another
# and 
# 0.5 

请注意,hello(和 world)不会产生任何结果,因为它们存在于每个文档中。这意味着术语频率具有零方差并且 cor 在引擎盖下产生 NA(如 cor(rep(1,3), 1:3),它给出 NA 加上零标准偏差警告)。