Match aliases with only one word

This commit is contained in:
Konstantin Mamalakis 2018-03-06 00:23:25 +02:00 committed by Josh Harvey
parent 9d609e6461
commit 051dac127b
2 changed files with 9 additions and 1 deletions

View file

@ -66,12 +66,16 @@ function match (structs, candidate, threshold) {
)(wordValues)
// At least two name-parts must match per alias
const adequateMatch = ([aliasId, count]) => {
const alias = structs.aliasesMap.get(aliasId)
return count >= Math.min(2, alias.words.length)
}
const aliasIdsFromNamePart = _.flow(
_.uniqWith(_.isEqual),
_.map(_.get('aliasId')),
_.countBy(_.identity),
_.toPairs,
_.filter(_.flow(_.last, _.lte(2))),
_.filter(adequateMatch),
_.map(_.first)
)([...phoneticMatches, ...stringMatches])