Skip to content

samprakos/gofuzzyset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gofuzzyset

A go implementation of the Javascript fuzzyset library, which is itself a port from a python library.

There is EXCELLENT documentation by the author of the Javascript library here.

Usage

The usage is simple. Just initialize a new fuzzyset, and ask for matches by using .Get:

package main

import (
	"github.com/samprakos/gofuzzyset"
	"log"
)

func main() {
	lowerGramSize := 2
	upperGramSize := 3
	minScore := 0.33

	data := []string{
		"Alabama",
		"Alaska",
		"Arizona",
		"Arkansas",
		"California",
		"Colorado",
		"Connecticut",
		"Delaware",
		"Florida",
		"Georgia",
		"Hawaii",
		"Idaho",
		"Illinois",
		"Indiana",
		"Iowa",
		"Kansas",
		"Kentucky",
		"Louisiana",
		"Maine",
		"Maryland",
		"Massachusetts",
		"Michigan",
		"Minnesota",
		"Mississippi",
		"Missouri",
		"Montana",
		"Nebraska",
		"Nevada",
		"New Hampshire",
		"New Jersey",
		"New Mexico",
		"New York",
		"North Carolina",
		"North Dakota",
		"Ohio",
		"Oklahoma",
		"Oregon",
		"Pennsylvania",
		"Rhode Island",
		"South Carolina",
		"South Dakota",
		"Tennessee",
		"Texas",
		"Utah",
		"Vermont",
		"Virginia",
		"Washington",
		"West Virginia",
		"Wisconsin",
		"Wyoming",
	}

	f := gofuzzyset.New(data, false, lowerGramSize, upperGramSize, minScore)

	results := f.Get("mossisippi")

	log.Printf("%v results found", len(results))
}

The result will []Match. The score is between 0 and 1, with 1 being a perfect match.

type Match struct {
	Word string
	Score float64
}

About

A go implementation of the Javascript fuzzyset library (https://github.com/Glench/fuzzyset.js), which is itself a port from a python library (https://github.com/axiak/fuzzyset).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages