195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
class Lexicographe {
constructor (oDict) {
this.oDict = oDict;
this._zElidedPrefix = new RegExp ("^([dljmtsncç]|quoiqu|lorsqu|jusqu|puisqu|qu)['’](.+)", "i");
this._zCompoundWord = new RegExp ("([a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ]+)-((?:les?|la)-(?:moi|toi|lui|[nv]ous|leur)|t-(?:il|elle|on)|y|en|[mts][’'](?:y|en)|les?|l[aà]|[mt]oi|leur|lui|je|tu|ils?|elles?|on|[nv]ous)$", "i");
this._zTag = new RegExp ("[:;/][a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ*][^:;/]*", "g");
};
getInfoForToken (oToken) {
// Token: .sType, .sValue, .nStart, .nEnd
// return a list [type, token_string, values]
let m = null;
try {
switch (oToken.sType) {
|
<
>
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
class Lexicographe {
constructor (oDict) {
this.oDict = oDict;
this._zElidedPrefix = new RegExp ("^([dljmtsncç]|quoiqu|lorsqu|jusqu|puisqu|qu)['’](.+)", "i");
this._zCompoundWord = new RegExp ("([a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ]+)-((?:les?|la)-(?:moi|toi|lui|[nv]ous|leur)|t-(?:il|elle|on)|y|en|[mts][’'](?:y|en)|les?|l[aà]|[mt]oi|leur|lui|je|tu|ils?|elles?|on|[nv]ous)$", "i");
this._zTag = new RegExp ("[:;/][a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ*][^:;/]*", "g");
}
getInfoForToken (oToken) {
// Token: .sType, .sValue, .nStart, .nEnd
// return a list [type, token_string, values]
let m = null;
try {
switch (oToken.sType) {
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
break;
}
}
catch (e) {
helpers.logerror(e);
}
return null;
};
_formatTags (sTags) {
let sRes = "";
sTags = sTags.replace(/V([0-3][ea]?)[itpqnmr_eaxz]+/, "V$1");
let m;
while ((m = this._zTag.exec(sTags)) !== null) {
sRes += _dTAGS.get(m[0]);
if (sRes.length > 100) {
break;
}
}
if (sRes.startsWith(" verbe") && !sRes.endsWith("infinitif")) {
sRes += " [" + sTags.slice(1, sTags.indexOf(" ")) + "]";
}
if (!sRes) {
sRes = "#Erreur. Étiquette inconnue : [" + sTags + "]";
helpers.echo(sRes);
return sRes;
}
return sRes.gl_trimRight(",");
};
_formatSuffix (s) {
if (s.startsWith("t-")) {
return "“t” euphonique +" + _dAD.get(s.slice(2));
}
if (!s.includes("-")) {
return _dAD.get(s.replace("’", "'"));
}
if (s.endsWith("ous")) {
s += '2';
}
let nPos = s.indexOf("-");
return _dAD.get(s.slice(0, nPos)) + " +" + _dAD.get(s.slice(nPos+1));
};
}
if (typeof(exports) !== 'undefined') {
exports.Lexicographe = Lexicographe;
}
|
<
>
<
>
<
>
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
break;
}
}
catch (e) {
helpers.logerror(e);
}
return null;
}
_formatTags (sTags) {
let sRes = "";
sTags = sTags.replace(/V([0-3][ea]?)[itpqnmr_eaxz]+/, "V$1");
let m;
while ((m = this._zTag.exec(sTags)) !== null) {
sRes += _dTAGS.get(m[0]);
if (sRes.length > 100) {
break;
}
}
if (sRes.startsWith(" verbe") && !sRes.endsWith("infinitif")) {
sRes += " [" + sTags.slice(1, sTags.indexOf(" ")) + "]";
}
if (!sRes) {
sRes = "#Erreur. Étiquette inconnue : [" + sTags + "]";
helpers.echo(sRes);
return sRes;
}
return sRes.gl_trimRight(",");
}
_formatSuffix (s) {
if (s.startsWith("t-")) {
return "“t” euphonique +" + _dAD.get(s.slice(2));
}
if (!s.includes("-")) {
return _dAD.get(s.replace("’", "'"));
}
if (s.endsWith("ous")) {
s += '2';
}
let nPos = s.indexOf("-");
return _dAD.get(s.slice(0, nPos)) + " +" + _dAD.get(s.slice(nPos+1));
}
}
if (typeof(exports) !== 'undefined') {
exports.Lexicographe = Lexicographe;
}
|