Top Description Interfaces Classes
[default module]

Package org.apache.commons.text.similarity


Provides algorithms for string similarity.

The algorithms that implement the EditDistance interface follow the same simple principle: the more similar (closer) strings are, lower is the distance. For example, the words house and hose are closer than house and trousers.

The following algorithms are available at the moment:

The Cosine Distance utilises a regular expression tokenizer (\w+). And the Levenshtein Distance's behavior can be changed to take into consideration a maximum throughput.

Since
1.0

Interface Summary

Modifier and TypeInterface and Description
pack-priv interface
public interface
EditDistance<
The type of similarity score unit used by this EditDistance.
R
>

Interface for Edit Distances.

public interface
ObjectSimilarityScore<
The left and right input type.
T
,
The type of similarity score unit used by this score.
R
>

Scores the similarity between two Objects of the same type.

public interface
SimilarityInput<
the type of elements in this input.
E
>

An ordered input of elements used to compute a similarity score.

public interface
SimilarityScore<
The type of similarity score unit.
R
>

Scores CharSequence similarity, like a String.

pack-priv interface
Tokenizer<
The type to tokenize.
T
,
The return array element type.
R
>

Produces arrays of tokens for a given type.

Class Summary

Modifier and TypeClass and Description
public class
CosineDistance

Measures the cosine distance between two character sequences.

public class
CosineSimilarity

Measures the Cosine similarity of two vectors of an inner product space and compares the angle between them.

pack-priv class
Counter

Java implementation of Python's collections Counter module.

public class
DamerauLevenshteinDistance

An algorithm for measuring the difference between two character sequences using the Damerau-Levenshtein Distance.

public class
EditDistanceFrom<
This is the type of similarity score used by the EditDistance function.
R
>

Stores a EditDistance implementation and a CharSequence "left" string.

public class
FuzzyScore

A matching algorithm that is similar to the searching algorithms implemented in editors such as Sublime Text, TextMate, Atom and others.

public class
HammingDistance

The hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.

public class
IntersectionResult

Represents the intersection result between two sets.

public class
IntersectionSimilarity<
the type of the elements extracted from the character sequence
T
>

Measures the intersection of two sets created from a pair of character sequences.

public class
JaccardDistance

Measures the Jaccard distance of two sets of character sequence.

public class
JaccardSimilarity

Measures the Jaccard similarity (aka Jaccard index) of two sets of character sequence.

public class
JaroWinklerDistance

Measures the Jaro-Winkler distance of two character sequences.

public class
JaroWinklerSimilarity

A similarity algorithm indicating the percentage of matched characters between two character sequences.

public class
LevenshteinDetailedDistance

An algorithm for measuring the difference between two character sequences.

public class
LevenshteinDistance

An algorithm for measuring the difference between two character sequences using the Levenshtein Distance.

public class
LevenshteinResults

Container class to store Levenshtein distance between two character sequences.

public class
LongestCommonSubsequence

A similarity algorithm indicating the length of the longest common subsequence between two strings.

public class
LongestCommonSubsequenceDistance

An edit distance algorithm based on the length of the longest common subsequence between two strings.

pack-priv class
RegexTokenizer

A simple word Tokenizer that utilizes a regex to find words.

pack-priv class
SimilarityCharacterInput

Scores the similarity between two CharSequences.

public class
SimilarityScoreFrom<
This is the type of similarity score used by the SimilarityScore function.
R
>

Stores a SimilarityScore implementation and a CharSequence "left" string.