lamassu-server/lib/ofac/name-utils.js
2018-05-03 20:20:18 +03:00

25 lines
634 B
JavaScript

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 standard order.
const fullNameFromParts = _.flow(
_.toPairs,
_.sortBy(_.first), // sort by part name,
_.map(_.last), // get part value
_.join(' ')
)
module.exports = {
fullNameFromParts,
phonetic: phoneticMethod3
}