LevenshteinDistance (Lucene 10.5.0 suggest API)
Description: declaration: package: org.apache.lucene.search.spell, class: LevenshteinDistance

Package org.apache.lucene.search.spell

# Class LevenshteinDistance

java.lang.Object
org.apache.lucene.search.spell.LevenshteinDistance

All Implemented Interfaces:
  `StringDistance`

public final class LevenshteinDistance extends Object implements StringDistance
Levenshtein edit distance class.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LevenshteinDistance()`
  Optimized to run a bit faster than the static getDistance().

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `float`
  `getDistance(String target, String other)`
  Returns a float between 0 and 1 based on how similar the specified strings are to one another.
  `int`
  `hashCode()`
  `String`
  `toString()`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### LevenshteinDistance

    public LevenshteinDistance()
    Optimized to run a bit faster than the static getDistance(). In one benchmark times were 5.3sec using ctr vs 8.5sec w/ static method, thus 37% faster.

- ## Method Details

  - ### getDistance

    public float getDistance(String target, String other)
    Description copied from interface: `StringDistance`
    Returns a float between 0 and 1 based on how similar the specified strings are to one another. Returning a value of 1 means the specified strings are identical and 0 means the string are maximally different.
    Specified by:
      `getDistance` in interface `StringDistance`
    Parameters:
      `target` - The first string.
      `other` - The second string.
    Returns:
      a float between 0 and 1 based on how similar the specified strings are to one another.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`