Grammalecte  Check-in [6c3d434a28]

Overview
Comment:[core][fr] analyses: update functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fr | core | rg
Files: files | file ages | folders
SHA3-256: 6c3d434a285235524240294faf8b2239b85592c513f8154102fcdb7f383b41ba
User & Date: olr on 2018-09-11 13:17:59
Other Links: branch diff | manifest | tags
Context
2018-09-11
18:38
[core][js] gc engine: fix several bugs check-in: e47d159953 user: olr tags: core, rg
13:17
[core][fr] analyses: update functions check-in: 6c3d434a28 user: olr tags: core, fr, rg
12:59
[core][fr][js] missing function, and useless code check-in: bc565ecc30 user: olr tags: core, fr, rg
Changes

Modified gc_lang/fr/modules-js/gce_suggestions.js from [6803550153] to [dfa4abac25].

     7      7       var mfsp = require("resource://grammalecte/fr/mfsp.js");
     8      8       var phonet = require("resource://grammalecte/fr/phonet.js");
     9      9   }
    10     10   
    11     11   
    12     12   //// verbs
    13     13   
    14         -function suggVerb (sFlex, sWho, funcSugg2=null) {
           14  +function splitVerb (sVerb) {
           15  +    // renvoie le verbe et les pronoms séparément
           16  +    let iRight = sVerb.lastIndexOf("-");
           17  +    let sSuffix = sVerb.slice(iRight);
           18  +    sVerb = sVerb.slice(0, iRight);
           19  +    if (sVerb.endsWith("-t") || sVerb.endsWith("-le") || sVerb.endsWith("-la") || sVerb.endsWith("-les")) {
           20  +        iRight = sVerb.lastIndexOf("-");
           21  +        sSuffix = sVerb.slice(iRight) + sSuffix;
           22  +        sVerb = sVerb.slice(0, iRight);
           23  +    }
           24  +    return [sVerb, sSuffix];
           25  +}
           26  +
           27  +function suggVerb (sFlex, sWho, funcSugg2=null, bVC=false) {
           28  +    let sSfx;
           29  +    if (bVC) {
           30  +        [sFlex, sSfx] = splitVerb(sFlex);
           31  +    }
    15     32       let aSugg = new Set();
    16     33       for (let sStem of _oSpellChecker.getLemma(sFlex)) {
    17     34           let tTags = conj._getTags(sStem);
    18     35           if (tTags) {
    19     36               // we get the tense
    20     37               let aTense = new Set();
    21     38               for (let sMorph of _oSpellChecker.getMorph(sFlex)) {
................................................................................
    49     66       if (funcSugg2) {
    50     67           let aSugg2 = funcSugg2(sFlex);
    51     68           if (aSugg2.size > 0) {
    52     69               aSugg.add(aSugg2);
    53     70           }
    54     71       }
    55     72       if (aSugg.size > 0) {
           73  +        if (bVC) {
           74  +            return Array.from(aSugg).map((sSugg) => { return sSugg + sSfx; }).join("|");
           75  +        }
    56     76           return Array.from(aSugg).join("|");
    57     77       }
    58     78       return "";
    59     79   }
    60     80   
    61     81   function suggVerbPpas (sFlex, sWhat=null) {
    62     82       let aSugg = new Set();
................................................................................
   117    137       }
   118    138       if (aSugg.size > 0) {
   119    139           return Array.from(aSugg).join("|");
   120    140       }
   121    141       return "";
   122    142   }
   123    143   
   124         -function suggVerbImpe (sFlex) {
          144  +function suggVerbImpe (sFlex, bVC=false) {
          145  +    let sSfx;
          146  +    if (bVC) {
          147  +        [sFlex, sSfx] = splitVerb(sFlex);
          148  +    }
   125    149       let aSugg = new Set();
   126    150       for (let sStem of _oSpellChecker.getLemma(sFlex)) {
   127    151           let tTags = conj._getTags(sStem);
   128    152           if (tTags) {
   129    153               if (conj._hasConjWithTags(tTags, ":E", ":2s")) {
   130    154                   aSugg.add(conj._getConjWithTags(sStem, tTags, ":E", ":2s"));
   131    155               }
................................................................................
   134    158               }
   135    159               if (conj._hasConjWithTags(tTags, ":E", ":2p")) {
   136    160                   aSugg.add(conj._getConjWithTags(sStem, tTags, ":E", ":2p"));
   137    161               }
   138    162           }
   139    163       }
   140    164       if (aSugg.size > 0) {
          165  +        if (bVC) {
          166  +            return Array.from(aSugg).map((sSugg) => { return sSugg + sSfx; }).join("|");
          167  +        }
   141    168           return Array.from(aSugg).join("|");
   142    169       }
   143    170       return "";
   144    171   }
   145    172   
   146    173   function suggVerbInfi (sFlex) {
   147    174       return _oSpellChecker.getLemma(sFlex).filter(sStem => conj.isVerb(sStem)).join("|");
................................................................................
   464    491           return Array.from(aSugg).join("|");
   465    492       }
   466    493       return "";
   467    494   }
   468    495   
   469    496   function switchPlural (sFlex) {
   470    497       let aSugg = new Set();
   471         -    for (let sMorph of _oSpellChecker.getMorph(sFlex)) { 
          498  +    for (let sMorph of _oSpellChecker.getMorph(sFlex)) {
   472    499           if (sMorph.includes(":s")) {
   473    500               aSugg.add(suggPlur(sFlex));
   474    501           } else if (sMorph.includes(":p")) {
   475    502               aSugg.add(suggSing(sFlex));
   476    503           }
   477    504       }
   478    505       if (aSugg.size > 0) {
................................................................................
   481    508       return "";
   482    509   }
   483    510   
   484    511   function hasSimil (sWord, sPattern=null) {
   485    512       return phonet.hasSimil(sWord, sPattern);
   486    513   }
   487    514   
   488         -function suggSimil (sWord, sPattern=null, bSubst=false) {
          515  +function suggSimil (sWord, sPattern=null, bSubst=false, bVC=false) {
   489    516       // return list of words phonetically similar to sWord and whom POS is matching sPattern
          517  +    let sSfx;
          518  +    if (bVC) {
          519  +        [sWord, sSfx] = splitVerb(sWord);
          520  +    }
   490    521       let aSugg = phonet.selectSimil(sWord, sPattern);
   491    522       for (let sMorph of _oSpellChecker.getMorph(sWord)) {
   492    523           for (let e of conj.getSimil(sWord, sMorph, bSubst)) {
   493    524               aSugg.add(e);
   494    525           }
   495    526       }
   496    527       if (aSugg.size > 0) {
          528  +        if (bVC) {
          529  +            return Array.from(aSugg).map((sSugg) => { return sSugg + sSfx; }).join("|");
          530  +        }
   497    531           return Array.from(aSugg).join("|");
   498    532       }
   499    533       return "";
   500    534   }
   501    535   
   502    536   function suggCeOrCet (sWord) {
   503    537       if (/^[aeéèêiouyâîï]/i.test(sWord)) {