【发布时间】:2012-02-04 08:07:56
【问题描述】:
我正在尝试计算字符串与集合的编辑距离,以找到最接近的匹配项。我目前的问题是集合非常大(大约 25000 个项目),所以我不得不将集合缩小到只有相似长度的字符串,但这仍然只能将其缩小到几千个字符串,这仍然很慢。是否有允许快速查找相似字符串的数据结构,或者有其他方法可以解决这个问题?
【问题讨论】:
-
你现在怎么样了?你能显示一些代码吗?
-
相似是指比较常见拼写错误的单词,例如“exanple”和“example”或“weird”和“wierd”。
-
看起来你想要一个列文斯坦距离的实现:stackoverflow.com/questions/6087281/…。
-
我目前正在这样做: String currentString;列出距离列表; (for word: wordList){ int distance = calculateDistance(currentString,word) distanceList.add(distance) }
标签: java algorithm data-structures pattern-matching edit-distance