130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
// Lexicographer
loadLexicographer (sLangCode) {
// load default suggestion module for <sLangCode>
if (typeof(process) !== 'undefined') {
this.lexicographer = require(`./lexgraph_${sLangCode}.js`);
}
else if (typeof(require) !== 'undefined') {
this.lexicographer = require(`resource://grammalecte/graphspell/lexgraph_${sLangCode}.js`);
}
}
// Storage
activateStorage () {
this.bStorage = true;
}
|
>
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
// Lexicographer
loadLexicographer (sLangCode) {
// load default suggestion module for <sLangCode>
if (typeof(process) !== 'undefined') {
this.lexicographer = require(`./lexgraph_${sLangCode}.js`);
}
else if (self && self.hasOwnProperty("lexgraph_"+sLangCode)) { // self is the Worker
this.lexicographer = self["lexgraph_"+sLangCode];
}
}
analyze (sWord) {
// returns a list of words and their morphologies
if (!this.lexicographer) {
return [];
}
let lWordAndMorph = [];
for (let sElem of this.lexicographer.split(sWord)) {
if (sElem) {
let lMorph = this.getMorph(sElem);
let sLex = this.lexicographer.analyze(sElem)
let aRes = [];
if (sLex) {
aRes = [ [lMorph.join(" | "), sLex] ];
} else {
for (let sMorph of lMorph) {
aRes.push([sMorph, this.lexicographer.formatTags(sMorph)]);
}
}
if (aRes.length > 0) {
lWordAndMorph.push([sElem, aRes]);
}
}
}
return lWordAndMorph;
}
readableMorph (sMorph) {
if (!this.lexicographer) {
return [];
}
return this.lexicographer.formatTags(sMorph);
}
// Storage
activateStorage () {
this.bStorage = true;
}
|