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 or AZERTY-keyboard. You can also supply your own substitution cost function.
Osita is published for Scala 2.12, 2.13 and 3. To start using it add the following to your build.sbt
:
libraryDependencies += "nl.gn0s1s" %% "osita" % "0.1.0"
import nl.gn0s1s.osita.Osita._
osa("abcde", "abcde") // val res0: Double = 0.0
osa("abcde", "abcd") // val res1: Double = 1.0
osaWithSubstitutionCost("abc", "agc")(qwertySubstitutionCost) // 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.