Package org.apache.commons.text.similarity

## Class CosineDistance

- java.lang.Object
- - org.apache.commons.text.similarity.CosineDistance

- All Implemented Interfaces:
    `EditDistance<Double>`, `SimilarityScore<Double>`

      public class CosineDistance
      extends Object
      implements EditDistance<Double>

  Measures the cosine distance between two character sequences.

  It utilizes the `CosineSimilarity` to compute the distance. Character sequences are converted into vectors through a simple tokenizer that works with a regular expression to split words in a sentence.

  For further explanation about Cosine Similarity and Cosine Distance, refer to http://en.wikipedia.org/wiki/Cosine_similarity.

  Since:
    1.0
  See Also:
    `CosineSimilarity`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CosineDistance()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Double` | `apply​(CharSequence left, CharSequence right)` | Compares two CharSequences.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CosineDistance

          public CosineDistance()

  - ### Method Detail

    - #### apply

          public Double apply​(CharSequence left,
                              CharSequence right)

      Description copied from interface: `EditDistance`
      Compares two CharSequences.
      Specified by:
        `apply` in interface `EditDistance<Double>`
      Specified by:
        `apply` in interface `SimilarityScore<Double>`
      Parameters:
        `left` - the first CharSequence
        `right` - the second CharSequence
      Returns:
        the similarity score between two CharSequences