计算字符串相似度的最佳方法是什么?

时间:2016-05-17 11:41:13

标签: nlp

考虑给你两个字符串S1和S2。有哪些不同的算法可用于计算这些字符串在其上下文中的相似程度以及哪一个在准确性方面最有效?

2 个答案:

答案 0 :(得分:1)

如果你打算使用python,最新的技术是文字嵌入。您可以将其视为通过对数百万个文档进行培训将单词转换为高维向量(从200到1000维)。

例如,如果你的字符串是"人机交互",你会找到这样的东西。

[(2, 0.99844527), # The EPS user interface management system
(0, 0.99809301), # Human machine interface for lab abc computer applications
(3, 0.9865886), # System and human system engineering testing of EPS
(1, 0.93748635), # A survey of user opinion of computer system response time
(4, 0.90755945), # Relation of user perceived response time to error measurement
(8, 0.050041795), # Graph minors A survey
(7, -0.098794639), # Graph minors IV Widths of trees and well quasi ordering
(6, -0.1063926), # The intersection graph of paths in trees
(5, -0.12416792)] # The generation of random binary unordered trees   

来自:https://radimrehurek.com/gensim/tut3.html

答案 1 :(得分:0)

尝试以下算法: Jaro-Winkler的距离 Levenshtein距离这两个算法有助于字符串匹配。这取决于你的字符串。根据字符串决定哪个是可行的。