R-文本分析 - 打印包含双元语法的特定文本



使用 R 进行文本分析。

我的数据集是来自 2000 个不同调查的 2000 条评论。我创建了双元语法。我已经检查了单词的频率,然后是用hclust()进行词聚类分析,然后是与findAssocs的词关联,例如findAssocs(bigram_dtm,"long time",0.2)

例如,我看到"长时间"与"感觉等待"有 0.66 的关联。

我试图在网上找到它,但还没有成功...... 问题: 有什么方法可以在这bi_grams在一起的地方打印评论吗? 有什么方法可以在"长时间"的位置打印评论吗?

谢谢

我认为您正在寻找的是grep.您可以使用它来获取要查找的评论的索引,也可以使用这些索引来获取评论本身。

Comments = c("I haven't seen you in a long time.",
"There is no U in TEAM, but it does contain ME.",
"In extreme cases, read the documentation.",
"A big computer, a complex algorithm and a long time does not equal science.",
"Use the source, Luke!")
grep("long time", Comments)
[1] 1 4
Comments[grep("long time", Comments)]
[1] "I haven't seen you in a long time."                                         
[2] "A big computer, a complex algorithm and a long time does not equal science."

(部分评论偷自fortune()(

最新更新