compromise
Version:
natural language processing in the browser
93 lines (89 loc) • 1.24 kB
JavaScript
;
//some most-common iso-codes (most are too ambiguous)
const shortForms = [
'usd',
'cad',
'aud',
'gbp',
'krw',
'inr',
'hkd',
'dkk',
'cny',
'xaf',
'xof',
'eur',
'jpy',
//currency symbols
'€',
'$',
'¥',
'£',
'лв',
'₡',
'kn',
'kr',
'¢',
'Ft',
'Rp',
'﷼',
'₭',
'ден',
'₨',
'zł',
'lei',
'руб',
'฿',
];
//some common, unambiguous currency names
let longForms = [
'denar',
'dobra',
'forint',
'kwanza',
'kyat',
'lempira',
'pound sterling',
'riel',
'yen',
'zloty',
//colloquial currency names
'dollar',
'cent',
'penny',
'dime',
'dinar',
'euro',
'lira',
'pound',
'pence',
'peso',
'baht',
'sterling',
'rouble',
'shekel',
'sheqel',
'yuan',
'franc',
'rupee',
'shilling',
'krona',
'dirham',
'bitcoin'
];
const irregularPlurals = {
yen: 'yen',
baht: 'baht',
riel: 'riel',
penny: 'pennies',
};
//add plural forms - 'euros'
let l = longForms.length;
for(let i = 0; i < l; i++) {
if (irregularPlurals[longForms[i]]) {
longForms.push(irregularPlurals[longForms[i]]);
} else {
longForms.push(longForms[i] + 's');
}
}
module.exports = shortForms.concat(longForms);