class EditDistanceMetrics
package markov.util
Algorithms that calculate the edit distances between strings.
Static methods
staticinline damerauLevenshtein (source:String, target:String):Int
Calculates the Damerau-Levenshtein distance between two Strings.
The Damerau-Levenshtein distance is the number of insertions, deletions, replacements and transpositions needed to transform a source String into a target String.
Parameters:
source | The source string. Must not be null. |
---|---|
target | The target string. Must not be null. |
Returns:
The number of character edits needed to transform the source into the target.
staticdamerauLevenshteinMatrix (source:String, target:String, enableTranspositions:Bool = true):Vector<Int>
Calculates the Levenshtein or Damerau-Levenshtein distance table for the edit operations (insertions, deletions, replacements and optionally transpositions) needed to transform a source String into a target String.
Parameters:
source | The source string. Must not be null. |
---|---|
target | The target string. Must not be null. |
enableTransposition | Whether to allow adjacent symbols to be transposed i.e. swapped. |
Returns:
The distance table, which can be queried to obtain sequences of operations to transform the source to the target.
staticlevenshtein (source:String, target:String):Int
Calculates the Levenshtein distance between two Strings.
The Levenshtein distance is the number of insertions, deletions and replacements needed to transform a source String into a target String.
This is a fast iterative method that doesn't create a whole distance table up front.
Parameters:
source | The source string. Must not be null. |
---|---|
target | The target string. Must not be null. |
The | number of single-character edits needed to transform the source into the target. |