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
+4.7k Golang : Calculate a pip value and distance to target profit example
+11.1k Golang : Concatenate (combine) buffer data example
+16.5k Golang : read gzipped http response
+30.1k Golang : How to redirect to new page with net/http?
+8.7k Golang : automatically figure out array length(size) with three dots
+21.5k Golang : How to reverse slice or array elements order
+24.9k Golang : Storing cookies in http.CookieJar example
+7.3k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+11.6k Golang : Clean formatting/indenting or pretty print JSON result
+6.6k Golang : Decode XML data from RSS feed
+33.6k Golang : Proper way to set function argument default value
+9.6k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral