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
+29.8k Golang : How to get HTTP request header information?
+4.6k Adding Skype actions such as call and chat into web page examples
+5.3k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+7.3k Golang : Check to see if *File is a file or directory
+7.4k Golang : Convert source code to assembly language
+13.1k Golang : How to calculate the distance between two coordinates using Haversine formula
+5.5k Python : Print unicode escape characters and string
+10.1k Golang : Text file editor (accept input from screen and save to file)
+24.4k Golang : GORM read from database example
+26.8k Golang : Force your program to run with root permissions
+6.2k Golang : Calculate US Dollar Index (DXY)