Documentation ¶
Overview ¶
approx is a package for approximate string matching. It will extract strings withing a given edit distance and return their start, end, and distance.
Index ¶
Constants ¶
const MaxInt = int(^uint(0) >> 1)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Match ¶
A match
func ApproxFind ¶
ApproxFind uses a modified Levenshtein function to find a 'pattern' in a 'text'. It is not the most optimal way to do this for longer strings, thus it is recommend for use on short patterns only (to be defined lanter). If you are finding that it returns many options for a single pattern, ie find 'perl' in 'berd' with a max dist of 2, You should concider ammending the Options to make the version you don't want to see cost more.
type MatchFunction ¶
type Options ¶
type Options struct { InsCost int DelCost int SubCost int Matches MatchFunction }
var DefaultOptions Options = Options{ InsCost: 1, DelCost: 1, SubCost: 1, Matches: func(sourceCharacter rune, targetCharacter rune) bool { return sourceCharacter == targetCharacter }, }
DefaultOptions is the default options: insertion cost is 1, deletion cost is 1, substitution cost is 1, and two runes match iff they are the same.