UNPKG

compromise

Version:
52 lines (44 loc) 1.19 kB
'use strict'; const fixContraction = require('./fix'); const irregulars = { 'wanna': ['want', 'to'], 'gonna': ['going', 'to'], 'im': ['i', 'am'], 'alot': ['a', 'lot'], 'dont': ['do', 'not'], 'dun': ['do', 'not'], 'won\'t': ['will', 'not'], 'wont': ['will', 'not'], 'can\'t': ['can', 'not'], 'cant': ['can', 'not'], 'cannot': ['can', 'not'], 'aint': ['is', 'not'], //or 'are' 'ain\'t': ['is', 'not'], 'shan\'t': ['should', 'not'], 'where\'d': ['where', 'did'], 'whered': ['where', 'did'], 'when\'d': ['when', 'did'], 'whend': ['when', 'did'], 'how\'d': ['how', 'did'], 'howd': ['how', 'did'], 'what\'d': ['what', 'did'], 'whatd': ['what', 'did'], 'let\'s': ['let', 'us'], // 'dunno': ['do', 'not', 'know'], // 'brb': ['be', 'right', 'back'] }; //check irregulars const checkIrregulars = (ts) => { let irreg = Object.keys(irregulars); for(let i = 0; i < irreg.length; i++) { for(let t = 0; t < ts.terms.length; t++) { if (ts.terms[t].normal === irreg[i]) { let fix = irregulars[irreg[i]]; ts = fixContraction(ts, fix, t); break; } } } return ts; }; module.exports = checkIrregulars;