UNPKG

compromise

Version:

modest natural language processing

23 lines (21 loc) • 525 B
import eachTerm from '../../1-one/tokenize/compute/_lib.js' const round = n => Math.round(n * 100) / 100 export default function (View) { // average tagger score View.prototype.confidence = function () { let sum = 0 let count = 0 eachTerm(this.docs, term => { count += 1 sum += term.confidence || 1 }) if (count === 0) { return 1 } return round(sum / count) } // (re-) run the POS-tagger View.prototype.tagger = function () { return this.compute(['tagger']) } }