Grammalecte  Check-in [768b26a5ce]

Overview
Comment:Simplification du code et renommage :s
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | Lexicographe
Files: files | file ages | folders
SHA3-256: 768b26a5cee8a26801ca0a41b3faaa3cd3e79d4ecab8bcc8a45e5ccd3ee58f2d
User & Date: IllusionPerdu on 2017-10-30 09:51:54
Original Comment: Simplification du code et fix du au renomage :s
Other Links: branch diff | manifest | tags
Context
2017-10-30
10:44
[fr] lexicographe: clarification de code check-in: 99637f2794 user: olr tags: Lexicographe, fr
09:51
Simplification du code et renommage :s check-in: 768b26a5ce user: IllusionPerdu tags: Lexicographe
09:27
[fr] lexicographe: remplacement de l’apostrophe seulement pour l’analyse de la suite des tokens check-in: 4fe9cf871e user: olr tags: Lexicographe, fr
Changes

Modified gc_lang/fr/modules-js/lexicographe.js from [0e3b56e9e5] to [6057617be0].

104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
...
355
356
357
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
    [';S', " : symbole (unité de mesure)"],

    ['/*', ""],
    ['/C', " {classique}"],
    ['/M', ""],
    ['/R', " {réforme}"],
    ['/A', ""],
    ['/X', ""]

]);

const _dPFX = new Map([
    ['d', "(de), déterminant épicène invariable"],
    ['l', "(le/la), déterminant masculin/féminin singulier"],
    ['j', "(je), pronom personnel sujet, 1ʳᵉ pers., épicène singulier"],
    ['m', "(me), pronom personnel objet, 1ʳᵉ pers., épicène singulier"],
................................................................................
    }

    getListOfTokensReduc (sText, bInfo = true) {
        let aTokenList = this.getListOfTokens(sText.replace("'", "’").trim(), false);
        let iKey = 0;
        let aElem = [];
        let aRes = null;
        let isType = {'WORD':1,'ELPFX':1};
        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);

            while (!bStop && typeof aLocution !== "undefined") {
                if (iKeyTree > aTokenList.length){
                    break;
                }
                let sTokenNextType = '';
                let oTokenNext = aTokenList[iKeyTree];


                if ( typeof oTokenNext !== "undefined" ) {
                    aLocution = aLocution[this._unifyStr(oTokenNext.sValue)];
                    sTokenNextType = oTokenNext.sType;
                } else {
                    aLocution = "undefined";
                }

                if ( sTokenNextType in isType && typeof aLocution !== "undefined") {
                    sTokenTmpKey = Object.keys(aLocution)[0];
                    iKeyTree++;
                    aTokenTempList.push(oTokenNext);
                } else if ( !(sTokenNextType in isType) || typeof aLocution == "undefined") {
                    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,
                    'niKeyTree':aTokenTempList[0].niKeyTree,
                    'sType':"LOC",
                    'sValue':sWord.replace('’ ','’').trim()
                };
                if (bInfo) {
                    let aFormatedTag = [];
                    for (let sTagMulti of sTokenTmpKey.split('|') ){
                        aFormatedTag.push( this._formatTags(sTagMulti).replace(/(\(él.\))/g,'').trim() );
                    }
                    aElem.push({
                        sType: oTokenLocution.sType,
                        sValue: oTokenLocution.sValue,
                        aLabel: aFormatedTag
                    });
                } else {







|
>







 







<









>
|
<
<
<
<
|
>

|
|
<
|
|
|

|
|
<
|
|
|
|
|
|
|
|
>









|






|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
356
357
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
    [';S', " : symbole (unité de mesure)"],

    ['/*', ""],
    ['/C', " {classique}"],
    ['/M', ""],
    ['/R', " {réforme}"],
    ['/A', ""],
    ['/X', ""],
    ['/L', " {latin}"]
]);

const _dPFX = new Map([
    ['d', "(de), déterminant épicène invariable"],
    ['l', "(le/la), déterminant masculin/féminin singulier"],
    ['j', "(je), pronom personnel sujet, 1ʳᵉ pers., épicène singulier"],
    ['m', "(me), pronom personnel objet, 1ʳᵉ pers., épicène singulier"],
................................................................................
    }

    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,
                    'nStart':aTokenTempList[0].nStart,
                    'sType':"LOC",
                    'sValue':sWord.replace('’ ','’').trim()
                };
                if (bInfo) {
                    let aFormatedTag = [];
                    for (let sTagMulti of sTokenTmpKey.split('|') ){
                        aFormatedTag.push( this._formatTags(sTagMulti).replace(/( \(él.\))/g,'') );
                    }
                    aElem.push({
                        sType: oTokenLocution.sType,
                        sValue: oTokenLocution.sValue,
                        aLabel: aFormatedTag
                    });
                } else {