SimilarityScore (Apache Commons Text 1.11.0 API)
Description: declaration: package: org.apache.commons.text.similarity, interface: SimilarityScore

Package org.apache.commons.text.similarity

# Interface SimilarityScore<R>

Type Parameters:
  `R` - The type of similarity score unit used by this EditDistance.

All Known Subinterfaces:
  `EditDistance<R>`

All Known Implementing Classes:
  `CosineDistance`, `HammingDistance`, `IntersectionSimilarity`, `JaccardDistance`, `JaccardSimilarity`, `JaroWinklerDistance`, `JaroWinklerSimilarity`, `LevenshteinDetailedDistance`, `LevenshteinDistance`, `LongestCommonSubsequence`, `LongestCommonSubsequenceDistance`

public interface SimilarityScore<R>
Interface for the concept of a string similarity score.

A string similarity score is intended to have some of the properties of a metric, yet allowing for exceptions, namely the Jaro-Winkler similarity score.

We Define a SimilarityScore to be a function `d: [X * X] -&gt; [0, INFINITY)` with the following properties:

- `d(x,y) &gt;= 0`, non-negativity or separation axiom
- `d(x,y) == d(y,x)`, symmetry.

Notice, these are two of the properties that contribute to d being a metric.

Further, this intended to be BiFunction<CharSequence, CharSequence, R>. The `apply` method accepts a pair of `CharSequence` parameters and returns an `R` type similarity score. We have omitted the explicit statement of extending BiFunction due to it only being implemented in Java 1.8, and we wish to maintain Java 1.7 compatibility.

Since:
  1.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `R`
  `apply(CharSequence left, CharSequence right)`
  Compares two CharSequences.

- ## Method Details

  - ### apply

    R apply(CharSequence left, CharSequence right)
    Compares two CharSequences.
    Parameters:
      `left` - the first CharSequence
      `right` - the second CharSequence
    Returns:
      The similarity score between two CharSequences