Skip to content

Commit 730bac9

Browse files
committed
fix incorrect indexing of words
1 parent c77c2bb commit 730bac9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dist/tag/js/tag.min.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -34892,16 +34892,18 @@ var BratParser = function () {
3489234892
}
3489334893
}
3489434894

34895+
var n = graph.words.length;
3489534896
this.textArray.forEach(function (t, i) {
3489634897
if (t.entity === null) {
3489734898
var text = _this.text.slice(t.charStart, t.charEnd).trim();
3489834899

3489934900
text.split(/\s+/).forEach(function (token) {
34900-
var word = new _word2.default(token, graph.words.length);
34901+
var word = new _word2.default(token, graph.words.length - n + 1);
3490134902
graph.words.push(word);
3490234903
});
3490334904
} else {
34904-
t.entity.idx = graph.words.length;
34905+
--n;
34906+
t.entity.idx = graph.words.length - n;
3490534907
}
3490634908
});
3490734909
graph.words.sort(function (a, b) {

src/js/parse/ann.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,18 @@ class BratParser {
6262
}
6363
}
6464

65+
let n = graph.words.length;
6566
this.textArray.forEach((t, i) => {
6667
if (t.entity === null) {
6768
let text = this.text.slice(t.charStart, t.charEnd).trim();
6869

6970
text.split(/\s+/).forEach(token => {
70-
let word = new Word(token, graph.words.length);
71+
let word = new Word(token, graph.words.length - n + 1);
7172
graph.words.push(word);
7273
});
7374
} else {
74-
t.entity.idx = graph.words.length;
75+
--n;
76+
t.entity.idx = graph.words.length - n;
7577
}
7678
});
7779
graph.words.sort((a, b) => a.idx - b.idx);

0 commit comments

Comments
 (0)