【发布时间】:2019-11-27 06:27:31
【问题描述】:
我想用 R 找出一个句子与许多其他句子的余弦相似度。例如:
s1 <- "The book is on the table"
s2 <- "The pen is on the table"
s3 <- "Put the pen on the book"
s4 <- "Take the book and pen"
sn <- "Take the book and pen from the table"
我想找出s1、s2、s3 和s4 与sn 的余弦相似度。我知道我必须使用向量(将句子转换为向量并使用 TF-IDF 和/或点积),但由于我对 R 比较陌生,所以我在实现它时遇到了问题。
感谢所有帮助。
【问题讨论】:
标签: r cosine-similarity