gofuzz

package module
v0.0.0-...-82a4e71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2015 License: MIT Imports: 2 Imported by: 1

README

GoFuzz

Fuzzy string matching algorithm implementations

GoFuzz is a collection of metrics and phonetic (fuzzy string matching) algorithms for Go. It is based entirely on the rockymadden stringmetric library written by Rocky Madden for Scala. I didn't use much of his code, but I've used all of his tests. There will eventually be implementations of all of the string metric and phonetic algorithms implemented in his library if I can find the time. The library provides facilities to perform approximate string matching, measurement of string similarity/distance, indexing by word pronunciation, and sounds-like comparisons. The best way to see usage is to check out the tests and the documentation.

The following algorithms are currently implemented.

  1. JaroWinklerMetric
  2. OverlapMetric
  3. MetaphoneAlgorithm

I implemented these ones first because I needed them for another project. I will be adding more as time progresses. If you need one of them for a project, and I haven't implemented it yet, please let me know so that I can give it a higher priority. I have started this same library in Elixir as well.

Documentation

Overview

GoFuzz is a collection of metrics and phonetic (fuzzy string matching) algorithms for Go.

All of the phonetic functions are defined within the 'phon' subdirectory, and all of the similarity functions are defined within the 'sim' subdirectory. They are also set up to be called from the gofuzz package, whichever is easier.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Jaro

func Jaro(s1 string, s2 string) (float32, error)

Jaro calculates the Jaro distance between two strings.

Example
result, err := Jaro("bob", "bobby")
if err != nil {
	fmt.Print("an unexpected error was encountered")
}
fmt.Print(result)
Output:
0.75555557

func JaroWinkler

func JaroWinkler(s1 string, s2 string) (float32, error)

JaroWinkler calculates the Jaro-Winkler distance between two strings.

Example
result, err := JaroWinkler("bob", "bobby")
if err != nil {
	fmt.Print("an unexpected error was encountered")
}
fmt.Print(result)
Output:
0.8288889

func Metaphone

func Metaphone(val string) (string, error)

Metaphone returns the metaphone phonetic version of the provided string.

Example
result, err := Metaphone("Colorado")
if err != nil {
	fmt.Print("an unexpected error was encountered")
}
fmt.Print(result)
Output:
klrt

func MetaphoneMetric

func MetaphoneMetric(val1 string, val2 string) (bool, error)

MetaphoneMetric compares two strings and returns a boolean of whether they match or not.

Example
result, err := MetaphoneMetric("Colorado", "Kolorado")
if err != nil {
	fmt.Print("an unexpected error was encountered")
}
fmt.Print(result)
Output:
true

func Overlap

func Overlap(s1 string, s2 string, ngramSize int) (float32, error)

Overlap calculates the Overlap distance between two strings.

Note: the ngramSize is the number of letters to clump together when doing the comparison. When in doubt, set it to 1.

Example
result, err := Overlap("Chipotle", "Chipotle Mexican Grill", 2)
if err != nil {
	fmt.Print("an unexpected error was encountered")
}
fmt.Print(result)
Output:
1

Types

This section is empty.

Directories

Path Synopsis
Phon contains all of the functions for doing phonetic comparisons.
Phon contains all of the functions for doing phonetic comparisons.
Sim contains all of the functions for calculating similarity.
Sim contains all of the functions for calculating similarity.
Utl contains utility fuctions used by the GoFuzz library.
Utl contains utility fuctions used by the GoFuzz library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL