better matching, now with plural forms and less distance

This commit is contained in:
2015-01-21 12:27:09 +01:00
parent e9c5fc7d8d
commit a8987936c4
4 changed files with 488 additions and 452 deletions
+11 -5
View File
@@ -33,16 +33,22 @@ smartPatternMatch <- function(string, pattern, chars, acronym) {
found <- agrep(patternrex, string, max.distance = list(all = 0), ignore.case = !acronym, fixed = FALSE)
}
else if(chars >= 8) { # 8 or more
found <- agrep(patternrex, string, max.distance = list(all = 2), ignore.case = !acronym, fixed = FALSE)
# Give longer words a chance by ignoring word boundaries \\b
if(convertLogical0(found) == 0) {
found <- grep(pattern, string, ignore.case = !acronym, fixed = FALSE)
}
found <- agrep(patternrex, string, max.distance = list(all = 1), ignore.case = !acronym, fixed = FALSE)
# # Give longer words a chance by ignoring word boundaries \\b
# if(convertLogical0(found) == 0) {
# found <- grep(pattern, string, ignore.case = !acronym, fixed = FALSE)
# }
}
else { # 5,6,7
found <- agrep(patternrex, string, max.distance = list(all = 1), ignore.case = !acronym, fixed = FALSE)
}
found <- convertLogical0(found)
if(found == 1) {
found <- TRUE
} else {
found <- FALSE
}
return(found)
}