Fixed issue with one word matching multiple
This commit is contained in:
parent
3e80cb745b
commit
3722ab2af3
2 changed files with 19 additions and 3 deletions
|
|
@ -55,7 +55,10 @@ function match (nameParts, birthDateString, threshold) {
|
||||||
const words = nameUtils.makeWords(fullName)
|
const words = nameUtils.makeWords(fullName)
|
||||||
|
|
||||||
const wordValues = _.map(_.get('value'), words)
|
const wordValues = _.map(_.get('value'), words)
|
||||||
const wordPhonetics = _.flatMap(_.get('phonetics'), words)
|
const wordPhonetics = _.flatMap(word => {
|
||||||
|
const {phonetics} = word
|
||||||
|
return _.map(phonetic => ({word: word.value, phonetic}), phonetics)
|
||||||
|
}, words)
|
||||||
|
|
||||||
// birthDateString is in YYYYMMDD format
|
// birthDateString is in YYYYMMDD format
|
||||||
const birthDate = _.cond([
|
const birthDate = _.cond([
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,13 @@ function match (structs, candidate, threshold) {
|
||||||
// Gather aliases who's name-parts match phonetically.
|
// Gather aliases who's name-parts match phonetically.
|
||||||
const getPhoneticMatches = phonetic => structs.phoneticMap.get(phonetic)
|
const getPhoneticMatches = phonetic => structs.phoneticMap.get(phonetic)
|
||||||
const phoneticMatches = _.flow(
|
const phoneticMatches = _.flow(
|
||||||
_.map(getPhoneticMatches),
|
_.map(wordPhonetic => {
|
||||||
|
const {word, phonetic} = wordPhonetic
|
||||||
|
const matches = getPhoneticMatches(phonetic)
|
||||||
|
return _.map(match => ({...match, word}), matches)
|
||||||
|
}),
|
||||||
_.compact,
|
_.compact,
|
||||||
|
// _.map(_.uniqWith((a, b) => a.aliasId === b.aliasId)),
|
||||||
_.flatten
|
_.flatten
|
||||||
)(wordPhonetics)
|
)(wordPhonetics)
|
||||||
|
|
||||||
|
|
@ -71,7 +76,10 @@ function match (structs, candidate, threshold) {
|
||||||
return count >= Math.min(2, alias.words.length)
|
return count >= Math.min(2, alias.words.length)
|
||||||
}
|
}
|
||||||
const aliasIdsFromNamePart = _.flow(
|
const aliasIdsFromNamePart = _.flow(
|
||||||
_.uniqWith((a, b) => a.value === b.value && a.aliasId === b.aliasId),
|
_.uniqWith((a, b) => (
|
||||||
|
(a.value === b.value && a.aliasId === b.aliasId) ||
|
||||||
|
(a.word === b.word && a.aliasId === b.aliasId)
|
||||||
|
)),
|
||||||
_.map(_.get('aliasId')),
|
_.map(_.get('aliasId')),
|
||||||
_.countBy(_.identity),
|
_.countBy(_.identity),
|
||||||
_.toPairs,
|
_.toPairs,
|
||||||
|
|
@ -79,6 +87,11 @@ function match (structs, candidate, threshold) {
|
||||||
_.map(_.first)
|
_.map(_.first)
|
||||||
)([...phoneticMatches, ...stringMatches])
|
)([...phoneticMatches, ...stringMatches])
|
||||||
|
|
||||||
|
// debug_log(aliasIdsFromFullName)
|
||||||
|
// debug_log(phoneticMatches)
|
||||||
|
// debug_log(stringMatches)
|
||||||
|
// debug_log(aliasIdsFromNamePart)
|
||||||
|
|
||||||
// Get the full record for each matched id
|
// Get the full record for each matched id
|
||||||
const getIndividual = aliasId => {
|
const getIndividual = aliasId => {
|
||||||
const individualId = structs.aliasToIndividual.get(aliasId)
|
const individualId = structs.aliasToIndividual.get(aliasId)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue