compromise
Version:
natural language processing in the browser
26 lines (23 loc) • 584 B
JavaScript
;
const log = require('../paths').log;
const rules = require('./data/word_rules');
const path = 'tagger/suffix';
const suffix_step = function(s) {
log.here(path);
s.terms.forEach((t) => {
//don't over-write any known tags
if (Object.keys(t.tag).length > 0) {
return;
}
//do normalized rules (on t.normal)
for (let o = 0; o < rules.length; o++) {
let r = rules[o];
if (t.normal.match(r.reg)) {
t.tagAs(r.tag, 'word-rule- "' + r.str + '"');
return;
}
}
});
return s;
};
module.exports = suffix_step;