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
+24.9k Golang : Create PDF file from HTML file
+7k Golang : Validate credit card example
+10.5k Android Studio : Simple input textbox and intercept key example
+22.1k Golang : Securing password with salt
+7.2k Golang : How to fix html/template : "somefile" is undefined error?
+7.4k Golang : How to handle file size larger than available memory panic issue
+3.6k Golang : Switch Redis database redis.NewClient
+9k Golang : Gonum standard normal random numbers example
+21.1k Golang : How to force compile or remove object files first before rebuild?
+13.4k Golang : Get constant name from value
+7.4k Gogland : Single File versus Go Application Run Configurations
+25.2k Golang : Get current file path of a file or executable