Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit 7312a71

Browse files
author
Francois-Xavier Gentilhomme
committed
[FIX] fixes word/char segments issue
1 parent de4c37c commit 7312a71

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

demo/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ <h1>MyScriptJS demo</h1>
5252
height: 600, // InkPaper height
5353
timeout: 25, // Recognition timeout
5454
textParameters: {
55-
language: 'en_US' // Set the recognition language (i.e.: 'en_US', 'fr_FR', ...)
55+
language: 'en_US', // Set the recognition language (i.e.: 'en_US', 'fr_FR', ...)
56+
resultDetail: 'CHARACTER',
57+
textProperties: {
58+
textCandidateListSize: 3
59+
}
5660
}
5761
};
5862
/**

dist/myscript.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,20 +4785,32 @@ MyScript = {
47854785
*/
47864786
function TextDocument(obj) {
47874787
this.tagItems = [];
4788-
this.wordCandidates = [];
4789-
this.charCandidates = [];
4788+
this.wordSegments = [];
4789+
this.charSegments = [];
47904790
if (obj) {
47914791
if (obj.textSegmentResult) {
47924792
this.textSegmentResult = new scope.TextSegment(obj.textSegmentResult);
47934793
}
47944794
for (var i in obj.tagItems) {
47954795
this.tagItems.push(new scope.TextTagItem(obj.tagItems[i]));
47964796
}
4797-
for (var j in obj.wordCandidates) {
4798-
this.wordCandidates.push(new scope.TextSegment(obj.wordCandidates[j]));
4797+
for (var j in obj.wordSegments) {
4798+
this.wordSegments.push(new scope.TextSegment(obj.wordSegments[j]));
47994799
}
4800-
for (var k in obj.charCandidates) {
4801-
this.charCandidates.push(new scope.TextSegment(obj.charCandidates[k]));
4800+
for (var k in obj.charSegments) {
4801+
this.charSegments.push(new scope.TextSegment(obj.charSegments[k]));
4802+
}
4803+
/**
4804+
* @deprecated
4805+
*/
4806+
for (var l in obj.wordCandidates) {
4807+
this.wordSegments.push(new scope.TextSegment(obj.wordCandidates[l]));
4808+
}
4809+
/**
4810+
* @deprecated
4811+
*/
4812+
for (var m in obj.charCandidates) {
4813+
this.charSegments.push(new scope.TextSegment(obj.charCandidates[m]));
48024814
}
48034815
}
48044816
}
@@ -4820,7 +4832,7 @@ MyScript = {
48204832
* @returns {TextSegment[]}
48214833
*/
48224834
TextDocument.prototype.getWordSegments = function () {
4823-
return this.wordCandidates;
4835+
return this.wordSegments;
48244836
};
48254837

48264838
/**
@@ -4846,7 +4858,7 @@ MyScript = {
48464858
* @returns {TextSegment[]}
48474859
*/
48484860
TextDocument.prototype.getCharSegments = function () {
4849-
return this.charCandidates;
4861+
return this.charSegments;
48504862
};
48514863

48524864
/**
@@ -4890,6 +4902,7 @@ MyScript = {
48904902
})(MyScript);
48914903

48924904

4905+
48934906
(function (scope) {
48944907
/**
48954908
* Text result

dist/myscript.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/output/text/textDocument.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@
1010
*/
1111
function TextDocument(obj) {
1212
this.tagItems = [];
13-
this.wordCandidates = [];
14-
this.charCandidates = [];
13+
this.wordSegments = [];
14+
this.charSegments = [];
1515
if (obj) {
1616
if (obj.textSegmentResult) {
1717
this.textSegmentResult = new scope.TextSegment(obj.textSegmentResult);
1818
}
1919
for (var i in obj.tagItems) {
2020
this.tagItems.push(new scope.TextTagItem(obj.tagItems[i]));
2121
}
22-
for (var j in obj.wordCandidates) {
23-
this.wordCandidates.push(new scope.TextSegment(obj.wordCandidates[j]));
22+
for (var j in obj.wordSegments) {
23+
this.wordSegments.push(new scope.TextSegment(obj.wordSegments[j]));
2424
}
25-
for (var k in obj.charCandidates) {
26-
this.charCandidates.push(new scope.TextSegment(obj.charCandidates[k]));
25+
for (var k in obj.charSegments) {
26+
this.charSegments.push(new scope.TextSegment(obj.charSegments[k]));
27+
}
28+
/**
29+
* @deprecated
30+
*/
31+
for (var l in obj.wordCandidates) {
32+
this.wordSegments.push(new scope.TextSegment(obj.wordCandidates[l]));
33+
}
34+
/**
35+
* @deprecated
36+
*/
37+
for (var m in obj.charCandidates) {
38+
this.charSegments.push(new scope.TextSegment(obj.charCandidates[m]));
2739
}
2840
}
2941
}
@@ -45,7 +57,7 @@
4557
* @returns {TextSegment[]}
4658
*/
4759
TextDocument.prototype.getWordSegments = function () {
48-
return this.wordCandidates;
60+
return this.wordSegments;
4961
};
5062

5163
/**
@@ -71,7 +83,7 @@
7183
* @returns {TextSegment[]}
7284
*/
7385
TextDocument.prototype.getCharSegments = function () {
74-
return this.charCandidates;
86+
return this.charSegments;
7587
};
7688

7789
/**
@@ -112,4 +124,4 @@
112124

113125
// Export
114126
scope.TextDocument = TextDocument;
115-
})(MyScript);
127+
})(MyScript);

0 commit comments

Comments
 (0)