fuzzy

package
v0.0.0-...-86e9f11 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fuzzy implements fuzzy equal/contains reference implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(a, b string) int

Distance is a shortcut func for doing a quick and dirty calculation, without having to set up your own struct and stuff. Not thread safe!

func EditDistance

func EditDistance(data Data, needle Needle, ascii bool, method MatchMethod) int

EditDistance calculates the edit distance with the provided method

func GenFuzzyApprox3Spec

func GenFuzzyApprox3Spec(genCode bool) (dataStructure []byte, goCode string)

GenFuzzyApprox3Spec generates the data-structure for the fuzzy approximation (with 3 characters lookahead)

func RefCmpStrFuzzyASCIIApprox3

func RefCmpStrFuzzyASCIIApprox3(data Data, needle Needle, threshold int) bool

RefCmpStrFuzzyASCIIApprox3 is the reference implementation for the str-match-fuzzy functionality

func RefCmpStrFuzzyUnicodeApprox3

func RefCmpStrFuzzyUnicodeApprox3(data Data, needle Needle, threshold int) bool

RefCmpStrFuzzyUnicodeApprox3 is the reference implementation for the str-match-fuzzy functionality

func RefHasSubstrFuzzyASCIIApprox3

func RefHasSubstrFuzzyASCIIApprox3(data Data, needle Needle, threshold int) bool

RefHasSubstrFuzzyASCIIApprox3 is the reference implementation for the has-substr-fuzzy functionality

func RefHasSubstrFuzzyUnicodeApprox3

func RefHasSubstrFuzzyUnicodeApprox3(data Data, needle Needle, threshold int) bool

RefHasSubstrFuzzyUnicodeApprox3 is the reference implementation for the has-substr-fuzzy functionality

Types

type Data

type Data = stringext.Data

type KernelFunc

type KernelFunc func(data, needle []rune, posData idxDataT, posNeedle idxNeedleT) (distance int, advData idxDataT, advNeedle idxNeedleT)

type MatchMethod

type MatchMethod int64
const (
	TrueEditDistance MatchMethod = iota
	Approx1
	Approx2
	Approx3
	Approx4
)

type Needle

type Needle = stringext.Needle

type TrueDamerauLevenshtein

type TrueDamerauLevenshtein struct {
	// contains filtered or unexported fields
}

TrueDamerauLevenshtein is a struct that allocates memory only once, which is used when running Distance(). This whole struct and associated functions are not thread safe in any way, that will be the callers responsibility! At least for now...

func (*TrueDamerauLevenshtein) Distance

func (t *TrueDamerauLevenshtein) Distance(a, b string) int

Distance calculates and returns the true Damerau–Levenshtein distance of string A and B. It's the caller's responsibility if he wants to trim whitespace or fix lower/upper cases.

If either of string A or B is too large for the internal memory matrix, we will allocate a bigger matrix on the fly. If not, Distance() won't cause any other allocs.

Jump to

Keyboard shortcuts

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