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
+15.6k Golang : How to convert(cast) IP address to string?
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command
+9.1k Golang : Simple histogram example
+22.7k Golang : Set and Get HTTP request headers example
+39.6k Golang : Remove dashes(or any character) from string
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+5.8k Golang : Launching your executable inside a console under Linux
+9.4k Golang : Scramble and unscramble text message by randomly replacing words
+13.5k Facebook PHP getUser() returns 0
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+5.4k Unix/Linux : How to archive and compress entire directory ?