Skip to content

🧸 Tiny optimal string alignment distance library

License

Notifications You must be signed in to change notification settings

Philippus/osita

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 or AZERTY-keyboard. You can also supply your own substitution cost function.

Installation

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"

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")(qwertySubstitutionCost) // val res2: Double = 1.118033988749895

Resources

License

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