compromise
Version:
natural language processing in the browser
28 lines (25 loc) • 689 B
JavaScript
;
const log = require('../paths').log;
const path = 'tagger/negation';
// 'not' is sometimes a verb, sometimes an adjective
const negation_step = function(ts) {
log.here(path);
for(let i = 0; i < ts.length; i++) {
let t = ts.get(i);
if (t.normal === 'not' || t.silent_term === 'not') {
//find the next verb/adjective
for(let o = i + 1; o < ts.length; o++) {
if (ts.get(o).tag.Verb) {
t.tagAs('VerbPhrase', 'negate-verb');
break;
}
if (ts.get(o).tag.Adjective) {
t.tagAs('AdjectivePhrase', 'negate-adj');
break;
}
}
}
}
return ts;
};
module.exports = negation_step;