Some matching tests
This commit is contained in:
parent
f8ec2be6e8
commit
e7193e3948
5 changed files with 146 additions and 10 deletions
|
|
@ -29,7 +29,7 @@ function load () {
|
|||
parser.parse
|
||||
))
|
||||
.then(result => {
|
||||
structs = result
|
||||
return (structs = result)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -58,12 +58,17 @@ function match (nameParts, birthDateString, threshold) {
|
|||
const wordPhonetics = _.flatMap(_.get('phonetics'), words)
|
||||
|
||||
// birthDateString is in YYYYMMDD format
|
||||
const year = parseInt(birthDateString.slice(0, 4))
|
||||
const month = parseInt(birthDateString.slice(4, 6))
|
||||
const day = parseInt(birthDateString.slice(6, 8))
|
||||
const date = new Date(year, month - 1, day)
|
||||
const birthDate = _.cond([
|
||||
[_.identity, () => {
|
||||
const year = parseInt(birthDateString.slice(0, 4))
|
||||
const month = parseInt(birthDateString.slice(4, 6))
|
||||
const day = parseInt(birthDateString.slice(6, 8))
|
||||
const date = new Date(year, month - 1, day)
|
||||
|
||||
const birthDate = {year, month, day, date}
|
||||
return {year, month, day, date}
|
||||
}],
|
||||
[_.stubTrue, () => null]
|
||||
])(birthDateString)
|
||||
|
||||
const candidate = {parts, fullName, wordValues, wordPhonetics, birthDate}
|
||||
// debug_log(candidate)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ function isDateWithinSomeDaysOfPeriod (period, date, days) {
|
|||
}
|
||||
|
||||
const isBornTooLongSince = _.curry((days, dateObject, individual) => {
|
||||
if (!dateObject) return false
|
||||
if (_.isEmpty(individual.birthDatePeriods)) return false
|
||||
const isWithinSomeYears = _.partialRight(isDateWithinSomeDaysOfPeriod, [dateObject.date, days])
|
||||
return !_.some(isWithinSomeYears, individual.birthDatePeriods)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ function processProfile (profileNode) {
|
|||
const birthDatePeriods = mapCompact(processFeature, profileNode.Feature)
|
||||
const individual = {id, aliases, birthDatePeriods}
|
||||
|
||||
debug_log(individual)
|
||||
// debug_log(individual)
|
||||
|
||||
return individual
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue