|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.search.spell.NGramDistance
public class NGramDistance
N-Gram version of edit distance based on paper by Grzegorz Kondrak, "N-gram similarity and distance". Proceedings of the Twelfth International Conference on String Processing and Information Retrieval (SPIRE 2005), pp. 115-126, Buenos Aires, Argentina, November 2005. http://www.cs.ualberta.ca/~kondrak/papers/spire05.pdf This implementation uses the position-based optimization to compute partial matches of n-gram sub-strings and adds a null-character prefix of size n-1 so that the first character is contained in the same number of n-grams as a middle character. Null-character prefix matches are discounted so that strings with no matching characters will return a distance of 0.
| Constructor Summary | |
|---|---|
NGramDistance()
Creates an N-Gram distance measure using n-grams of size 2. |
|
NGramDistance(int size)
Creates an N-Gram distance measure using n-grams of the specified size. |
|
| Method Summary | |
|---|---|
float |
getDistance(String source,
String target)
Returns a float between 0 and 1 based on how similar the specified strings are to one another. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NGramDistance(int size)
size - The size of the n-gram to be used to compute the string distance.public NGramDistance()
| Method Detail |
|---|
public float getDistance(String source,
String target)
StringDistance
getDistance in interface StringDistancesource - The first string.target - The second string.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||