string - 是否有任何算法可以从字符串集合中找到与字符串最接近的匹配项?

标签 string algorithm match

是否有任何算法可以从字符串集合中找到与字符串最接近的匹配项?例如:

string_to_match = 'What color is the sky?'

strings = [
  'What colour is the sea?', 
  'What colour is the sky?', 
  'What colour is grass?', 
  'What colour is earth?'
]

answer = method_using_string_matching_algorithm(string_to_match, strings)
answer # returns strings[1] 'What colour is the sky?'

最佳答案

您要查找的搜索词是“字符串距离算法”和“近似字符串匹配”。快速查看 Google 会发现一些有趣的选项,例如:

  • Sift3 距离
  • 编辑距离
  • 最佳字符串对齐距离
  • Damerau-Levenshtein 距离
  • Qwerty 键盘距离

一些有用的链接包括:

在撰写本文时,基于 Debian 的 Linux 发行版还包括 agrep 和 TRE-agrep在他们的存储库中。

关于string - 是否有任何算法可以从字符串集合中找到与字符串最接近的匹配项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10348867/

相关文章:

javascript - 在javascript中匹配和替换整个单词

java - 字符串格式错误

c - 使用指针反转 C 中的字符串 - if 语句的目的?

performance - 洗牌时跟踪项目的最佳方式,以及洗牌前它们所在的位置

Java:两个列表之间的区别

Perl 输出太多列

regex - 需要使用 RegEx 防止重复字符

java - 将逗号分隔的字符串拆分为多个新字符串

string - 在brainf*ck的270个字符中打印出178个字符的字符串

algorithm - 在 Dijkstra 算法中每次迭代将选择具有最小距离值的顶点的引理是什么?