Package opennlp.spellcheck.distance
Interface EditDistance
- All Known Implementing Classes:
DamerauOSADistance,LevenshteinDistance
public interface EditDistance
Computes the edit distance between two character sequences with an upper bound.
Implementations must be Unicode-aware and operate on code points rather than
UTF-16 char units so that supplementary characters are handled correctly.
-
Method Summary
Modifier and TypeMethodDescriptionintdistance(CharSequence a, CharSequence b, int max) Computes the edit distance betweenaandb, giving up early once it is certain the distance exceedsmax.
-
Method Details
-
distance
Computes the edit distance betweenaandb, giving up early once it is certain the distance exceedsmax.A
maxof0is permitted and meaningful: it asks only whether the two sequences are equal, returning0when they are and-1as soon as any difference is found. It is the natural lower bound of the contract, not a degenerate case.- Parameters:
a- the first sequence; must not benullb- the second sequence; must not benullmax- the maximum acceptable distance; must not be negative (>= 0)- Returns:
- the edit distance, or
-1if it is strictly greater thanmax - Throws:
IllegalArgumentException- ifaorbisnull, or ifmaxis negative
-