Class Level2

  extended by
      extended by
          extended by
All Implemented Interfaces:
StringDistance, StringDistanceLearner
Direct Known Subclasses:
Level2Jaro, Level2JaroWinkler, Level2Levenstein, Level2MongeElkan

public class Level2
extends AbstractTokenizedStringDistance

Generic version of Monge & Elkan's "level 2" recursive field matching. Given strings A, B that are broken into substrings A = A1...Ak and B=B1...Bm, the recursive string matching algorithm scores

score(A,B) = 1/k [ sum_i max_j score(Ai,Bj) ] For level 1, substrings Ai, Bj are delimited by commas; for level 2, they are tokens.

Constructor Summary
Level2(Tokenizer tokenizer, StringDistance tokenDistance)
Method Summary
 java.lang.String explainScore(StringWrapper s, StringWrapper t)
          Explain how the distance was computed.
static void main(java.lang.String[] argv)
 double score(StringWrapper s, StringWrapper t)
          This method needs to be implemented by subclasses.
 java.lang.String toString()
 void train(StringWrapperIterator i)
          Training is a null operation.
Methods inherited from class
asBagOfTokens, prepare, setStringWrapperPool
Methods inherited from class
addExample, doMain, explainScore, getDistance, hasNextQuery, nextQuery, prepare, prepare, score, setDistanceInstancePool
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public Level2(Tokenizer tokenizer,
              StringDistance tokenDistance)
Method Detail


public double score(StringWrapper s,
                    StringWrapper t)
Description copied from class: AbstractStringDistance
This method needs to be implemented by subclasses.

Specified by:
score in interface StringDistance
Specified by:
score in class AbstractStringDistance


public java.lang.String explainScore(StringWrapper s,
                                     StringWrapper t)
Explain how the distance was computed.

Specified by:
explainScore in interface StringDistance
Specified by:
explainScore in class AbstractStringDistance


public void train(StringWrapperIterator i)
Training is a null operation. Properly speaking of course, it should train the inner distance function.

Specified by:
train in class AbstractTokenizedStringDistance


public java.lang.String toString()
toString in class java.lang.Object


public static void main(java.lang.String[] argv)