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
+17.9k Golang : Iterate linked list example
+10.2k Golang : Find and replace data in all files recursively
+11.1k Golang : Read until certain character to break for loop
+13.5k Golang : Get constant name from value
+21.2k Golang : Convert(cast) string to rune and back to string example
+19.7k Golang : Set or Add HTTP Request Headers
+5.5k Golang : Get S3 or CloudFront object or file information
+13.1k Golang : Calculate elapsed years or months since a date
+23.2k Golang : Randomly pick an item from a slice/array example
+12.8k Golang : Add ASCII art to command line application launching process
+9.1k Golang : How to use Gorilla webtoolkit context package properly
+6.1k Java : Human readable password generator