Skip to content

Instantly share code, notes, and snippets.

@lmas
Created April 25, 2016 15:59
Show Gist options
  • Save lmas/0d19e98636459eb1bf82759223abbdf3 to your computer and use it in GitHub Desktop.
Save lmas/0d19e98636459eb1bf82759223abbdf3 to your computer and use it in GitHub Desktop.
package leven
import "github.com/arbovm/levenshtein"
func calcScore(a, b string) float64 {
score := levenshtein.Distance(a, b)
lena := len(a)
lenb := len(b)
var bigger float64
if lena > lenb {
bigger = float64(lena)
} else {
bigger = float64(lenb)
}
return (bigger - float64(score)) / bigger
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment