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
+13.6k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+23.9k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+6.9k Golang : Tell color name with OpenCV example
+29.6k error: trying to remove "yum", which is protected
+14.2k Golang : Get current time from the Internet time server(ntp) example
+7.4k Golang : Count leading or ending zeros(any item of interest) example
+10.7k Golang : md5 hash of a string
+18.3k Golang : Determine if directory is empty with os.File.Readdir() function
+11.7k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+12.9k Golang : syscall.Socket example
+6k Golang : How to iterate a slice without using for loop?