Grammalecte  Check-in [ca296fe5b5]

Overview
Comment:[fr] lexicographe: clarification de code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fr | Lexicographe
Files: files | file ages | folders
SHA3-256: ca296fe5b56c984f4ecbbbe30a74f3838b46906541584ebe5f5e657b8f455efe
User & Date: olr on 2017-10-30 11:27:57
Other Links: branch diff | manifest | tags
Context
2017-10-30
12:00
[fr] lexicographe: clarification de code check-in: 83fbc36b7a user: olr tags: fr, Lexicographe
11:27
[fr] lexicographe: clarification de code check-in: ca296fe5b5 user: olr tags: fr, Lexicographe
10:44
[fr] lexicographe: clarification de code check-in: 99637f2794 user: olr tags: fr, Lexicographe
Changes

Modified gc_lang/fr/modules-js/lexicographe.js from [eef0487ce0] to [d4be1a8610].

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
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
421
422
423
424
425
426
427
428
        let nPos = s.indexOf("-");
        return _dAD.get(s.slice(0, nPos)) + " +" + _dAD.get(s.slice(nPos + 1));
    }

    getListOfTokens (sText, bInfo = true) {
        let aElem = [];
        if (sText !== "") {
            let aRes = null;
            for (let oToken of this.oTokenizer.genTokens(sText)) {
                if (bInfo) {
                    aRes = this.getInfoForToken(oToken);
                    if (aRes) {
                        aElem.push(aRes);
                    }
                } else if (oToken.sType !== "SPACE") {
                    aElem.push(oToken);
                }
            }
        }
        return aElem;
    }

    _unifyStr (sWord){
        return sWord.replace('’', 'e').toLowerCase();
    }

    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,
                    '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 {
                    aElem.push(oTokenLocution);
                }
            } else {
                if (bInfo) {
                    aRes = this.getInfoForToken(oToken);
                    if (aRes) {
                        aElem.push(aRes);
                    }
                } else {
                    aElem.push(oToken);
                }
            }







<


|



















<

|
<



|
<

>
|




|

|


|
|

|















|
|
|
|
















|







332
333
334
335
336
337
338

339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
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
421
422
423
424
425
        let nPos = s.indexOf("-");
        return _dAD.get(s.slice(0, nPos)) + " +" + _dAD.get(s.slice(nPos + 1));
    }

    getListOfTokens (sText, bInfo = true) {
        let aElem = [];
        if (sText !== "") {

            for (let oToken of this.oTokenizer.genTokens(sText)) {
                if (bInfo) {
                    let aRes = this.getInfoForToken(oToken);
                    if (aRes) {
                        aElem.push(aRes);
                    }
                } else if (oToken.sType !== "SPACE") {
                    aElem.push(oToken);
                }
            }
        }
        return aElem;
    }

    _unifyStr (sWord){
        return sWord.replace('’', 'e').toLowerCase();
    }

    getListOfTokensReduc (sText, bInfo = true) {
        let aTokenList = this.getListOfTokens(sText.replace("'", "’").trim(), false);
        let iKey = 0;
        let aElem = [];

        do {
            let oToken = aTokenList[iKey];

            let bLocFound = false;
            let iKeyTree = iKey + 1;
            let sTokenTmpKey = '';
            let aTokenTempList = [oToken];

            if (oToken.sType == "WORD" || oToken.sType == "ELPFX"){
                let oLocNode = this.oLocGraph[this._unifyStr(oToken.sValue)];
                while (typeof(oLocNode) !== "undefined") {
                    let oTokenNext = aTokenList[iKeyTree];
                    iKeyTree++;

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

                    if (typeof(oLocNode) !== "undefined" && iKeyTree <= aTokenList.length) {
                        sTokenTmpKey = Object.keys(oLocNode)[0];
                        aTokenTempList.push(oTokenNext);
                    } else {
                        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,
                    '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 {
                    aElem.push(oTokenLocution);
                }
            } else {
                if (bInfo) {
                    let aRes = this.getInfoForToken(oToken);
                    if (aRes) {
                        aElem.push(aRes);
                    }
                } else {
                    aElem.push(oToken);
                }
            }