Grammalecte  Check-in [8b4efd4241]

Overview
Comment:[build][core][fr] function change_meta(), +ajustements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fr | core | build
Files: files | file ages | folders
SHA3-256: 8b4efd42416e53114d1c8bcf0880593d81af2ae655572108a141881daa1fc295
User & Date: olr on 2019-08-27 08:04:55
Original Comment: [build][core][fr] function change_meta()
Other Links: manifest | tags
Context
2019-08-27
09:55
[core] suggSing() and suggPlur(): remove useless condition check-in: 90c5c54a05 user: olr tags: core, trunk
08:04
[build][core][fr] function change_meta(), +ajustements check-in: 8b4efd4241 user: olr tags: build, core, fr, trunk
06:21
[fr] ajustements check-in: 702c4c02f1 user: olr tags: fr, trunk
Changes

Modified compile_rules_graph.py from [b81c4ccc24] to [b8468e70e1].

    46     46       if sCode[0:1] == "=":
    47     47           sCode = sCode[1:]
    48     48       sCode = sCode.replace("__also__", "bCondMemo")
    49     49       sCode = sCode.replace("__else__", "not bCondMemo")
    50     50       sCode = sCode.replace("sContext", "_sAppContext")
    51     51       sCode = re.sub(r"(morph|morphVC|analyse|value|tag|displayInfo)[(]\\(\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
    52     52       sCode = re.sub(r"(morph|morphVC|analyse|value|tag|displayInfo)[(]\\-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
    53         -    sCode = re.sub(r"(select|exclude|define|define_from)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
    54         -    sCode = re.sub(r"(select|exclude|define|define_from)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
           53  +    sCode = re.sub(r"(select|exclude|define|define_from|change_meta)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
           54  +    sCode = re.sub(r"(select|exclude|define|define_from|change_meta)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
    55     55       sCode = re.sub(r"(tag_before|tag_after)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2], dTags', sCode)
    56     56       sCode = re.sub(r"(tag_before|tag_after)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1], dTags', sCode)
    57     57       sCode = re.sub(r"space_after[(][\\](\d+)", 'g_space_between_tokens(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode)
    58     58       sCode = re.sub(r"space_after[(][\\]-(\d+)", 'g_space_between_tokens(lToken[nLastToken-\\1+1], lToken[nLastToken-\\1+2]', sCode)
    59     59       sCode = re.sub(r"analyse_with_next[(][\\](\d+)", 'g_merged_analyse(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode)
    60     60       sCode = re.sub(r"analyse_with_next[(][\\]-(\d+)", 'g_merged_analyse(lToken[nLastToken-\\1+1], lToken[nLastToken-\\1+2]', sCode)
    61     61       sCode = re.sub(r"(morph|analyse|tag|value)\(>1", 'g_\\1(lToken[nLastToken+1]', sCode)                       # next token

Modified gc_core/js/lang_core/gc_engine.js from [4f26fdbb38] to [73b1002d2e].

  1459   1459       let sValue = oToken["sValue"];
  1460   1460       if (nLeft !== null) {
  1461   1461           sValue = (nRight !== null) ? sValue.slice(nLeft, nRight) : sValue.slice(nLeft);
  1462   1462       }
  1463   1463       oToken["lMorph"] = _oSpellChecker.getMorph(sValue);
  1464   1464       return true;
  1465   1465   }
         1466  +
         1467  +function g_change_meta (oToken, sType) {
         1468  +    // Disambiguation: change type of token
         1469  +    oToken["sType"] = sType;
         1470  +    return true;
         1471  +}
         1472  +
  1466   1473   
  1467   1474   
  1468   1475   //////// GRAMMAR CHECKER PLUGINS
  1469   1476   
  1470   1477   ${pluginsJS}
  1471   1478   
  1472   1479   

Modified gc_core/py/lang_core/gc_engine.py from [259ba70a2c] to [3f4ffa12fb].

  1117   1117       return False
  1118   1118   
  1119   1119   
  1120   1120   def g_tag (dToken, sTag):
  1121   1121       "returns True if <sTag> is present on token <dToken>"
  1122   1122       return "aTags" in dToken and sTag in dToken["aTags"]
  1123   1123   
         1124  +
         1125  +def g_meta (dToken, sType):
         1126  +    "returns True if <sType> is equal to the token type"
         1127  +    return dToken["sType"] == sType
         1128  +
  1124   1129   
  1125   1130   def g_space_between_tokens (dToken1, dToken2, nMin, nMax=None):
  1126   1131       "checks if spaces between tokens is >= <nMin> and <= <nMax>"
  1127   1132       nSpace = dToken2["nStart"] - dToken1["nEnd"]
  1128   1133       if nSpace < nMin:
  1129   1134           return False
  1130   1135       if nMax is not None and nSpace > nMax:
................................................................................
  1186   1191       "Disambiguation: set morphologies of token at <nPos> with <lMorph>"
  1187   1192       if nPos not in dTokenPos:
  1188   1193           echo("Error. There should be a token at this position: ", nPos)
  1189   1194           return True
  1190   1195       dTokenPos[nPos]["lMorph"] = lMorph
  1191   1196       return True
  1192   1197   
         1198  +
  1193   1199   
  1194   1200   #### Disambiguation for graph rules
  1195   1201   
  1196   1202   def g_select (dToken, sPattern, lDefault=None):
  1197   1203       "select morphologies for <dToken> according to <sPattern>, always return True"
  1198   1204       lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])
  1199   1205       if not lMorph or len(lMorph) == 1:
................................................................................
  1240   1246       "set morphologies of <dToken> with slicing its value with <nLeft> and <nRight>"
  1241   1247       if nLeft is not None:
  1242   1248           dToken["lMorph"] = _oSpellChecker.getMorph(dToken["sValue"][slice(nLeft, nRight)])
  1243   1249       else:
  1244   1250           dToken["lMorph"] = _oSpellChecker.getMorph(dToken["sValue"])
  1245   1251       return True
  1246   1252   
         1253  +
         1254  +def g_change_meta (dToken, sType):
         1255  +    "Disambiguation: change type of token"
         1256  +    dToken["sType"] = sType
         1257  +    return True
         1258  +
  1247   1259   
  1248   1260   
  1249   1261   #### GRAMMAR CHECKER PLUGINS
  1250   1262   
  1251   1263   ${plugins}
  1252   1264   
  1253   1265   

Modified gc_lang/fr/rules.grx from [ab4b2094bc] to [2ffda65501].

  3603   3603   TEST: Le {{XXIème}} siècle.                     ->> XXIᵉ
  3604   3604   TEST: le {{XXè}} siècle.                        ->> XXᵉ
  3605   3605   TEST: les {{CXIèmes}}                           ->> CXIᵉˢ
  3606   3606   
  3607   3607   
  3608   3608   
  3609   3609   !!!! Dates                                                                                        !!
         3610  +
         3611  +__fusion_date__
         3612  +    *NUM  -  ~^\d\d?$  - ~^\d{2,5}$
         3613  +        <<- \1.isdigit() ~>> ␣
         3614  +        <<- =>> change_meta(\1, "DATE")
         3615  +
  3610   3616   
  3611   3617   __date_jour_mois_année__
  3612   3618       31 [avril|juin|septembre|novembre]
  3613   3619           <<- /date/ space_after(\1, 1, 1) ->> 30 \2                                                  # Cette date est invalide. Il n’y a que 30 jours en \2.
  3614   3620   
  3615   3621       [30|31] février
  3616   3622           <<- /date/ space_after(\1, 1, 1) ->> 28 février|29 février                                  # Cette date est invalide. Il n’y a que 28 ou 29 jours en février.
................................................................................
  3620   3626   
  3621   3627   TEST: le {{31 avril}}
  3622   3628   TEST: le {{30 février}}
  3623   3629   TEST: {{29 février 2011}}
  3624   3630   
  3625   3631   
  3626   3632   __date_journée_jour_mois_année__
  3627         -    *NUM - *NUM - ~^\d{2,5}$
  3628         -        <<- \1.isdigit() and \2.isdigit() ~>> ␣
  3629         -
  3630   3633       ([lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche])  ?,¿  ?le¿  (~^\d\d?$) - (~^\d\d?$) - (~^\d{2,5}$)
  3631         -        <<- /date/ not after("^ +av(?:ant|) +J(?:C|ésus-Christ)") and not checkDay(\1, \2, \3, \4)
  3632         -        -1>> =getDay(\2, \3, \4)
  3633         -        # Le jour de la date suivante est incorrect (selon le calendrier grégorien).|https://fr.wikipedia.org/wiki/Passage_du_calendrier_julien_au_calendrier_gr%C3%A9gorien
  3634         -
  3635   3634       ([lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche])  ?,¿  ?le¿  (~^\d\d?$)  ([janvier|février|mars|avril|mai|juin|juillet|aout|août|septembre|octobre|novembre|décembre])  (~^\d{2,5}$)
  3636   3635           <<- /date/ not after("^ +av(?:ant|) +J(?:C|ésus-Christ)") and not checkDay(\1, \2, \3, \4)
  3637   3636           -1>> =getDay(\2, \3, \4)
  3638   3637           # Le jour de la date suivante est incorrect (selon le calendrier grégorien).|https://fr.wikipedia.org/wiki/Passage_du_calendrier_julien_au_calendrier_gr%C3%A9gorien
  3639   3638   
  3640   3639   TEST: {{samedi}}, le 10-06-2014                                           ->> mardi
  3641   3640   TEST: {{lundi}} le 23-07-2019