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
+8.6k Golang : How to check if a website is served via HTTPS
+13.1k Golang : How to determine if user agent is a mobile device example
+15.2k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+7.9k Golang : Find the length of big.Int variable example
+5.7k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+7.9k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+19.7k Curl usage examples with Golang
+3.9k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+27.2k Golang : Detect (OS) Operating System
+12.4k Golang : Set image canvas or background to transparent
+5k Golang : Function as an argument type example
+8k Golang : Serving HTTP and Websocket from different ports in a program example