Class RatcliffObershelp
- java.lang.Object
-
- info.debatty.java.stringsimilarity.RatcliffObershelp
-
- All Implemented Interfaces:
NormalizedStringDistance,NormalizedStringSimilarity,StringDistance,StringSimilarity,Serializable
@Immutable public class RatcliffObershelp extends Object implements NormalizedStringSimilarity, NormalizedStringDistance
Ratcliff/Obershelp pattern recognition The Ratcliff/Obershelp algorithm computes the similarity of two strings a the doubled number of matching characters divided by the total number of characters in the two strings. Matching characters are those in the longest common subsequence plus, recursively, matching characters in the unmatched region on either side of the longest common subsequence. The Ratcliff/Obershelp distance is computed as 1 - Ratcliff/Obershelp similarity.- Author:
- Ligi https://github.com/dxpux (as a patch for fuzzystring) Ported to java from .net by denmase
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RatcliffObershelp()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(String s1, String s2)Return 1 - similarity.doublesimilarity(String s1, String s2)Compute the Ratcliff-Obershelp similarity between strings.
-
-
-
Method Detail
-
similarity
public final double similarity(String s1, String s2)
Compute the Ratcliff-Obershelp similarity between strings.- Specified by:
similarityin interfaceStringSimilarity- Parameters:
s1- The first string to compare.s2- The second string to compare.- Returns:
- The RatcliffObershelp similarity in the range [0, 1]
- Throws:
NullPointerException- if s1 or s2 is null.
-
distance
public final double distance(String s1, String s2)
Return 1 - similarity.- Specified by:
distancein interfaceStringDistance- Parameters:
s1- The first string to compare.s2- The second string to compare.- Returns:
- 1 - similarity
- Throws:
NullPointerException- if s1 or s2 is null.
-
-