edu.stanford.nlp.util
Class EditDistance

java.lang.Object
  extended by edu.stanford.nlp.util.EditDistance

public class EditDistance
extends java.lang.Object

Find the (Levenshtein) edit distance between two Strings or Character arrays. By default it allows transposition.
This is an object so that you can save on the cost of allocating / deallocating the large array when possible

Author:
Dan Klein, John Bauer - rewrote using DP instead of memorization

Field Summary
protected  double[][] score
           
 
Constructor Summary
EditDistance()
           
EditDistance(boolean allowTranspose)
           
 
Method Summary
protected  double best()
           
protected  double better(double x, double y)
           
protected  void clear(int sourceLength, int targetLength)
           
protected  double combine(double x, double y)
           
protected  double deleteCost(java.lang.Object o)
           
protected  double insertCost(java.lang.Object o)
           
static void main(java.lang.String[] args)
           
 double score(java.lang.Object[] source, java.lang.Object[] target)
           
 double score(java.lang.String sourceStr, java.lang.String targetStr)
           
protected  double substituteCost(java.lang.Object source, java.lang.Object target)
           
protected  double unit()
           
protected  double worst()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

score

protected double[][] score
Constructor Detail

EditDistance

public EditDistance()

EditDistance

public EditDistance(boolean allowTranspose)
Method Detail

clear

protected void clear(int sourceLength,
                     int targetLength)

best

protected double best()

worst

protected double worst()

unit

protected double unit()

better

protected double better(double x,
                        double y)

combine

protected double combine(double x,
                         double y)

insertCost

protected double insertCost(java.lang.Object o)

deleteCost

protected double deleteCost(java.lang.Object o)

substituteCost

protected double substituteCost(java.lang.Object source,
                                java.lang.Object target)

score

public double score(java.lang.Object[] source,
                    java.lang.Object[] target)

score

public double score(java.lang.String sourceStr,
                    java.lang.String targetStr)

main

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


Stanford NLP Group