Support modifier for value search and allow ability to select matching criteria for multi value field - Removed name from rule for now - Value modifier to search with are ignore-case, case-sensitive, fuzzy-search, sounds-like - Multi value matching criteria are one-of, equal - Migrate RecordDeDup config for module, by adding upgrade fix for module.config.recordDeDup to migrate as per to the latest DeDupRule struct.
32 lines
672 B
Go
32 lines
672 B
Go
package str
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// DefaultLevenshteinDistance is the default levenshtein distance
|
|
DefaultLevenshteinDistance = 3
|
|
|
|
CaseInSensitiveMatch = iota
|
|
CaseSensitiveMatch
|
|
LevenshteinDistance
|
|
Soundex
|
|
)
|
|
|
|
// Match will match string as per given algorithm
|
|
func Match(str1, str2 string, algorithm int) bool {
|
|
switch algorithm {
|
|
case LevenshteinDistance:
|
|
return ToLevenshteinDistance(str1, str2) <= DefaultLevenshteinDistance
|
|
case Soundex:
|
|
return ToSoundex(str1) == ToSoundex(str2)
|
|
case CaseSensitiveMatch:
|
|
return strings.Compare(str1, str2) == 0
|
|
case CaseInSensitiveMatch:
|
|
return strings.EqualFold(str1, str2)
|
|
default:
|
|
return false
|
|
}
|
|
}
|