我想知道如何使用数据帧中的R来执行文本相似性。当我直接输入要比较的内容时,我有以下代码可以正常工作,但我很难让它与我的数据帧中包含的单词一起工作。我想比较我的数据框中的所有单词对。有任何想法吗?提前谢谢。
library(textcat)
?textcat_xdist
round(textcat_xdist(
list(
text1="hello there",
text2="why hello there",
text3="totally different"
),
method="cosine"),
3)
Data <- data.frame(
X = sample(1:4),
Word = sample(c("hello", "hellow", "hellloooo", "different"), 4, replace = TRUE)
)