Osita is an implementation of the Optimal String Alignment distance algorithm. It implements the standard version of the algorithm and an extension of it where the substitution cost has been replaced by a function which calculates the keyboard distance between characters using the Euclidean distance between keys on a QWERTY-keyboard. You can also supply your own substitution cost function.
Osita is published for Scala 2.13. To start using it add the following to your
libraryDependencies += "nl.gn0s1s" %% "osita" % "0.0.2"
import nl.gn0s1s.osita.Osita._ osa("abcde", "abcde") // val res0: Double = 0.0 osa("abcde", "abcd") // val res1: Double = 1.0 osaWithSubstitutionCost("abc", "agc")(weightedKeyboardSubstitutionCost) // val res2: Double = 1.118033988749895
- Optimal String Alignment distance
- Euclidean Distance
- Distances between keys on a QWERTY keyboard on Code Golf - https://codegolf.stackexchange.com/questions/233618/distances-between-keys-on-a-qwerty-keyboard
- Keyboard distance in Perl - https://metacpan.org/release/KRBURTON/String-KeyboardDistance-1.01/source/README
The code is available under the Mozilla Public License, version 2.0.