Implementing a simple Trie for efficient Levenshtein Distance calculation - Java

后端 未结 11 828
不思量自难忘°
不思量自难忘° 2020-12-22 18:51

UPDATE 3

Done. Below is the code that finally passed all of my tests. Again, this is modeled after Murilo Vasconcelo\'s modified version of Steve

11条回答
  •  情话喂你
    2020-12-22 19:28

    Here is an example of Levenshtein Automata in Java (EDIT: moved to github).These will probably also be helpful:

    http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/ http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/automaton/

    EDIT: The above links seem to have moved to github:

    https://github.com/apache/lucene-solr/tree/master/lucene/core/src/java/org/apache/lucene/util/automaton https://github.com/apache/lucene-solr/tree/master/lucene/core/src/test/org/apache/lucene/util/automaton

    It looks like the experimental Lucene code is based off of the dk.brics.automaton package.

    Usage appears to be something similar to below:

    LevenshteinAutomata builder = new LevenshteinAutomata(s);
    Automaton automata = builder.toAutomaton(n);
    boolean result1 = BasicOperations.run(automata, "foo");
    boolean result2 = BasicOperations.run(automata, "bar");
    

提交回复
热议问题