Golang : Levenshtein distance example
Continue from previous tutorial on fuzzy string search. This is a short example on Levenshtein distance with https://github.com/renstrom/fuzzysearch package. If you ever need to build a parser to parse natural language - Levenshtein distance will be handy. It also helps in spell checkers, correction systems for optical character recognition, and software to assist natural language translation.
Here you go!
package main
import (
"fmt"
"github.com/renstrom/fuzzysearch/fuzzy"
)
func main() {
input := []string{"example", "help", "assistance", "existence"}
rankMatches := fuzzy.RankFind("ex", input)
for _, rank := range rankMatches {
fmt.Println("Source : ", rank.Source, " Word :", rank.Target, " Distance : ", rank.Distance)
}
}
References :
See also : Golang : Fuzzy string search or approximate string matching example
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.4k CodeIgniter : form input set_value cause " to become & quot
+10.1k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+7.9k Golang : Take screen shot of browser with JQuery example
+17.7k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+31.6k Delete a directory in Go
+12.6k Golang : Gin framework accept query string by post request example
+4.1k Golang : Display packages names during compilation
+7.3k Android Studio : Import third-party library or package into Gradle Scripts
+10.4k Swift : Convert (cast) Float to String
+7.9k Golang : Apply Histogram Equalization to color images
+7.9k Golang : Find the length of big.Int variable example