Top Description Constructors Methods
info.debatty.java.stringsimilarity

public Class RatcliffObershelp

extends Object
implements NormalizedStringSimilarity, NormalizedStringDistance
Class Inheritance
All Implemented Interfaces
info.debatty.java.stringsimilarity.interfaces.NormalizedStringDistance, info.debatty.java.stringsimilarity.interfaces.StringDistance, java.io.Serializable, info.debatty.java.stringsimilarity.interfaces.NormalizedStringSimilarity, info.debatty.java.stringsimilarity.interfaces.StringSimilarity
Annotations
@Immutable
Imports
info.debatty.java.stringsimilarity.interfaces.NormalizedStringSimilarity, .NormalizedStringDistance, java.util.List, .ArrayList, net.jcip.annotations.Immutable

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final double

Returns:

1 - similarity
distance
(final String
The first string to compare.
s1
,
final String
The second string to compare.
s2
)

Implements info.debatty.java.stringsimilarity.interfaces.StringDistance.distance.

Return 1 - similarity.

private static String
frontMaxMatch(final String s1, final String s2)

private static List<String>
getMatchList(final String s1, final String s2)

public final double

Returns:

The RatcliffObershelp similarity in the range [0, 1]
similarity
(final String
The first string to compare.
s1
,
final String
The second string to compare.
s2
)

Implements info.debatty.java.stringsimilarity.interfaces.StringSimilarity.similarity.

Compute the Ratcliff-Obershelp similarity between strings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RatcliffObershelpback to summary
public RatcliffObershelp()

Method Detail

distanceback to summary
public final double distance(final String s1, final String s2)

Implements info.debatty.java.stringsimilarity.interfaces.StringDistance.distance.

Return 1 - similarity.

Parameters
s1:String

The first string to compare.

s2:String

The second string to compare.

Returns:double

1 - similarity

Annotations
@Override
Exceptions
NullPointerException:
if s1 or s2 is null.
frontMaxMatchback to summary
private static String frontMaxMatch(final String s1, final String s2)
getMatchListback to summary
private static List<String> getMatchList(final String s1, final String s2)
similarityback to summary
public final double similarity(final String s1, final String s2)

Implements info.debatty.java.stringsimilarity.interfaces.StringSimilarity.similarity.

Compute the Ratcliff-Obershelp similarity between strings.

Parameters
s1:String

The first string to compare.

s2:String

The second string to compare.

Returns:double

The RatcliffObershelp similarity in the range [0, 1]

Annotations
@Override
Exceptions
NullPointerException:
if s1 or s2 is null.