Some matching tests

This commit is contained in:
Konstantin Mamalakis 2018-03-09 01:45:22 +02:00 committed by Josh Harvey
parent f8ec2be6e8
commit e7193e3948
5 changed files with 146 additions and 10 deletions

View file

@ -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)