WIP
This commit is contained in:
parent
f7561acf3c
commit
80e851fb59
9 changed files with 131 additions and 76 deletions
|
|
@ -7,9 +7,7 @@ const nameUtils = require('./name-utils')
|
|||
const options = require('../options')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const debug_log = require('../pp')(__filename) // KOSTIS TODO: remove
|
||||
|
||||
const OFAC_SOURCES_DIR = path.join(options.ofacDataDir, 'sources')
|
||||
const debugLog = require('../pp')(__filename) // KOSTIS TODO: remove
|
||||
|
||||
let structs = null
|
||||
|
||||
|
|
@ -18,19 +16,21 @@ const readdir = util.promisify(fs.readdir)
|
|||
function load () {
|
||||
// NOTE: Not sure how you push code updates to existing clients. This problem
|
||||
// might pop up if new code is pushed, without re-doing setup.
|
||||
if (!OFAC_SOURCES_DIR) {
|
||||
if (!options.ofacDataDir) {
|
||||
const message = 'The ofacDataDir option has not been set in lamassu.json'
|
||||
return Promise.reject(new Error(message))
|
||||
}
|
||||
|
||||
return readdir(OFAC_SOURCES_DIR)
|
||||
.then(_.flow(
|
||||
_.map(file => path.join(OFAC_SOURCES_DIR, file)),
|
||||
loader.load
|
||||
))
|
||||
.then(result => {
|
||||
return (structs = result)
|
||||
})
|
||||
const ofacSourcesDir = path.join(options.ofacDataDir, 'sources')
|
||||
|
||||
return readdir(ofacSourcesDir)
|
||||
.then(_.flow(
|
||||
_.map(file => path.join(ofacSourcesDir, file)),
|
||||
loader.load
|
||||
))
|
||||
.then(result => {
|
||||
return (structs = result)
|
||||
})
|
||||
}
|
||||
|
||||
// nameParts should be an object like {firstName: "John", lastName: "Doe", ...}
|
||||
|
|
@ -69,10 +69,10 @@ function match (nameParts, birthDateString, options) {
|
|||
])(birthDateString)
|
||||
|
||||
const candidate = {parts, fullName, words, birthDate}
|
||||
debug && debug_log(candidate)
|
||||
debug && debugLog(candidate)
|
||||
|
||||
const result = matcher.match(structs, candidate, options)
|
||||
debug && debug_log(result)
|
||||
debug && debugLog(result)
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue