Name-part matching now combines Jaro and Double Metaphone scores

This commit is contained in:
Konstantin Mamalakis 2018-03-13 22:07:44 +02:00 committed by Josh Harvey
parent f00516ce2e
commit 793db0f449
5 changed files with 54 additions and 78 deletions

View file

@ -37,7 +37,7 @@ function load () {
function makeCompatible (nameParts) {
const partNames = _.keys(nameParts)
const values = _.values(nameParts)
const values = _.map(_.lowerCase, _.values(nameParts))
const props = _.zipAll([partNames, values])
return _.map(_.zipObject(['partName', 'value']), props)
}
@ -54,12 +54,6 @@ function match (nameParts, birthDateString, threshold) {
const fullName = nameUtils.makeFullName(parts)
const words = nameUtils.makeWords(fullName)
const wordValues = _.map(_.get('value'), words)
const wordPhonetics = _.flatMap(word => {
const {phonetics} = word
return _.map(phonetic => ({word: word.value, phonetic}), phonetics)
}, words)
// birthDateString is in YYYYMMDD format
const birthDate = _.cond([
[_.identity, () => {
@ -73,7 +67,7 @@ function match (nameParts, birthDateString, threshold) {
[_.stubTrue, () => null]
])(birthDateString)
const candidate = {parts, fullName, wordValues, wordPhonetics, birthDate}
const candidate = {parts, fullName, words, birthDate}
// debug_log(candidate)
const result = matcher.match(structs, candidate, threshold)