osita

build codecov Current Version Scala Steward badge license

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.

Installation

Osita is published for Scala 2.13. To start using it add the following to your build.sbt:

libraryDependencies += "nl.gn0s1s" %% "osita" % "0.0.2"

Example usage

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

Resources

License

The code is available under the Mozilla Public License, version 2.0.