195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
['<', "inférieur à"],
['>', "supérieur à"],
]);
class Lexicographe {
constructor(oDict, oTokenizer, oLocution) {
this.oDict = oDict;
this.oTokenizer = oTokenizer;
this.oLocution = JSON.parse(oLocution);
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");
}
|
|
|
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
['<', "inférieur à"],
['>', "supérieur à"],
]);
class Lexicographe {
constructor (oDict, oTokenizer, oLocGraph) {
this.oDict = oDict;
this.oTokenizer = oTokenizer;
this.oLocGraph = JSON.parse(oLocGraph);
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");
}
|
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
getListOfTokensReduc (sText, bInfo = true) {
let aTokenList = this.getListOfTokens(sText.replace("'", "’").trim(), false);
let iKey = 0;
let aElem = [];
let aRes = null;
do {
let oToken = aTokenList[iKey]
let aLocution = this.oLocution[this._unifyStr(oToken.sValue)];
let bStop = false;
let bOk = false;
let iKeyTree = iKey + 1;
let sTokenTmpKey = '';
let aTokenTempList = [];
aTokenTempList.push(oToken);
if ( oToken.sType == "WORD" || oToken.sType == "ELPFX" ){
while (!bStop && typeof aLocution !== "undefined") {
let oTokenNext = aTokenList[iKeyTree];
iKeyTree++;
if ( typeof oTokenNext !== "undefined" ) {
aLocution = aLocution[this._unifyStr(oTokenNext.sValue)];
} else {
aLocution = "undefined";
}
if ( typeof aLocution !== "undefined" && iKeyTree <= aTokenList.length) {
sTokenTmpKey = Object.keys(aLocution)[0];
aTokenTempList.push(oTokenNext);
} else if ( typeof aLocution == "undefined" || iKeyTree > aTokenList.length) {
bStop = true;
if ( sTokenTmpKey.substring(0, 1) == ':' ) {
bOk = true;
}
}
};
}
if ( bOk ){
let sWord = '';
for (let oTokenWord of aTokenTempList) {
sWord += oTokenWord.sValue+' ';
}
iKey = iKey + aTokenTempList.length-1;
let oTokenLocution = {
'nEnd':aTokenTempList[aTokenTempList.length-1].nEnd,
|
|
<
|
|
|
|
|
|
<
|
|
>
|
|
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
getListOfTokensReduc (sText, bInfo = true) {
let aTokenList = this.getListOfTokens(sText.replace("'", "’").trim(), false);
let iKey = 0;
let aElem = [];
let aRes = null;
do {
let oToken = aTokenList[iKey]
let aLocution = this.oLocGraph[this._unifyStr(oToken.sValue)];
let bLocFound = false;
let iKeyTree = iKey + 1;
let sTokenTmpKey = '';
let aTokenTempList = [];
aTokenTempList.push(oToken);
if (oToken.sType == "WORD" || oToken.sType == "ELPFX"){
while (typeof(aLocution) !== "undefined") {
let oTokenNext = aTokenList[iKeyTree];
iKeyTree++;
if (typeof(oTokenNext) !== "undefined") {
aLocution = aLocution[this._unifyStr(oTokenNext.sValue)];
} else {
aLocution = "undefined";
}
if (typeof(aLocution) !== "undefined" && iKeyTree <= aTokenList.length) {
sTokenTmpKey = Object.keys(aLocution)[0];
aTokenTempList.push(oTokenNext);
} else if (typeof(aLocution) == "undefined" || iKeyTree > aTokenList.length) {
if (sTokenTmpKey.substring(0, 1) == ':') {
bLocFound = true;
}
break;
}
};
}
if (bLocFound) {
let sWord = '';
for (let oTokenWord of aTokenTempList) {
sWord += oTokenWord.sValue+' ';
}
iKey = iKey + aTokenTempList.length-1;
let oTokenLocution = {
'nEnd':aTokenTempList[aTokenTempList.length-1].nEnd,
|
430
431
432
433
434
435
436
437
438
439
|
iKey++;
} while (iKey < aTokenList.length);
return aElem;
}
}
if (typeof (exports) !== 'undefined') {
exports.Lexicographe = Lexicographe;
}
|
|
|
429
430
431
432
433
434
435
436
437
438
|
iKey++;
} while (iKey < aTokenList.length);
return aElem;
}
}
if (typeof(exports) !== 'undefined') {
exports.Lexicographe = Lexicographe;
}
|