Split into files. Worked on style.
This commit is contained in:
parent
c4307cb749
commit
a3f8db79b3
4 changed files with 238 additions and 208 deletions
25
lib/ofac/name-utils.js
Normal file
25
lib/ofac/name-utils.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const metaphone = require('talisman/phonetics/metaphone')
|
||||
const doubleMetaphone = require('talisman/phonetics/double-metaphone')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
// KOSTIS TODO: Decide on a method. Remove the others
|
||||
|
||||
const phoneticMethod1 = metaphone
|
||||
|
||||
const phoneticMethod2 = _.flow(doubleMetaphone, _.uniq)
|
||||
|
||||
const phoneticMethod3 = _.flow(_.split(' '), _.map(phoneticMethod2))
|
||||
|
||||
// Combine name-parts in a standared order.
|
||||
|
||||
const fullNameFromParts = _.flow(
|
||||
_.toPairs,
|
||||
_.sortBy(_.nth(0)), // sort by part name,
|
||||
_.map(_.nth(1)), // get part value
|
||||
_.join(' ')
|
||||
)
|
||||
|
||||
module.exports = {
|
||||
fullNameFromParts,
|
||||
phonetic: phoneticMethod3
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue