Top Description Fields Constructors Methods
org.apache.commons.text.similarity

public Class JaroWinklerDistance

extends Object
implements EditDistance<Double>
Class Inheritance
All Implemented Interfaces
org.apache.commons.text.similarity.EditDistance, org.apache.commons.text.similarity.SimilarityScore, org.apache.commons.text.similarity.ObjectSimilarityScore, java.util.function.BiFunction

Measures the Jaro-Winkler distance of two character sequences. It is the complementary of Jaro-Winkler similarity.
Since
1.0

Field Summary

Modifier and TypeField and Description
public static final int
INDEX_NOT_FOUND

Deprecated Deprecated as of 1.7. This constant will be removed in 2.0.

Constructor Summary

AccessConstructor and Description
public
JaroWinklerDistance()

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
public Double

Returns:

result distance.
apply
(final CharSequence
the first input, must not be null.
left
,
final CharSequence
the second input, must not be null.
right
)

Implements org.apache.commons.text.similarity.SimilarityScore.apply.

Computes the Jaro Winkler Distance between two character sequences.

public <
The type of similarity score unit.
E
>
Double

Returns:

result distance.
apply
(final SimilarityInput<E>
the first input, must not be null.
left
,
final SimilarityInput<E>
the second input, must not be null.
right
)

Implements org.apache.commons.text.similarity.ObjectSimilarityScore.apply.

Computes the Jaro Winkler Distance between two character sequences.

protected static int[]

Returns:

array containing: matches, half transpositions, and prefix
matches
(final CharSequence
the first string to be matched.
first
,
final CharSequence
the second string to be matched.
second
)
Deprecated Deprecated as of 1.7, use JaroWinklerSimilarity#matches(CharSequence, CharSequence).

Computes the Jaro-Winkler string matches, half transpositions, prefix array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INDEX_NOT_FOUNDback to summary
public static final int INDEX_NOT_FOUND

Deprecated

Deprecated as of 1.7. This constant will be removed in 2.0.

Annotations
@Deprecated

Constructor Detail

JaroWinklerDistanceback to summary
public JaroWinklerDistance()

Creates a new instance.

Method Detail

applyback to summary
public Double apply(final CharSequence left, final CharSequence right)

Implements org.apache.commons.text.similarity.SimilarityScore.apply.

Computes the Jaro Winkler Distance between two character sequences.

distance.apply(null, null)          = Throws IllegalArgumentException
distance.apply("foo", null)         = Throws IllegalArgumentException
distance.apply(null, "foo")         = Throws IllegalArgumentException
distance.apply("", "")              = 0.0
distance.apply("foo", "foo")        = 0.0
distance.apply("foo", "foo ")       = 0.06
distance.apply("foo", "foo  ")      = 0.09
distance.apply("foo", " foo ")      = 0.13
distance.apply("foo", "  foo")      = 0.49
distance.apply("", "a")             = 1.0
distance.apply("aaapppp", "")       = 1.0
distance.apply("frog", "fog")       = 0.07
distance.apply("fly", "ant")        = 1.0
distance.apply("elephant", "hippo") = 0.56
distance.apply("hippo", "elephant") = 0.56
distance.apply("hippo", "zzzzzzzz") = 1.0
distance.apply("hello", "hallo")    = 0.12
distance.apply("ABC Corporation", "ABC Corp") = 0.09
distance.apply("D N H Enterprises Inc", "D & H Enterprises, Inc.") = 0.05
distance.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness") = 0.08
distance.apply("PENNSYLVANIA", "PENNCISYLVNIA") = 0.12
Parameters
left:CharSequence

the first input, must not be null.

right:CharSequence

the second input, must not be null.

Returns:Double

result distance.

Annotations
@Override
Exceptions
IllegalArgumentException:
if either CharSequence input is null.
applyback to summary
public <E> Double apply(final SimilarityInput<E> left, final SimilarityInput<E> right)

Implements org.apache.commons.text.similarity.ObjectSimilarityScore.apply.

Computes the Jaro Winkler Distance between two character sequences.

distance.apply(null, null)          = Throws IllegalArgumentException
distance.apply("foo", null)         = Throws IllegalArgumentException
distance.apply(null, "foo")         = Throws IllegalArgumentException
distance.apply("", "")              = 0.0
distance.apply("foo", "foo")        = 0.0
distance.apply("foo", "foo ")       = 0.06
distance.apply("foo", "foo  ")      = 0.09
distance.apply("foo", " foo ")      = 0.13
distance.apply("foo", "  foo")      = 0.49
distance.apply("", "a")             = 1.0
distance.apply("aaapppp", "")       = 1.0
distance.apply("frog", "fog")       = 0.07
distance.apply("fly", "ant")        = 1.0
distance.apply("elephant", "hippo") = 0.56
distance.apply("hippo", "elephant") = 0.56
distance.apply("hippo", "zzzzzzzz") = 1.0
distance.apply("hello", "hallo")    = 0.12
distance.apply("ABC Corporation", "ABC Corp") = 0.09
distance.apply("D N H Enterprises Inc", "D & H Enterprises, Inc.") = 0.05
distance.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness") = 0.08
distance.apply("PENNSYLVANIA", "PENNCISYLVNIA") = 0.12
Parameters
<E>
The type of similarity score unit.
left:SimilarityInput<E>

the first input, must not be null.

right:SimilarityInput<E>

the second input, must not be null.

Returns:Double

result distance.

Exceptions
IllegalArgumentException:
if either CharSequence input is null.
Since
1.13.0
matchesback to summary
protected static int[] matches(final CharSequence first, final CharSequence second)

Deprecated

Deprecated as of 1.7, use JaroWinklerSimilarity#matches(CharSequence, CharSequence). This method will be removed in 2.0. TODO see TEXT-104.

Computes the Jaro-Winkler string matches, half transpositions, prefix array.

Parameters
first:CharSequence

the first string to be matched.

second:CharSequence

the second string to be matched.

Returns:int[]

array containing: matches, half transpositions, and prefix

Annotations
@Deprecated