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
+11.3k Golang : Arithmetic operation with numerical slices or arrays example
+16.2k Golang : How to remove certain lines from a file
+4.2k Golang : Calculate half life decay example
+6.8k Android Studio : Rating bar example
+27.8k Golang : Get first few and last few characters from string
+19.9k Golang : Encrypt and decrypt data with TripleDES
+11.3k Elastic Search : Return all records (higher than default 10)
+13.9k Golang : How to get Unix file descriptor for console and file
+7.4k Golang : Convert word to its plural form example
+9.7k Golang : Fix - does not implement sort.Interface (missing Len method)
+7.2k Golang : Metaprogramming example of wrapping a function
+20.5k Golang : Match strings by wildcard patterns with filepath.Match() function