Documentation
¶
Overview ¶
Package tdl implements the true Damerau–Levenshtein distance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 New ¶
func New(maxSize int) *TrueDamerauLevenshtein
New initializes a new struct which allocates memory only once, to be used by Distance(). maxSize sets an upper limit for both input strings used in Distance().
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.