com.wcohen.ss.api
Interface StringDistance

All Known Implementing Classes:
AbstractStatisticalTokenDistance, AbstractStringDistance, AbstractTokenizedStringDistance, AffineGap, ApproxNeedlemanWunsch, CombinedStringDistanceLearner.CombinedStringDistance, DirichletJS, Jaccard, Jaro, JaroWinkler, JaroWinklerTFIDF, JelinekMercerJS, JensenShannonDistance, Level2, Level2Jaro, Level2JaroWinkler, Level2Levenstein, Level2MongeElkan, Levenstein, Mixture, MongeElkan, MultiStringAvgDistance, MultiStringDistance, NeedlemanWunsch, ScaledLevenstein, SmithWaterman, SoftTFIDF, SoftTokenFelligiSunter, TagLink, TagLinkToken, TFIDF, TokenFelligiSunter, UnsmoothedJS, WinklerRescorer

public interface StringDistance

Compute the difference between pairs of strings.

For some types of distances, it is fine to simply create a StringDistance object and then use it, e.g., new JaroWinkler().compare("frederic", "fredrick").

Other string metrics benefit from caching information about a string, especially when many comparisons are many concerning the same string. The prepare() method returns a StringWrapper object, which can cache any appropriate information about the String it 'wraps'. The most frequent use of caching here is saving a tokenized version of a string (as a BagOfTokens, which is a subclass of StringWrapper.)


Method Summary
 java.lang.String explainScore(java.lang.String s, java.lang.String t)
          Explain how the distance was computed.
 java.lang.String explainScore(StringWrapper s, StringWrapper t)
          Explain how the distance was computed.
 StringWrapper prepare(java.lang.String s)
          Preprocess a string for distance computation
 double score(java.lang.String s, java.lang.String t)
          Find the distance between s and t
 double score(StringWrapper s, StringWrapper t)
          Find the distance between s and t.
 

Method Detail

score

double score(StringWrapper s,
             StringWrapper t)
Find the distance between s and t. Larger values indicate more similar strings.


score

double score(java.lang.String s,
             java.lang.String t)
Find the distance between s and t


prepare

StringWrapper prepare(java.lang.String s)
Preprocess a string for distance computation


explainScore

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


explainScore

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