Grammalecte  Check-in [85d2c18b0e]

Overview
Comment:Renommage des variables pour se conformer au reste du code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | Lexicographe
Files: files | file ages | folders
SHA3-256: 85d2c18b0ed858ae8ce8887bfd4c4dfe347232ef1450dffdaf14faa957849a29
User & Date: IllusionPerdu on 2017-10-29 23:33:31
Other Links: branch diff | manifest | tags
Context
2017-10-30
09:21
[fr] lexicographe: commentaire erroné check-in: b9365d6a6c user: olr tags: fr, Lexicographe
2017-10-29
23:33
Renommage des variables pour se conformer au reste du code check-in: 85d2c18b0e user: IllusionPerdu tags: Lexicographe
22:57
Ajout forme :Ô locution pronominales check-in: 937fa6cf25 user: IllusionPerdu tags: Lexicographe
Changes

Modified gc_lang/fr/modules-js/lexicographe.js from [a897840ed1] to [1cdb365c76].

205
206
207
208
209
210
211
212

213
214
215
216
217
218
219
205
206
207
208
209
210
211

212
213
214
215
216
217
218
219







-
+








        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) {
    getInfoForToken (oToken) {
        // Token: .sType, .sValue, .nStart, .nEnd
        // return a list [type, token_string, values]
        let m = null;
        try {
            switch (oToken.sType) {
                case 'SEPARATOR':
                    return {
293
294
295
296
297
298
299
300

301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
329
330
331
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
429

430
431
432
433
434
435
436
437
438
439
440
441
442


443
444
445
446
447
448
449
450
293
294
295
296
297
298
299

300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320

321
322
323
324
325
326
327
328
329
330
331
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
429
430
431
432
433


434
435
436
437
438
439
440
441
442
443







-
+




















-
+













-
+


















-
-
+
+


-
-
+
+
-
-
-
-
+




-
-
+
+
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+


-
-
+
+
-

-
-
-
+
+
+




-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+




-
-
-
-
+
+
+
+
-

-
-
-
-
+
+
+
+

-
+


-
-
-
+
+
+


-
-
-
+
+
+


-
+











-
-
+
+








            }
        } catch (e) {
            helpers.logerror(e);
        }
        return null;
    }

    _formatTags(sTags) {
    _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) {
    _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));
    }

    getListOfTokens(sText, bInfo = true) {
    getListOfTokens (sText, bInfo = true) {
        let aElem = [];
        sText = sText.replace("'", "’").trim();
        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;
    }

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

    getListOfTokensReduc(sText, bInfo = true) {
        let lstToken = this.getListOfTokens(sText, false);
    getListOfTokensReduc (sText, bInfo = true) {
        let aTokenList = this.getListOfTokens(sText, false);
        //console.log(lstToken);
        //console.log(this.oLocution);

        let id = 0;
        let iKey = 0;
        let aElem = [];
        let aRes = null;
        let isType = {'WORD':1,'ELPFX':1};
        do {
            let oToken = lstToken[id]
            let aLocution = this.oLocution[this.elpfxToword(oToken.sValue)];
            let oToken = aTokenList[iKey]
            let aLocution = this.oLocution[this._unifyStr(oToken.sValue)];
            //console.log('Start cherche', oToken.sValue, aLocution);
            let stop = false;
            let bStop = false;
            let start = id + 1;
            let lastTokenWord = '';
            let ok = false;
            let oLst = [];
            oLst.push(oToken);
            while (!stop && typeof aLocution !== "undefined") {
                if (start > lstToken.length){
            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 typeToken = '';
                let nextToken = lstToken[start];
                let sTokenNextType = '';
                let oTokenNext = aTokenList[iKeyTree];
                //console.log(start, nextToken, aLocution);

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

                if ( typeToken in isType && typeof aLocution !== "undefined") {
                    lastTokenWord = Object.keys(aLocution)[0];
                    start++;
                    oLst.push(nextToken);
                if ( sTokenNextType in isType && typeof aLocution !== "undefined") {
                    sTokenTmpKey = Object.keys(aLocution)[0];
                    iKeyTree++;
                    aTokenTempList.push(oTokenNext);
                    //console.log( nextToken.sValue );
                } else if ( !(typeToken in isType) || typeof aLocution == "undefined") {
                    stop = true;
                    if ( lastTokenWord.substring(0, 1) == ':' ) {
                        ok = true;
                } else if ( !(sTokenNextType in isType) || typeof aLocution == "undefined") {
                    bStop = true;
                    if ( sTokenTmpKey.substring(0, 1) == ':' ) {
                        bOk = true;
                    }
                }
            };

            if ( ok ){
                let word = '';
                for (let oToken of oLst) {
                    word += oToken.sValue+' ';
            if ( bOk ){
                let sWord = '';
                for (let oTokenWord of aTokenTempList) {
                    sWord += oTokenWord.sValue+' ';
                    //console.log('***',word);
                }
                id = id + oLst.length-1;
                let tmpToken = {
                    'nEnd':oLst[oLst.length-1].nEnd,
                    'nStart':oLst[0].nStart,
                iKey = iKey + aTokenTempList.length-1;
                let oTokenLocution = {
                    'nEnd':aTokenTempList[aTokenTempList.length-1].nEnd,
                    'niKeyTree':aTokenTempList[0].niKeyTree,
                    'sType':"LOC",
                    'sValue':word.replace('’ ','’').trim()
                    'sValue':sWord.replace('’ ','’').trim()
                };
                if (bInfo) {
                    let formatedTag = [];
                    for (let oToFormat of lastTokenWord.split('|') ){
                        formatedTag.push( this._formatTags(oToFormat).replace(/(\(él.\))/g,'').trim() );
                    let aFormatedTag = [];
                    for (let sTagMulti of sTokenTmpKey.split('|') ){
                        aFormatedTag.push( this._formatTags(sTagMulti).replace(/(\(él.\))/g,'').trim() );
                    }
                    aElem.push({
                        sType: tmpToken.sType,
                        sValue: tmpToken.sValue,
                        aLabel: formatedTag
                        sType: oTokenLocution.sType,
                        sValue: oTokenLocution.sValue,
                        aLabel: aFormatedTag
                    });
                } else {
                    aElem.push(tmpToken);
                    aElem.push(oTokenLocution);
                }
            } else {
                if (bInfo) {
                    aRes = this.getInfoForToken(oToken);
                    if (aRes) {
                        aElem.push(aRes);
                    }
                } else {
                    aElem.push(oToken);
                }
            }
            id++;
        } while (id < lstToken.length);
            iKey++;
        } while (iKey < aTokenList.length);
        return aElem;
    }
}


if (typeof (exports) !== 'undefined') {
    exports.Lexicographe = Lexicographe;
}