-
Notifications
You must be signed in to change notification settings - Fork 0
/
counts.js
29 lines (24 loc) · 869 Bytes
/
counts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const defaultdict = require('defaultdict2');
const REGEX_IOB_TAG = /^([^-]*)-(.*)$/
class EvalCounts {
constructor() {
this.correct_chunk = 0; // number of correctly identified chunks
this.correct_tags = 0; // number of correct chuck tags
this.found_correct = 0; // number of chunks in corpus
this.found_guessed = 0; // number of identified chunks
this.token_counter = 0; // token counter (ignores sentence breaks)
// count by type
this.t_correct_chunk = defaultdict(0);
this.t_found_correct = defaultdict(0);
this.t_found_guessed = defaultdict(0);
}
get empty() {
return Object.create(null);
}
parse_tag(tag) {
let match = REGEX_IOB_TAG.exec(tag);
return match ? [match[1], match[2]] : [tag, ''];
}
}
module.exports = EvalCounts;