go-edlib: github.com/hbollon/go-edlib Index | Files | Directories

package edlib

import "github.com/hbollon/go-edlib"

Index

Package Files

hamming.go jaro.go lcs.go levenshtein.go string-analysis.go

func DamerauLevenshteinDistance Uses

func DamerauLevenshteinDistance(str1, str2 string) int

DamerauLevenshteinDistance calculate the distance between two string This algorithm computes the true Damerau–Levenshtein distance with adjacent transpositions Allowing insertions, deletions, substitutions and transpositions to change one string to the second Compatible with non-ASCII characters

func FuzzySearch Uses

func FuzzySearch(str string, strList []string, algo AlgorithMethod) (string, error)

FuzzySearch realize an approximate search on a string list and return the closest one compared to the string input

func FuzzySearchSet Uses

func FuzzySearchSet(str string, strList []string, quantity int, algo AlgorithMethod) ([]string, error)

FuzzySearchSet realize an approximate search on a string list and return a set composed with x strings compared to the string input sorted by similarity with the base string. Takes the a quantity parameter to define the number of output strings desired (For example 3 in the case of the Google Keyboard word suggestion).

func FuzzySearchSetThreshold Uses

func FuzzySearchSetThreshold(str string, strList []string, quantity int, minSim float32, algo AlgorithMethod) ([]string, error)

FuzzySearchSetThreshold realize an approximate search on a string list and return a set composed with x strings compared to the string input sorted by similarity with the base string. Take a similarity threshold in parameter. Takes the a quantity parameter to define the number of output strings desired (For example 3 in the case of the Google Keyboard word suggestion). Takes also a threshold parameter for similarity with base string.

func FuzzySearchThreshold Uses

func FuzzySearchThreshold(str string, strList []string, minSim float32, algo AlgorithMethod) (string, error)

FuzzySearchThreshold realize an approximate search on a string list and return the closest one compared to the string input. Takes a similarity threshold in parameter.

func HammingDistance Uses

func HammingDistance(str1, str2 string) (int, error)

HammingDistance calculate the edit distance between two given strings using only substitutions Return edit distance integer and an error

func JaroSimilarity Uses

func JaroSimilarity(str1, str2 string) float32

JaroSimilarity return a similarity index (between 0 and 1) It use Jaro distance algorithm and allow only transposition operation

func JaroWinklerSimilarity Uses

func JaroWinklerSimilarity(str1, str2 string) float32

JaroWinklerSimilarity return a similarity index (between 0 and 1) Use Jaro similarity and after look for a common prefix (length <= 4)

func LCS Uses

func LCS(str1, str2 string) int

LCS takes two strings and compute their LCS(Longuest Subsequence Problem)

func LCSBacktrack Uses

func LCSBacktrack(str1, str2 string) (string, error)

LCSBacktrack returns all choices taken during LCS process

func LCSBacktrackAll Uses

func LCSBacktrackAll(str1, str2 string) ([]string, error)

LCSBacktrackAll returns an array containing all common substrings between str1 and str2

func LCSDiff Uses

func LCSDiff(str1, str2 string) ([]string, error)

LCSDiff will backtrack through the lcs matrix and return the diff between the two sequences

func LCSEditDistance Uses

func LCSEditDistance(str1, str2 string) int

LCSEditDistance determines the edit distance between two strings using LCS function (allow only insert and delete operations)

func LevenshteinDistance Uses

func LevenshteinDistance(str1, str2 string) int

LevenshteinDistance calculate the distance between two string This algorithm allow insertions, deletions and substitutions to change one string to the second Compatible with non-ASCII characters

func OSADamerauLevenshteinDistance Uses

func OSADamerauLevenshteinDistance(str1, str2 string) int

OSADamerauLevenshteinDistance calculate the distance between two string Optimal string alignment distance variant that use extension of the Wagner-Fisher dynamic programming algorithm Doesn't allow multiple transformations on a same substring Allowing insertions, deletions, substitutions and transpositions to change one string to the second Compatible with non-ASCII characters

func StringsSimilarity Uses

func StringsSimilarity(str1 string, str2 string, algo AlgorithMethod) (float32, error)

StringsSimilarity return a similarity index [0..1] between two strings based on given edit distance algorithm in parameter. Use defined AlgorithmMethod type.

type AlgorithMethod Uses

type AlgorithMethod uint8

AlgorithMethod is an Integer type used to identify edit distance algorithms

const (
    // Levenshtein algo identifier
    Levenshtein AlgorithMethod = iota
    // DamerauLevenshtein algo identifier
    DamerauLevenshtein AlgorithMethod = iota
    // OSADamerauLevenshtein algo identifier
    OSADamerauLevenshtein AlgorithMethod = iota
    // Lcs algo identifier
    Lcs AlgorithMethod = iota
    // Hamming algo identifier
    Hamming AlgorithMethod = iota
    // Jaro algo identifier
    Jaro AlgorithMethod = iota
    // JaroWinkler algo identifier
    JaroWinkler AlgorithMethod = iota
)

Directories

PathSynopsis
internal/orderedmap
internal/utils

Package edlib imports 4 packages (graph). Updated 2020-09-22. Refresh now. Tools for package owners.