Class IntersectionSimilarity<T>
- java.lang.Object
-
- org.apache.commons.text.similarity.IntersectionSimilarity<T>
-
- Type Parameters:
T- the type of the elements extracted from the character sequence
- All Implemented Interfaces:
SimilarityScore<IntersectionResult>
public class IntersectionSimilarity<T> extends Object implements SimilarityScore<IntersectionResult>
Measures the intersection of two sets created from a pair of character sequences.It is assumed that the type
Tcorrectly conforms to the requirements for storage within aSetorHashMap. Ideally the type is immutable and implementsObject.equals(Object)andObject.hashCode().
-
-
Constructor Summary
Constructors Constructor Description IntersectionSimilarity(Function<CharSequence,Collection<T>> converter)Create a new intersection similarity using the provided converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntersectionResultapply(CharSequence left, CharSequence right)Calculates the intersection of two character sequences passed as input.
-
-
-
Constructor Detail
-
IntersectionSimilarity
public IntersectionSimilarity(Function<CharSequence,Collection<T>> converter)
Create a new intersection similarity using the provided converter.If the converter returns a
Setthen the intersection result will not include duplicates. Any otherCollectionis used to produce a result that will include duplicates in the intersect and union.- Parameters:
converter- the converter used to create the elements from the characters- Throws:
IllegalArgumentException- if the converter is null
-
-
Method Detail
-
apply
public IntersectionResult apply(CharSequence left, CharSequence right)
Calculates the intersection of two character sequences passed as input.- Specified by:
applyin interfaceSimilarityScore<T>- Parameters:
left- first character sequenceright- second character sequence- Returns:
- The intersection result
- Throws:
IllegalArgumentException- if either input sequence isnull
-
-