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
+6.6k Swift : Convert (cast) String to Double
+3.7k Javascript : How to get width and height of a div?
+12.3k Android Studio : Use image as AlertDialog title with custom layout example
+50k Golang : How to get time in milliseconds?
+10.8k Golang : Arithmetic operation with numerical slices or arrays example
+24.2k Golang : Convert file content into array of bytes
+8.4k Javascript : Read/parse JSON data from HTTP response
+5.2k Golang : Embedded or data bundling example
+4.2k Python : Delay with time.sleep() function example
+10.3k Golang : Perform sanity checks on filename example
+22.9k Golang : Change file read or write permission example
+26.6k Golang : Detect (OS) Operating System