Quickly compare a string against a Collection in Java

前端 未结 3 2020
借酒劲吻你
借酒劲吻你 2020-12-18 06:42

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 item

相关标签:
3条回答
  • 2020-12-18 06:58

    If your criteria for 'similar' define a total ordering, you should be able to define a Comparator and use a TreeSet to find the closest matches (eg using the ceiling and floor methods).

    0 讨论(0)
  • 2020-12-18 07:02

    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.

    0 讨论(0)
  • 2020-12-18 07:16

    Levenshtein Automata allow for fast selection of a set of words from a large dictionary such that they are within the given Levenshtein distance from a given word.

    See: Schulz K, Mihov S. (2002) Fast String Correction with Levenshtein-Automata.

    0 讨论(0)
提交回复
热议问题