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.8k Golang : Struct field tags and what is their purpose?
+21.7k Golang : Randomly pick an item from a slice/array example
+13.6k Golang : Search folders for file recursively with wildcard support
+8.1k Golang : Create and shuffle deck of cards example
+5.7k Golang : Warp text string by number of characters or runes example
+19.5k Golang : Clean up null characters from input data
+7.1k Golang : HTTP Server Example
+15.5k Golang : How to generate QR codes?
+4.4k Javascript : How to loop over and parse JSON data?
+18.9k Nginx + FastCGI + Go Setup.
+4.8k Unix/Linux : How to open tar.gz file ?