Replaced isEqual for better performance

This commit is contained in:
Konstantin Mamalakis 2018-03-06 23:28:08 +02:00 committed by Josh Harvey
parent 051dac127b
commit f8ec2be6e8
2 changed files with 4 additions and 5 deletions

View file

@ -66,10 +66,10 @@ function match (nameParts, birthDateString, threshold) {
const birthDate = {year, month, day, date} const birthDate = {year, month, day, date}
const candidate = {parts, fullName, wordValues, wordPhonetics, birthDate} const candidate = {parts, fullName, wordValues, wordPhonetics, birthDate}
debug_log(candidate) // debug_log(candidate)
const result = matcher.match(structs, candidate, threshold) const result = matcher.match(structs, candidate, threshold)
debug_log(result) // debug_log(result)
return result return result
} }

View file

@ -39,7 +39,6 @@ function match (structs, candidate, threshold) {
const aliases = _.flatMap(_.get('aliases'), structs.individuals) const aliases = _.flatMap(_.get('aliases'), structs.individuals)
const aliasIdsFromFullName = _.flow( const aliasIdsFromFullName = _.flow(
_.filter(doesNameMatch), _.filter(doesNameMatch),
_.map(_.get('id')) _.map(_.get('id'))
)(aliases) )(aliases)
@ -53,7 +52,7 @@ function match (structs, candidate, threshold) {
// Gether aliases whose name-parts match alphabetically. // Gether aliases whose name-parts match alphabetically.
const getStringMatches = value => { const getStringMatches = value => {
const entryMatches = entry => (jaroWinkler(value, entry.value) >= threshold) const entryMatches = entry => (stringSimilarity(value, entry.value) >= threshold)
return _.filter(entryMatches, structs.wordList) return _.filter(entryMatches, structs.wordList)
} }
const getSingleEntries = wordEntry => { const getSingleEntries = wordEntry => {
@ -71,7 +70,7 @@ 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(_.isEqual), _.uniqWith((a, b) => a.value === b.value && a.aliasId === b.aliasId),
_.map(_.get('aliasId')), _.map(_.get('aliasId')),
_.countBy(_.identity), _.countBy(_.identity),
_.toPairs, _.toPairs,