Created new data structures for the upcomming matching
This commit is contained in:
parent
620863d703
commit
2f8c798304
3 changed files with 86 additions and 18 deletions
|
|
@ -5,12 +5,12 @@ const _ = require('lodash/fp')
|
|||
|
||||
const debug_log = require('../pp')(__filename) // KOSTIS TODO: remove
|
||||
|
||||
let individuals = null
|
||||
let structs = null
|
||||
|
||||
function load () {
|
||||
return dataParser.parseList()
|
||||
.then(list => {
|
||||
individuals = Array.from(list)
|
||||
return dataParser.produceStructs()
|
||||
.then(result => {
|
||||
structs = result
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ function makeCompatible (nameParts) {
|
|||
}
|
||||
|
||||
function match (nameParts, birthDateString) {
|
||||
if (!individuals) {
|
||||
if (!structs) {
|
||||
const message = 'The OFAC data sources have not been loaded yet.'
|
||||
return Promise.reject(new Error(message))
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ function match (nameParts, birthDateString) {
|
|||
debug_log(candidate)
|
||||
|
||||
const similarToCandidate = similarity(candidate)
|
||||
const result = mapMax(similarToCandidate, individuals)
|
||||
const result = mapMax(similarToCandidate, structs.individuals)
|
||||
console.log(result)
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue