org.basex.util
Class Levenshtein

java.lang.Object
  extended by org.basex.util.Levenshtein

public final class Levenshtein
extends java.lang.Object

Damerau-Levenshtein implementation. Based on the publications from Levenshtein (1965): Binary codes capable of correcting spurious insertions and deletions of ones, and Damerau (1964): A technique for computer detection and correction of spelling errors.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
Levenshtein()
           
 
Method Summary
 boolean similar(byte[] token, byte[] sub)
          Compares two character arrays for similarity.
 boolean similar(byte[] token, byte[] sub, int err)
          Compares two character arrays for similarity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Levenshtein

public Levenshtein()
Method Detail

similar

public boolean similar(byte[] token,
                       byte[] sub)
Compares two character arrays for similarity.

Parameters:
token - token to be compared
sub - second token to be compared
Returns:
true if the arrays are similar

similar

public boolean similar(byte[] token,
                       byte[] sub,
                       int err)
Compares two character arrays for similarity.

Parameters:
token - token to be compared
sub - second token to be compared
err - number of allowed errors; dynamic calculation if value is 0
Returns:
true if the arrays are similar