您可以使用的一种方法称为 Shingling。该过程涉及标记两个文档中的所有单词,例如。
D1 = {"An", "Example", "Document", "To", "Show", "Shingling"}
D2 = {"Another", "Example", "Document", "To", "Show", "Shingling", "but", "longer"}
然后取一组窗口长度为 n 的连续子序列(记住在一组中没有重复)。
S(D1, 3) = {{"An", "Example", "Document"}, {"Example", "Document", "To"}, {"Document", "To", "Show"}, {"To", "Show", "Shingling"}}
S(D2, 3) = {{"Another", "Example", "Document"}, {"Example", "Document", "To"}, {"Document", "To", "Show"}, {"To", "Show", "Shingling"}, {"Show", "Shingling", "but"}, {"Shingling", "but", "longer"}}
然后相似度是交集的基数除以并集的基数。因此,对于我们的示例,3/7 = 43% 相似。
可以通过使用随机选择的草图(一组带状疱疹的子集)来进行有效的近似。