UNPKG

compromise

Version:
36 lines (33 loc) 946 B
'use strict'; // const conditionPass = function(r) { //'if it really goes, I will..' let m = r.match('#Condition {1,7} #ClauseEnd'); //make sure it ends on a comma if (m.found && m.match('#Comma$')) { m.tag('ConditionPhrase'); } //'go a bit further, if it then has a pronoun m = r.match('#Condition {1,13} #ClauseEnd #Pronoun'); if (m.found && m.match('#Comma$')) { m.not('#Pronoun$').tag('ConditionPhrase', 'end-pronoun'); } //if it goes then .. m = r.match('#Condition {1,7} then'); if (m.found) { m.not('then$').tag('ConditionPhrase', 'cond-then'); } //at the end of a sentence: //'..., if it really goes.' m = r.match('#Comma #Condition {1,7} .$'); if (m.found) { m.not('^#Comma').tag('ConditionPhrase', 'comma-7-end'); } // '... if so.' m = r.match('#Condition {1,4}$'); if (m.found) { m.tag('ConditionPhrase', 'cond-4-end'); } return r; }; module.exports = conditionPass;