UNPKG

compromise

Version:
44 lines (39 loc) 913 B
'use strict'; const log = require('../paths').log; const phrasals = require('./data/phrasal_verbs'); const path = 'tagger/phrasal'; //words that could be particles const particles = { 'away': true, 'back': true, 'in': true, 'out': true, 'on': true, 'off': true, 'over': true, 'under': true, 'together': true, 'apart': true, 'up': true, 'down': true }; //phrasal verbs are compound verbs like 'beef up' const phrasals_step = function(ts) { log.here(path); for(let i = 1; i < ts.length; i++) { let t = ts.get(i); //is it a particle, like 'up' if (particles[t.normal]) { //look backwards let last = ts.get(i - 1); if (last.tag.Verb) { let inf = last.verb.infinitive(); if (phrasals[inf + ' ' + t.normal]) { t.tagAs('Particle', 'phrasalVerb-particle'); } } } } return ts; }; module.exports = phrasals_step;