UNPKG

compromise

Version:
32 lines (29 loc) 777 B
'use strict'; 'use strict'; const log = require('../paths').log; const path = 'tagger/value'; const value_step = function(ts) { log.here(path); ts.terms.forEach((t) => { if (t.tag.Value) { //ordinal/cardinal if (!t.tag.Ordinal && !t.tag.Cardinal) { if (t.normal.match(/^[0-9]([0-9]+,)*?(\.[0-9])$/)) { t.tagAs('Cardinal', 'ordinal-regex'); } else { t.tagAs('Cardinal', 'cardinal-regex'); } } //text/number if (!t.tag.TextValue && !t.tag.NumericValue) { if (t.normal.match(/^[a-z]/)) { t.tagAs('TextValue', 'TextValue-regex'); } else { t.tagAs('NumericValue', 'NumericValue-regex'); } } } }); return ts; }; module.exports = value_step;