快速比较一个字符串与Java中的集合 [英] Quickly compare a string against a Collection in Java

查看:266
本文介绍了快速比较一个字符串与Java中的集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算字符串与集合的编辑距离,以找到最接近的匹配项。我目前的问题是收集非常大(大约25000个项目),所以我不得不将这个集合缩小到相似长度的字符串,但仍然只能缩小到几千个字符串,这仍然很慢。有没有一个数据结构可以快速查找类似的字符串,还有另一种方法可以解决这个问题?

I am trying to calculate edit distances of a string against a collection to find the closest match. My current problem is that the collection is very large (about 25000 items), so I had to narrow down the set to just strings of similar lengths but that still would only narrow it down to a few thousand strings and this still is very slow. Is there a datastructure that allows for a quick lookup of similar strings or is there another way I could address this problem?

推荐答案

声音像 BK-tree 可能是你想要的。这是一篇文章讨论他们: http://博客.notdot.net / 2007/4 / Damn-Cool-Algorithms-Part-1-BK-Trees 快速Google 产生一些Java实现。

Sounds like a BK-tree might be what you want. Here's an article discussing them: http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees. A quick Google yields some Java implementations.

这篇关于快速比较一个字符串与Java中的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆