Documentation ¶
Overview ¶
Package fuzzy implements fuzzy equal/contains reference implementations.
Index ¶
- func Distance(a, b string) int
- func EditDistance(data Data, needle Needle, ascii bool, method MatchMethod) int
- func GenFuzzyApprox3Spec(genCode bool) (dataStructure []byte, goCode string)
- func RefCmpStrFuzzyASCIIApprox3(data Data, needle Needle, threshold int) bool
- func RefCmpStrFuzzyUnicodeApprox3(data Data, needle Needle, threshold int) bool
- func RefHasSubstrFuzzyASCIIApprox3(data Data, needle Needle, threshold int) bool
- func RefHasSubstrFuzzyUnicodeApprox3(data Data, needle Needle, threshold int) bool
- type Data
- type KernelFunc
- type MatchMethod
- type Needle
- type TrueDamerauLevenshtein
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Distance ¶
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 ¶
GenFuzzyApprox3Spec generates the data-structure for the fuzzy approximation (with 3 characters lookahead)
func RefCmpStrFuzzyASCIIApprox3 ¶
RefCmpStrFuzzyASCIIApprox3 is the reference implementation for the str-match-fuzzy functionality
func RefCmpStrFuzzyUnicodeApprox3 ¶
RefCmpStrFuzzyUnicodeApprox3 is the reference implementation for the str-match-fuzzy functionality
func RefHasSubstrFuzzyASCIIApprox3 ¶
RefHasSubstrFuzzyASCIIApprox3 is the reference implementation for the has-substr-fuzzy functionality
Types ¶
type KernelFunc ¶
type MatchMethod ¶
type MatchMethod int64
const ( TrueEditDistance MatchMethod = iota Approx1 Approx2 Approx3 Approx4 )
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.