Golang : Fuzzy string search or approximate string matching example
For this tutorial, we will learn how to do a fuzzy search in Golang. Fuzzy search or approximate string matching algorithm is a technique of finding strings that match a pattern approximately. The algorithm is useful to determine a question or sentence intent, sentence auto-complete/suggest and building artificial intelligence chat bot.
Here you go!
package main
import (
"fmt"
"github.com/renstrom/fuzzysearch/fuzzy"
)
func main() {
// find
input := []string{"example", "help", "assistance", "existence"}
fuzzyMatches := fuzzy.Find("ex", input)
fmt.Println("Matches found : ", fuzzyMatches)
}
Happy coding!
References :
See also : Golang : How to check if a string contains another sub-string?
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
+7.7k Golang : Random integer with rand.Seed() within a given range
+13.2k Golang : How to shuffle elements in array or slice?
+18k Mac OSX : Homebrew and Golang
+11.2k Golang : Validate email address
+10.6k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+7k Golang : Add build version and other information in executables
+28.9k Golang : Generate random string
+10.7k Golang : Clean formatting/indenting or pretty print JSON result
+22.1k Golang : Fix type interface{} has no field or no methods and type assertions example
+6.3k Golang : Not able to grep log.Println() output
+3.9k Golang : Customize scanner.Scanner to treat dash as part of identifier
+6.8k Golang Hello World Example