Index: compile_rules.py ================================================================== --- compile_rules.py +++ compile_rules.py @@ -64,11 +64,11 @@ s = re.sub(r"\brealstart0\(\)", 'before0("^ *$")', s) s = re.sub(r"\bend\(\)", 'after("^ *$|^,")', s) s = re.sub(r"\brealend\(\)", 'after("^ *$")', s) s = re.sub(r"\bend0\(\)", 'after0("^ *$|^,")', s) s = re.sub(r"\brealend0\(\)", 'after0("^ *$")', s) - s = re.sub(r"\b(select|exclude)[(][\\](\d+)", '\\1(dTokenPos, m.start(\\2), m.group(\\2)', s) + s = re.sub(r"\bselect[(][\\](\d+)", '\\1(dTokenPos, m.start(\\2), m.group(\\2)', s) s = re.sub(r"\bdefine[(][\\](\d+)", 'define(dTokenPos, m.start(\\1)', s) s = re.sub(r"\b(morph|info)[(][\\](\d+)", '\\1((m.start(\\2), m.group(\\2))', s) s = re.sub(r"\b(morph|info)[(]", '\\1(dTokenPos, ', s) s = re.sub(r"\b(sugg\w+|switch\w+)\(@", '\\1(m.group(i[4])', s) s = re.sub(r"\bword\(\s*1\b", 'nextword1(sSentence, m.end()', s) # word(1) Index: compile_rules_graph.py ================================================================== --- compile_rules_graph.py +++ compile_rules_graph.py @@ -38,12 +38,12 @@ sCode = sCode.replace("__also__", "bCondMemo") sCode = sCode.replace("__else__", "not bCondMemo") sCode = sCode.replace("sContext", "_sAppContext") sCode = re.sub(r"\b(morph0?|morphVC|value|tag|meta|info)[(]\\(\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode) sCode = re.sub(r"\b(morph0?|morphVC|value|tag|meta|info)[(]\\-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode) - sCode = re.sub(r"\b(select|exclude|define|definefrom|rewrite|addmorph|setmeta)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode) - sCode = re.sub(r"\b(select|exclude|define|definefrom|rewrite|addmorph|setmeta)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode) + sCode = re.sub(r"\b(select|define|definefrom|rewrite|addmorph|setmeta)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode) + sCode = re.sub(r"\b(select|define|definefrom|rewrite|addmorph|setmeta)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode) sCode = re.sub(r"\b(tagbefore|tagafter)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2], dTags', sCode) sCode = re.sub(r"\b(tagbefore|tagafter)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1], dTags', sCode) sCode = re.sub(r"\bspace[(][\\](\d+)", 'g_space(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode) sCode = re.sub(r"\bspace[(][\\]-(\d+)", 'g_space(lToken[nLastToken-\\1+1], lToken[nLastToken-\\1+2]', sCode) sCode = re.sub(r"\bmorph2[(][\\](\d+)", 'g_morph2(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode) Index: gc_core/js/lang_core/gc_functions.js ================================================================== --- gc_core/js/lang_core/gc_functions.js +++ gc_core/js/lang_core/gc_functions.js @@ -349,11 +349,11 @@ } //////// Disambiguator for regex rules -function select (dTokenPos, nPos, sWord, sPattern) { +function select (dTokenPos, nPos, sWord, sPattern, sNegPattern="") { if (!sWord) { return true; } if (!dTokenPos.has(nPos)) { console.log("Error. There should be a token at this position: ", nPos); @@ -361,30 +361,26 @@ } let lMorph = gc_engine.oSpellChecker.getMorph(sWord); if (lMorph.length === 0 || lMorph.length === 1) { return true; } - let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 ); - if (lSelect.length > 0 && lSelect.length != lMorph.length) { - dTokenPos.get(nPos)["lMorph"] = lSelect; - } - return true; -} - -function exclude (dTokenPos, nPos, sWord, sPattern) { - if (!sWord) { - return true; - } - if (!dTokenPos.has(nPos)) { - console.log("Error. There should be a token at this position: ", nPos); - return true; - } - let lMorph = gc_engine.oSpellChecker.getMorph(sWord); - if (lMorph.length === 0 || lMorph.length === 1) { - return true; - } - let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) === -1 ); + let lSelect; + if (sPattern) { + if (sNegPattern) { + lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 && sMorph.search(sNegPattern) === -1 ); + } + else { + lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 ); + } + } + else if (sNegPattern) { + lSelect = lMorph.filter( sMorph => sMorph.search(sNegPattern) === -1 ); + } + else { + console.log("[Grammalecte] Error: missing pattern for disambiguation selection..."); + return true; + } if (lSelect.length > 0 && lSelect.length != lMorph.length) { dTokenPos.get(nPos)["lMorph"] = lSelect; } return true; } @@ -395,30 +391,32 @@ } //// Disambiguation for graph rules -function g_select (oToken, sPattern) { +function g_select (oToken, sPattern, sNegPattern="") { // select morphologies for according to , always return true let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]); if (lMorph.length === 0 || lMorph.length === 1) { return true; } - let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 ); - if (lSelect.length > 0 && lSelect.length != lMorph.length) { - oToken["lMorph"] = lSelect; - } - return true; -} - -function g_exclude (oToken, sPattern) { - // select morphologies for according to , always return true - let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]); - if (lMorph.length === 0 || lMorph.length === 1) { + let lSelect; + if (sPattern) { + if (sNegPattern) { + lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 && sMorph.search(sNegPattern) === -1 ); + } + else { + lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 ); + } + } + else if (sNegPattern) { + lSelect = lMorph.filter( sMorph => sMorph.search(sNegPattern) === -1 ); + } + else { + console.log("[Grammalecte] Error: missing pattern for disambiguation selection..."); return true; } - let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) === -1 ); if (lSelect.length > 0 && lSelect.length != lMorph.length) { oToken["lMorph"] = lSelect; } return true; } Index: gc_core/py/lang_core/gc_functions.py ================================================================== --- gc_core/py/lang_core/gc_functions.py +++ gc_core/py/lang_core/gc_functions.py @@ -296,37 +296,30 @@ #### Disambiguator for regex rules -def select (dTokenPos, nPos, sWord, sPattern): +def select (dTokenPos, nPos, sWord, sPattern, sNegPattern=""): "Disambiguation: select morphologies of matching " if not sWord: return True if nPos not in dTokenPos: echo("Error. There should be a token at this position: ", nPos) return True lMorph = _oSpellChecker.getMorph(sWord) if not lMorph or len(lMorph) == 1: return True - lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) ] - if lSelect and len(lSelect) != len(lMorph): - dTokenPos[nPos]["lMorph"] = lSelect - return True - - -def exclude (dTokenPos, nPos, sWord, sPattern): - "Disambiguation: exclude morphologies of matching " - if not sWord: - return True - if nPos not in dTokenPos: - echo("Error. There should be a token at this position: ", nPos) - return True - lMorph = _oSpellChecker.getMorph(sWord) - if not lMorph or len(lMorph) == 1: - return True - lSelect = [ sMorph for sMorph in lMorph if not re.search(sPattern, sMorph) ] + if sPattern: + if sNegPattern: + lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) and not re.search(sNegPattern, sMorph) ] + else: + lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) ] + elif sNegPattern: + lSelect = [ sMorph for sMorph in lMorph if not re.search(sNegPattern, sMorph) ] + else: + echo("# Error: missing pattern for disambiguation selection...") + return True if lSelect and len(lSelect) != len(lMorph): dTokenPos[nPos]["lMorph"] = lSelect return True @@ -339,28 +332,25 @@ return True #### Disambiguation for graph rules -def g_select (dToken, sPattern): - "Disambiguation: select morphologies for according to , always return True" +def g_select (dToken, sPattern, sNegPattern=""): + "Disambiguation: select morphologies for according to , removing those matching ; always return True" lMorph = dToken["lMorph"] if "lMorph" in dToken else _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph or len(lMorph) == 1: return True - lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) ] - if lSelect and len(lSelect) != len(lMorph): - dToken["lMorph"] = lSelect - #echo("DA:", dToken["sValue"], dToken["lMorph"]) - return True - - -def g_exclude (dToken, sPattern): - "Disambiguation: select morphologies for according to , always return True" - lMorph = dToken["lMorph"] if "lMorph" in dToken else _oSpellChecker.getMorph(dToken["sValue"]) - if not lMorph or len(lMorph) == 1: - return True - lSelect = [ sMorph for sMorph in lMorph if not re.search(sPattern, sMorph) ] + if sPattern: + if sNegPattern: + lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) and not re.search(sNegPattern, sMorph) ] + else: + lSelect = [ sMorph for sMorph in lMorph if re.search(sPattern, sMorph) ] + elif sNegPattern: + lSelect = [ sMorph for sMorph in lMorph if not re.search(sNegPattern, sMorph) ] + else: + echo("# Error: missing pattern for disambiguation selection...") + return True if lSelect and len(lSelect) != len(lMorph): dToken["lMorph"] = lSelect #echo("DA:", dToken["sValue"], dToken["lMorph"]) return True Index: gc_lang/fr/perf_memo.txt ================================================================== --- gc_lang/fr/perf_memo.txt +++ gc_lang/fr/perf_memo.txt @@ -35,6 +35,6 @@ 1.12.2 2020.09.11 19:16 1.35297 0.330545 0.221731 0.0666998 0.0692539 0.0701707 0.160564 0.0891676 0.015807 0.0045998 1.12.2 2020.09.30 14:50 1.37531 0.330381 0.226012 0.0668063 0.0690574 0.0694727 0.160282 0.0929373 0.0176629 0.0019713 1.12.2 2020.09.30 17:01 1.37168 0.329009 0.248127 0.0670758 0.0701238 0.0910568 0.170556 0.093876 0.0168925 0.0020051 1.12.2 2020.10.01 11:18 1.36493 0.34176 0.24473 0.0691607 0.0720002 0.0903613 0.170067 0.0934571 0.0174357 0.0019585 2.0.0 2020.11.29 00:00 1.27748 0.320919 0.227774 0.0649503 0.0688481 0.0672859 0.163426 0.0878984 0.016784 0.0018913 -2.0.0 2020.11.30 11:29 1.41342 0.337644 0.237702 0.0724714 0.0806047 0.0743924 0.190887 0.101287 0.0176239 0.0022744 +2.0.0 2020.11.30 11:29 1.41342 0.337644 0.237702 0.0724714 0.0806047 0.0743924 0.190887 0.101287 0.0176239 0.0022744 Index: gc_lang/fr/rules.grx ================================================================== --- gc_lang/fr/rules.grx +++ gc_lang/fr/rules.grx @@ -2366,23 +2366,23 @@ <<- =>> select(\1, ":D") la *WORD <<- not value(<1, "|je|j’|il|on|elle|nous|vous|ils|elles|iel|iels|ne|n’|me|m’|te|t’|se|s’|") and (morph(\2, ":[NABWM]", "*") or value(\2, "|plus|moins|plupart|")) =>> select(\1, ":D") <<- __else__ and morph(\2, ":[ISKYPE]", "*") =>> select(\1, ":Ov") - <<- __else__ and not value(<1, "|le|ce|du|") =>> exclude(\1, ":N") + <<- __else__ and not value(<1, "|le|ce|du|") =>> select(\1, "", ":N") les *WORD <<- not value(<1, "|je|j’|il|on|elle|nous|vous|ils|elles|iel|iels|ne|n’|me|m’|te|t’|se|s’|") and (morph(\2, ":[NABWM]", "*") or value(\2, "|plus|moins|")) =>> select(\1, ":D") <<- __else__ and morph(\2, ":[ISKYPE]", "*") =>> select(\1, ":Ov") leur *WORD - <<- not value(<1, "|le|du|") =>> exclude(\1, ":N") + <<- not value(<1, "|le|du|") =>> select(\1, "", ":N") <<- not value(<1, "|je|j’|il|on|elle|nous|vous|ils|elles|iel|iels|ne|n’|me|m’|te|t’|se|s’|") and (morph(\2, ":[NABWM]", "*") or value(\2, "|plus|moins|")) =>> select(\1, ":D") <<- __else__ and morph(\2, ":[ISKYPE]", "*") =>> select(\1, ":Ov") leurs *WORD - <<- not value(<1, "|les|des|") =>> exclude(\1, ":N") + <<- not value(<1, "|les|des|") =>> select(\1, "", ":N") en [*NUM|*HOUR] <<- =>> select(\1, ":R") en *WORD @@ -2401,17 +2401,17 @@ <<- value(<1, "|j’|n’|m’|t’|s’|l’|c’|") or morph(\2, ":(?:[123][sp]|P|Y)") =>> select(\1, ":Ov") __da_nous_vous__ [ne|n’] [nous|vous] - <<- =>> exclude(\2, ":Os") + <<- =>> select(\2, "", ":Os") nous [>avoir|>être] - <<- not morph(\2, ":1p") =>> exclude(\1, ":Os") + <<- not morph(\2, ":1p") =>> select(\1, "", ":Os") vous [>avoir|>être] - <<- not morph(\2, ":2p") =>> exclude(\1, ":Os") + <<- not morph(\2, ":2p") =>> select(\1, "", ":Os") __da_préverbes_verbes__ [ne|n’] ?[le|la|l’|les|nous|vous|lui|leur]¿ @:¬:[OX] [ne|n’] [nous|vous] [le|la|l’|les|en] @:¬:[OX] @@ -2427,11 +2427,11 @@ lui @:[ISKQYP]¬:3s <<- =>> select(\1, ":Ov") lui - <<- morph(<1, ":R") =>> exclude(\1, ":(?:Q|Os)") + <<- morph(<1, ":R") =>> select(\1, "", ":(?:Q|Os)") [me|m’|te] ?[le|la|l’|les|en|y]¿ @:¬:[OX] <<- =>> select(\-1, ":[ISKYPE]") [se|s’] ?[le|la|l’|les|en|y]¿ @:¬:[OX] @@ -2493,17 +2493,17 @@ $:M @:(?:[123]s|Ov)¬:A <<- =>> =select(\2, ":M") [que|qu’|combien|pourquoi|qui|quand|où] ?[en|y]¿ *WORD - <<- =>> exclude(\-1, ":E") + <<- =>> select(\-1, "", ":E") [|,|(] quelqu’ un *WORD - <<- =>> exclude(\4, ":N") + <<- =>> select(\4, "", ":N") >falloir [pouvoir|savoir|vouloir|manger|conseiller] - <<- =>> exclude(\2, ":N") + <<- =>> select(\2, "", ":N") v’nir <<- ~>> venir s’ ra @@ -2519,11 +2519,11 @@ [de|d’|par|pour|sans|contre] [elle|lui|nous|vous|eux|elles|celui-ci|celui-là|celle-ci|celle-là|ceux-ci|ceux-là|celles-ci|celles-là] <<- =>> select(\-1, ":Oo") après avoir $:Q - <<- =>> exclude(\2, ":N") + <<- =>> select(\2, "", ":N") __da_jours__ [lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche] <<- not morph(<1, ":[DA].*:[me]:[si]") =>> select(\1, ":W") @@ -2532,25 +2532,25 @@ [ça|ceci|cela] a <<- =>> select(\2, ":V") __da_autour__ autour [de|du|d’|des] - <<- not morph(<1, ":D.*:[me]") =>> exclude(\1, ":N") + <<- not morph(<1, ":D.*:[me]") =>> select(\1, "", ":N") __da_avant__ avant [que|qu’|$:D] <<- not value(<1, "|l’|quel|cet|un|mon|ton|son|notre|votre|leur|") =>> select(\1, ":R") __da_bien__ bien [que|qu’] - <<- not morph(<1, ":[DNA].*:[me]:[si]") =>> exclude(\1, ":[AW]") + <<- not morph(<1, ":[DNA].*:[me]:[si]") =>> select(\1, "", ":[AW]") bien $:Y <<- not morph(<1, ":[DNA].*:[me]:[si]") =>> select(\1, ":W") bien *WORD - <<- not value(\2, "|que|qu’|") =>> exclude(\1, ":G") + <<- not value(\2, "|que|qu’|") =>> select(\1, "", ":G") __da_car__ car <<- not morph(<1, ":[DA].*:[me]:[si]") =>> select(\1, ":G") @@ -2564,27 +2564,27 @@ ce @:3[sp]¬:[NA].*:[me]:[si] ce [ne|n’] <<- =>> select(\1, ":O") ce [que|qu’|qui|dont|pour|par] - <<- =>> exclude(\1, ":D") + <<- =>> select(\1, "", ":D") __da_cela__ [|,|(] cela [ne|n’|me|m’|te|t’|se|s’] [|,|(] cela [le|la|l’|les|en|nous|vous|lui|leur|y] @:(?:[123]s|P) [|,|(] cela [nous|vous] [le|la|l’|les|en|y] @:(?:[123]s|P) [|,|(] cela [le|la|l’|les] [lui|leur|en|y] @:(?:[123]s|P) [|,|(] cela [lui|leur|y] en @:(?:[123]s|P) [|,|(] cela @:(?:[123]s|P) - <<- =>> exclude(\2, ":V") + <<- =>> select(\2, "", ":V") __da_certains_certaines__ certains @:[NA].*:[me]:[pi]¬:(?:G|3[sp]) - <<- =>> exclude(\1, ":O") + <<- =>> select(\1, "", ":O") certaines @:[NA].*:[fe]:[pi]¬:(?:G|3[sp]) - <<- =>> exclude(\1, ":O") + <<- =>> select(\1, "", ":O") certains [ne|n’|me|m’|te|t’|se|s’] @:3p certains [le|la|l’|les|en|nous|vous|lui|leur|y] @:3p certains [nous|vous] [le|la|l’|les|en|y] @:3p certains [le|la|l’|les] [lui|leur|en|y] @:3p @@ -2609,11 +2609,11 @@ [>guerre|>jihad|>offensive|>ratonnade|>sortilège|>violence] ?$:A¬:G¿ contre [>antidote|>crime|>philtre|>remède|>sérum|>vaccin|>solution] ?$:A¬:G¿ contre <<- =>> select(\-1, ":R") contre - <<- not morph(<1, ":[DA].*:[me]:[si]") =>> exclude(\1, ":N") + <<- not morph(<1, ":[DA].*:[me]:[si]") =>> select(\1, "", ":N") __da_dans__ dans <<- not morph(<1, ":D.*:p|>[a-zé-]+ième/") =>> select(\1, ":R") @@ -2671,11 +2671,11 @@ >choisir entre <<- =>> select(\-1, ":R") __da_environ__ environ [$:B|*NUM] - <<- not value(<1, "|l’|un|cet|quel|") =>> exclude(\1, ":N") + <<- not value(<1, "|l’|un|cet|quel|") =>> select(\1, "", ":N") __da_été__ >avoir ?@:[WX]¿ été <<- =>> select(\1, ":V0") and select(\-1, ":Q") @@ -2682,24 +2682,24 @@ [un|l’|quel|cet|mon|ton|son|notre|votre|leur] été <<- =>> select(\-1, ":N") __da_face__ face [à|au|aux] - <<- not morph(<1, ":(?:D|A.*:[fe]:[si])") =>> exclude(\1, ":N") + <<- not morph(<1, ":(?:D|A.*:[fe]:[si])") =>> select(\1, "", ":N") <<- __else__ =>> select(\1, ":N") __da_grâce__ grâce [à|au|aux] - <<- not morph(<1, ":(?:D|A.*:[fe]:[si])") =>> exclude(\1, ":N") + <<- not morph(<1, ":(?:D|A.*:[fe]:[si])") =>> select(\1, "", ":N") __da_grave__ grave - <<- morph(<1, ":D") =>> exclude(\1, ":W") + <<- morph(<1, ":D") =>> select(\1, "", ":W") __da_mais__ mais - <<- not value(<1, "|les|ces|des|mes|tes|ses|nos|vos|leurs|quelques|") =>> exclude(\1, ":N") + <<- not value(<1, "|les|ces|des|mes|tes|ses|nos|vos|leurs|quelques|") =>> select(\1, "", ":N") n’ en >pouvoir mais <<- =>> define(\-1, ">mais/:W") __da_mal__ @@ -2737,11 +2737,11 @@ [le|l’|un|mon|notre|votre|leur|chaque|mes|tes|ses|nos|vos|leurs|quel|quels|quelle|quelles] point <<- =>> select(\2, ":N") [ne|n’] $:V point [ne|n’] point - <<- =>> exclude(\-1, ":N") + <<- =>> select(\-1, "", ":N") __da_nos__ nos $¬:B <<- =>> select(\1, ":D") @@ -2749,18 +2749,18 @@ parmi *WORD <<- =>> select(\1, ":R") __da_pas__ pas - <<- morph(<1, ":[VWX]") =>> exclude(\1, ":N") + <<- morph(<1, ":[VWX]") =>> select(\1, "", ":N") pourquoi pas <<- =>> select(\2, ":X") __da_passé__ passé [|,|$:R] - <<- =>> exclude(\1, ":G") + <<- =>> select(\1, "", ":G") __da_pendant__ ## évènements pendant ?tout¿ [le|l’|ce|cet|mon|ton|son|notre|votre|leur] ?[interminable|long]¿ || [accouchement|acte|âge|colloque|confinement|conflit|cours|couronnement|déjeuner|dîner|diner|entracte|entrainement|entraînement|entretien|examen|événement|évènement|interrègne|jihad|mandat|mariage|match|passage|procès|repas|règne|sommeil|souper|temps|travail|voyage] @@ -2784,11 +2784,11 @@ __da_personne__ personne [ne|n’] <<- not morph(<1, ":[DA].*:[fe]:[si]") =>> select(\1, ":O") n’ $:V personne - <<- =>> exclude(\-1, ":N") + <<- =>> select(\-1, "", ":N") [une|le|la|les|des|chaque|quelque|quelques|cet|cette|ces|ma|ta|sa|mes|tes|ses|au|aux|notre|votre|nos|vos|leur|leurs|quel|quelle|quels|quelles] personne [une|la|cette|ma|ta|sa|votre|votre|leur|quel|quelle|quelque] tierce personne <<- =>> select(\-1, ":N") @@ -2809,15 +2809,15 @@ [un|une|des|le|la|l’|les|mon|ton|son|ma|ta|sa|notre|votre|leur|mes|tes|ses|nos|vos|leurs] [plus|moins] @:[AW]¬:G <<- =>> select(\2, ":W") __da_pourvu__ pourvu - <<- not value(>1, "|que|qu’|") =>> exclude(\1, ":G") + <<- not value(>1, "|que|qu’|") =>> select(\1, "", ":G") __da_puis__ puis - <<- not value(<1, "|je|ne|n’|le|l’|leur|") =>> exclude(\1, ":V") + <<- not value(<1, "|je|ne|n’|le|l’|leur|") =>> select(\1, "", ":V") __da_quelque__ quelque *NUM <<- =>> select(\1, ":W") @@ -2824,11 +2824,11 @@ quelque [autre|chose|temps|part] <<- =>> select(\1, ":D") __da_SA__ SA - <<- morph(<1, ":D") =>> exclude(\1, ":D") + <<- morph(<1, ":D") =>> select(\1, "", ":D") __da_selon__ selon @:(?:[DBM]|Oo) <<- =>> select(\1, ":R") @@ -2846,14 +2846,14 @@ si @:[AW]¬:G <<- morph(<1, ":N", ":D") =>> select(\1, ":W") __da_son_ton__ [le|ce|cet|mon|ton|son|quel|quelque|notre|votre|un|leur|ledit|dudit|chaque|des|les|quelques|quel|quelle|quels|quelles] [son|ton] - <<- =>> exclude(\2, ":D") + <<- =>> select(\2, "", ":D") [son|ton] *WORD - <<- morph(\2, ":G", ":[NA]") or value(<1, "|du|le|ce|un|quel|mon|") =>> exclude(\1, ":D") + <<- morph(\2, ":G", ":[NA]") or value(<1, "|du|le|ce|un|quel|mon|") =>> select(\1, "", ":D") <<- __else__ and morph(\2, ":N", "*") =>> select(\1, ":D") [son|ton] , <<- =>> select(\1, ":N") @@ -2870,11 +2870,11 @@ sur @:[BD] <<- not morph(<1, ":(?:V[0123]e|[DN].*:[me]:[si])") =>> select(\1, ":R") __da_tout__ tout - <<- morph(<1, "|>,") =>> exclude(\1, ":N") + <<- morph(<1, "|>,") =>> select(\1, "", ":N") tout @:N.*:[me]:[si]¬:(?:[AGW]|3s) <<- =>> select(\1, ":D") tout le monde @@ -2943,11 +2943,11 @@ vis-à-vis [de|des|du|d’] <<- not morph(<1, ":(?:[DA].*:[me]|R)") =>> select(\1, ":R") __da_vu__ vu [|,|$:R] - <<- =>> exclude(\1, ":G") + <<- =>> select(\1, "", ":G") __da_y_compris__ y compris <<- not value(<1, "|n’|j’|tu|t’|m’|s’|") ~>> ␣ <<- __also__ =>> define(\1, ":G:R:LR") @@ -2967,14 +2967,14 @@ __da_groupe_nominal__ à [la|l’|leur] @:[NA]¬:Y [sans|pour|par] [la|l’|le|les|leur] @:[NA]¬:Y [à|par] @:[NA]¬:Y - <<- =>> exclude(\-1, ":V") + <<- =>> select(\-1, "", ":V") [de|d’] ?[la|l’|leur]¿ @:¬:[YD] - <<- not value(<1, "|semblant|") =>> exclude(\-1, ":V") + <<- not value(<1, "|semblant|") =>> select(\-1, "", ":V") du @:[NA].*:[me]:[si]¬:[GY] <<- =>> select(\2, ":[NA]") aucun @:[NA].*:[me]:s¬:G @@ -2984,39 +2984,39 @@ certains @:[NA].*:[me]:p¬:(?:G|3p|V0) certaines @:[NA].*:[fe]:p¬:(?:G|3p|V0) <<- =>> select(\1, ":D") and select(\2, ":[NA]") d’ [un|une] *WORD - <<- =>> select(\2, ":D") and exclude(\3, ":V") + <<- =>> select(\2, ":D") and select(\3, "", ":V") [un|quel|cet|l’|notre|votre] été <<- =>> select(\2, ":N") l’ [un|une] *WORD <<- not value(\3, "|plus|") =>> select(\3, ":[123][sp]") [des|chaque|quelque|quelques|cet|cette|ces|mon|ma|ta|mes|tes|ses|au|aux|notre|votre|nos|vos|leurs|aucun|aucune] *WORD - <<- not morph(\-1, ":V0") =>> exclude(\-1, ":V") + <<- not morph(\-1, ":V0") =>> select(\-1, "", ":V") ce @:[NA].*:[me]:[si]¬:(?:3[sp]|V0) <<- not value(<1, "|il|elle|on|iel|ils|elles|iels|ne|n’|") =>> select(\-1, ":[NA]") sa @¬:(?:V0|3s) - <<- =>> exclude(\2, ":V") + <<- =>> select(\2, "", ":V") les ~.es$ <<- not value(<1, "|tu|ne|n’|me|m’|te|t’|se|s’|nous|vous|") and morph(\2, ":V1.*Ip.*:2s") and not tagbefore(\1, "_2s_") and not value(>1, "|tu|pas|jamais|") - =>> exclude(\2, ":V") + =>> select(\2, "", ":V") [un|une] *WORD - <<- not value(<1, "|l’|quelqu’|quelqu|") and not value(\2, "|a|fut|fût|est|fait|") and not morph(\2, ":P") =>> exclude(\2, ":V") + <<- not value(<1, "|l’|quelqu’|quelqu|") and not value(\2, "|a|fut|fût|est|fait|") and not morph(\2, ":P") =>> select(\2, "", ":V") [/_VCint_|/_VCimp_] [le|la|l’|leur|les] $:¬:Y <<- =>> select(\2, ":D") de [>tel|ce|cet|cette|ces|mon|ma|ta|sa|mes|tes|ses|notre|votre|plein|pleine] *WORD - <<- =>> exclude(\3, ":V") + <<- =>> select(\3, "", ":V") de [tous|toutes] les *WORD <<- =>> select(\4, ":[NA]") en [plein|pleine] *WORD @@ -3033,11 +3033,11 @@ nombre [de|d’|des] <<- morph(<1, ":[VR]||>,") =>> select(\1, ":N") par *WORD - <<- =>> exclude(\2, ":[123][sp]") + <<- =>> select(\2, "", ":[123][sp]") plein [de|d’] @:[AN] <<- not morph(<1, ":(?:D.*:m|V[0-3]e)") =>> =define(\1, ":G") plusieurs @:[NA].*:p¬:(?:G|3p|V0) @@ -3048,11 +3048,11 @@ source [de|d’] <<- morph(<1, ":V[0-3]e") =>> define(\1, ":ÉV") très *WORD - <<- =>> exclude(\2, ":[123][sp]") + <<- =>> select(\2, "", ":[123][sp]") __da_groupe_nominal__cas_particuliers__ [au|aux] alentour <<- =>> select(\2, ":N") @@ -3074,11 +3074,11 @@ l’ une comme l’ autre <<- ~>> ␣ <<- =>> define(\1, ":GN:f:p") en peine - <<- not value(<1, "|ne|n’|j’|on|il|elle|iel|") =>> exclude(\2, ":V") + <<- not value(<1, "|ne|n’|j’|on|il|elle|iel|") =>> select(\2, "", ":V") m’ dame <<- ~>> ␣madame m’ sieur @@ -3103,11 +3103,11 @@ TEST: tu s’ras bien content d’nous voir. __da_couleurs_invariables__ *WORD [abricot|acajou|amarante|anthracite|aubergine|brique|caca|café|cannelle|caramel|carmin|carotte|cerise|châtaigne|chocolat|citron|corail|crème|fuchsia|groseille|havane|jonquille|marron|mastic|nacarat|ocre|olive|paille|parme|pastel|pervenche|pie|prune|sable|tabac|vermillon] - <<- morph(\1, ":(?:D.*:p|B)") =>> exclude(\2, ":A:e:i") + <<- morph(\1, ":(?:D.*:p|B)") =>> select(\2, "", ":A:e:i") __da_noms_propres__ Concorde <<- not morph(<1, ":D.*:f") =>> addmorph(\1, ">Concorde/:MP:m:i") @@ -16351,10 +16351,11 @@ en toute bonne foi en ?toute¿ connaissance [de|d’] cause en toute [confiance|discrétion|franchise|hâte|impartialité|impunité|innocence|légalité|liberté|logique|modestie|sécurité|simplicité] en travers [de|d’] la gorge en trompe-l’œil + en ultime recours en vase clos en vigueur en vitesse ?[subsonique|supersonique|subluminique|superluminique]¿ en voie [de|d’] développement en vrac @@ -16945,11 +16946,11 @@ pas très <<- morph(<1, ":[NV]", ":A:[em]:[is]") ~>> * personne d’ autre [que|qu’] [moi|moi-même|toi|toi-même|lui|lui-même|elle|elle-même|elles|elles-mêmes|nous|nous-même|nous-mêmes|vous|vous-même|vous-mêmes|eux-mêmes|iel|iels|iel-même|iels-mêmes] <<- ~2:0>> * - <<- =>> exclude(\1, ":N") + <<- =>> select(\1, "", ":N") pour ou contre <<- ~2:0>> * qui ce [jour-là|matin-là|après-midi-là|soir-là|mois-là|siècle-là|millénaire-là] @@ -17741,10 +17742,11 @@ >locomotive à vapeur >loi d’ airain >longueur d’ avance >lopin [de|d’] terre ?[desséchée|glaiseuse|grise|jaune|noire|ocre|rouge|sableuse|sèche]¿ >lune [de|d’] miel + lunettes [de|d’] [soleil|vue] >lutte à outrance >machine à [café|coudre|écrire|laver|sous|vapeur|voter] >machine à remonter le temps >machine [de|d’] guerre >maillot [de|d’] bain @@ -19114,41 +19116,41 @@ [|,|(] c’ ?[ne|n’]¿ >être [le|la|l’|les] @:[NA]¬:G [|,|(] ?[je|tu|il|elle|on|nous|vous|ils|elles|iel|iels]¿ ?[ne|n’]¿ ?[le|la|l’|les|en|me|m’|te|t’|se|s’|nous|vous|lui|leur|y]¿ *WORD [le|la|l’|les] @:[NA]¬:[YG] [|,|(] ?[je|tu|il|elle|on|nous|vous|ils|elles|iel|iels]¿ ?[ne|n’]¿ [me|m’|te|t’|se|s’|nous|vous] [le|la|l’|les|en|y] *WORD [le|la|l’|les] @:[NA]¬:[YG] [|,|(] ?[je|tu|il|elle|on|nous|vous|ils|elles|iel|iels]¿ ?[ne|n’]¿ [le|la|l’|les] [lui|leur|en|y] *WORD [le|la|l’|les] @:[NA]¬:[YG] [|,|(] ?[je|tu|il|elle|on|nous|vous|ils|elles|iel|iels]¿ ?[ne|n’]¿ [lui|leur|y] en *WORD [le|la|l’|les] @:[NA]¬:[YG] - <<- morph(\-3, ":[123][sp]") =>> =select(\-2, ":D") and exclude(\-1, ":[123][sp]") + <<- morph(\-3, ":[123][sp]") =>> =select(\-2, ":D") and select(\-1, "", ":[123][sp]") [/_VCint_|/_VCimp_] [le|la|l’|les|leur|leurs] @:[NA]¬:[YG] - <<- =>> =select(\-2, ":D") and exclude(\-1, ":[123][sp]") + <<- =>> =select(\-2, ":D") and select(\-1, "", ":[123][sp]") __da_substantifs__ [|,|(] $:D *WORD *WORD [ne|n’|me|m’|te|t’|se|s’] [|,|(] $:D *WORD *WORD [en|nous|vous|lui|y] @:(?:[123][sp]|P) [|,|(] $:D *WORD *WORD [le|la|l’|les|leur] @:(?:[123][sp]|P)¬:[NA] [|,|(] $:D *WORD *WORD [nous|vous] [le|la|l’|les|en|y] @:(?:[123][sp]|P) [|,|(] $:D *WORD *WORD [le|la|l’|les] [lui|leur|en|y] @:(?:[123][sp]|P) [|,|(] $:D *WORD *WORD [lui|leur|y] en @:(?:[123][sp]|P) - <<- morph(\3, ":[NA]", ":(?:G|V0)") and morph(\4, ":[NA]", ":(?:[PG]|V[023])") =>> exclude(\4, ":V") + <<- morph(\3, ":[NA]", ":(?:G|V0)") and morph(\4, ":[NA]", ":(?:[PG]|V[023])") =>> select(\4, "", ":V") [|,|(] $:D *WORD *WORD @:(?:3[sp]|P)¬:[GW] - <<- morph(\2, ":p") and morph(\3, ":[NA].*:p", ":(?:G|V0)") and morph(\4, ":[NA].*:p", ":(?:[PGQ]|V[023])") =>> exclude(\4, ":V") + <<- morph(\2, ":p") and morph(\3, ":[NA].*:p", ":(?:G|V0)") and morph(\4, ":[NA].*:p", ":(?:[PGQ]|V[023])") =>> select(\4, "", ":V") <<- __else__ and - morph(\2, ":s") and morph(\3, ":[NA].*:s", ":(?:G|V0)") and morph(\4, ":[NA].*:s", ":(?:[PGQ]|V[023])") and not morph(\5, ":A.*:[si]") =>> exclude(\4, ":V") + morph(\2, ":s") and morph(\3, ":[NA].*:s", ":(?:G|V0)") and morph(\4, ":[NA].*:s", ":(?:[PGQ]|V[023])") and not morph(\5, ":A.*:[si]") =>> select(\4, "", ":V") [des|ces|mes|tes|ses|nos|vos|quelques|lesdits] @:A.*:[pi] @:N.*:[pi]¬(?:3[sp]|Q|G) - <<- =>> exclude(\3, ":V") + <<- =>> select(\3, "", ":V") les @:A.*:[pi]¬:V @:N.*:[pi]¬(?:3[sp]|Q|G) - <<- not before(":O[vs]") =>> exclude(\3, ":V") + <<- not before(":O[vs]") =>> select(\3, "", ":V") leurs @:A.*:[pi]¬:V @:N.*:[pi]¬(?:3[sp]|Q|G) - <<- not before(":O[vs]") =>> exclude(\3, ":V") + <<- not before(":O[vs]") =>> select(\3, "", ":V") [plusieurs|certains|certaines|maints|maintes] @:A.*:[pi]¬:3[sp] @:N.*:p¬:(?:3[sp]|Q|G) - <<- =>> select(\2, ":A") and exclude(\3, ":N") + <<- =>> select(\2, ":A") and select(\3, "", ":N") __da_locutions_verbales__ >avoir [cours|foule|lieu|recours|vent] >avoir ni queue ?,¿ ni tête @@ -19665,11 +19667,11 @@ qui ?[ne|n’]¿ ?[le|la|l’|les|en|me|m’|te|t’|se|s’|nous|vous|lui|leur|y]¿ $:V qui ?[ne|n’]¿ [me|m’|te|t’|se|s’|nous|vous] [le|la|l’|les|en|y] $:V qui ?[ne|n’]¿ [le|la|l’|les] [lui|leur|en|y] $:V qui ?[ne|n’]¿ [lui|leur|y] en $:V - <<- =>> exclude(\-1, ":E") + <<- =>> select(\-1, "", ":E") [|,|(] nous ?[ne|n’]¿ $:1p <<- =>> select(\2, ":Os") and select(\-1, ":[ISK].*:1p") [|,|(] vous ?[ne|n’]¿ $:2p @@ -23483,11 +23485,11 @@ <<- /gn/ ( (morph(\2, ":[NA].*:m", ":[fe]") and morph(\3, ":[NA].*:f", "*")) or (morph(\2, ":[NA].*:f", ":[me]") and morph(\3, ":[NA].*:m", "*")) ) and not apposition(\2, \3) -3>> =switchGender(\3, True) && Accord de genre erroné avec « \2 ». <<- /gn/ __also__ and hasFemForm(\2) -2>> =switchGender(\2) && Accord de genre erroné avec « \3 ». <<- /gn/ morph(\2, ":[NA].*:[pi]", ":G") and morph(\3, ":[NA].*:s", "*") and not apposition(\2, \3) and not (value(>1, "|et|,|") and morph(>2, ":A")) -3>> =suggPlur(\3) && Accord de nombre erroné avec « \1 \2 » : « \3 » devrait être au pluriel. - <<- not morph(\3, ":G|>a/") and agreement(\2, \3) =>> =exclude(\3, ":V") + <<- not morph(\3, ":G|>a/") and agreement(\2, \3) =>> =select(\3, "", ":V") TEST: faire table rase des passions {{inutile}} ->> inutiles TEST: à bonne distance des {{chiens}} {{méchante}} TEST: des hommes {{attaquée}} TEST: des femmes {{agressé}} Index: misc/grammalecte.sublime-syntax ================================================================== --- misc/grammalecte.sublime-syntax +++ misc/grammalecte.sublime-syntax @@ -58,11 +58,11 @@ scope: keyword.python - match: '\b(?:True|False|None)\b' scope: constant.language - - match: '\b(?:spell|morph(?:VC|0|2|)|stem|tag|value|space|textarea0?\w*|before0?\w*|after0?\w*|start0?|end0?|word|option|define(?:from|)|select|exclude|setmeta|analyse|tag(?:after|before)|apposition|is[A-Z]\w+|agreement|rewrite|checkD\w+|getD\w+|has[A-Z]\w+|sugg[A-Z]\w+|switch[A-Z]\w+|ceOrCet|formatN\w+|mbUnit)\b' + - match: '\b(?:spell|morph(?:VC|0|2|)|stem|tag|value|space|textarea0?\w*|before0?\w*|after0?\w*|start0?|end0?|word|option|define(?:from|)|select|setmeta|analyse|tag(?:after|before)|apposition|is[A-Z]\w+|agreement|rewrite|checkD\w+|getD\w+|has[A-Z]\w+|sugg[A-Z]\w+|switch[A-Z]\w+|ceOrCet|formatN\w+|mbUnit)\b' scope: entity.name.function - match: '\b(?:replace|endswith|startswith|search|upper|lower|capitalize|strip|rstrip|is(?:alpha|upper|lower|digit|title))\b' scope: support.function