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: trunk, core
08:04
[build][core][fr] function change_meta(), +ajustements check-in: 8b4efd4241 user: olr tags: trunk, fr, core, build
06:21
[fr] ajustements check-in: 702c4c02f1 user: olr tags: trunk, fr
Changes

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

46
47
48
49
50
51
52
53
54


55
56
57
58
59
60
61
46
47
48
49
50
51
52


53
54
55
56
57
58
59
60
61







-
-
+
+







    if sCode[0:1] == "=":
        sCode = sCode[1:]
    sCode = sCode.replace("__also__", "bCondMemo")
    sCode = sCode.replace("__else__", "not bCondMemo")
    sCode = sCode.replace("sContext", "_sAppContext")
    sCode = re.sub(r"(morph|morphVC|analyse|value|tag|displayInfo)[(]\\(\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
    sCode = re.sub(r"(morph|morphVC|analyse|value|tag|displayInfo)[(]\\-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
    sCode = re.sub(r"(select|exclude|define|define_from)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
    sCode = re.sub(r"(select|exclude|define|define_from)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
    sCode = re.sub(r"(select|exclude|define|define_from|change_meta)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2]', sCode)
    sCode = re.sub(r"(select|exclude|define|define_from|change_meta)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1]', sCode)
    sCode = re.sub(r"(tag_before|tag_after)[(][\\](\d+)", 'g_\\1(lToken[nTokenOffset+\\2], dTags', sCode)
    sCode = re.sub(r"(tag_before|tag_after)[(][\\]-(\d+)", 'g_\\1(lToken[nLastToken-\\2+1], dTags', sCode)
    sCode = re.sub(r"space_after[(][\\](\d+)", 'g_space_between_tokens(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode)
    sCode = re.sub(r"space_after[(][\\]-(\d+)", 'g_space_between_tokens(lToken[nLastToken-\\1+1], lToken[nLastToken-\\1+2]', sCode)
    sCode = re.sub(r"analyse_with_next[(][\\](\d+)", 'g_merged_analyse(lToken[nTokenOffset+\\1], lToken[nTokenOffset+\\1+1]', sCode)
    sCode = re.sub(r"analyse_with_next[(][\\]-(\d+)", 'g_merged_analyse(lToken[nLastToken-\\1+1], lToken[nLastToken-\\1+2]', sCode)
    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
1460
1461
1462
1463
1464
1465







1466
1467
1468
1469
1470
1471
1472
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479







+
+
+
+
+
+
+







    let sValue = oToken["sValue"];
    if (nLeft !== null) {
        sValue = (nRight !== null) ? sValue.slice(nLeft, nRight) : sValue.slice(nLeft);
    }
    oToken["lMorph"] = _oSpellChecker.getMorph(sValue);
    return true;
}

function g_change_meta (oToken, sType) {
    // Disambiguation: change type of token
    oToken["sType"] = sType;
    return true;
}



//////// GRAMMAR CHECKER PLUGINS

${pluginsJS}


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

1117
1118
1119
1120
1121
1122
1123





1124
1125
1126
1127
1128
1129
1130
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135







+
+
+
+
+







    return False


def g_tag (dToken, sTag):
    "returns True if <sTag> is present on token <dToken>"
    return "aTags" in dToken and sTag in dToken["aTags"]


def g_meta (dToken, sType):
    "returns True if <sType> is equal to the token type"
    return dToken["sType"] == sType


def g_space_between_tokens (dToken1, dToken2, nMin, nMax=None):
    "checks if spaces between tokens is >= <nMin> and <= <nMax>"
    nSpace = dToken2["nStart"] - dToken1["nEnd"]
    if nSpace < nMin:
        return False
    if nMax is not None and nSpace > nMax:
1186
1187
1188
1189
1190
1191
1192

1193
1194
1195
1196
1197
1198
1199
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205







+







    "Disambiguation: set morphologies of token at <nPos> with <lMorph>"
    if nPos not in dTokenPos:
        echo("Error. There should be a token at this position: ", nPos)
        return True
    dTokenPos[nPos]["lMorph"] = lMorph
    return True



#### Disambiguation for graph rules

def g_select (dToken, sPattern, lDefault=None):
    "select morphologies for <dToken> according to <sPattern>, always return True"
    lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])
    if not lMorph or len(lMorph) == 1:
1240
1241
1242
1243
1244
1245
1246






1247
1248
1249
1250
1251
1252
1253
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265







+
+
+
+
+
+







    "set morphologies of <dToken> with slicing its value with <nLeft> and <nRight>"
    if nLeft is not None:
        dToken["lMorph"] = _oSpellChecker.getMorph(dToken["sValue"][slice(nLeft, nRight)])
    else:
        dToken["lMorph"] = _oSpellChecker.getMorph(dToken["sValue"])
    return True


def g_change_meta (dToken, sType):
    "Disambiguation: change type of token"
    dToken["sType"] = sType
    return True



#### GRAMMAR CHECKER PLUGINS

${plugins}


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

3603
3604
3605
3606
3607
3608
3609






3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632



3633




3634
3635
3636
3637
3638
3639
3640







+
+
+
+
+
+

















-
-
-

-
-
-
-







TEST: Le {{XXIème}} siècle.                     ->> XXIᵉ
TEST: le {{XXè}} siècle.                        ->> XXᵉ
TEST: les {{CXIèmes}}                           ->> CXIᵉˢ



!!!! Dates                                                                                        !!

__fusion_date__
    *NUM  -  ~^\d\d?$  - ~^\d{2,5}$
        <<- \1.isdigit() ~>> ␣
        <<- =>> change_meta(\1, "DATE")


__date_jour_mois_année__
    31 [avril|juin|septembre|novembre]
        <<- /date/ space_after(\1, 1, 1) ->> 30 \2                                                  # Cette date est invalide. Il n’y a que 30 jours en \2.

    [30|31] février
        <<- /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.

    ~^\d\d?$  [janvier|février|mars|avril|mai|juin|juillet|aout|août|septembre|octobre|novembre|décembre]  ~^\d{2,5}$
        <<- /date/ not checkDate(\1, \2, \3) ->> _                                                  # Cette date est invalide.

TEST: le {{31 avril}}
TEST: le {{30 février}}
TEST: {{29 février 2011}}


__date_journée_jour_mois_année__
    *NUM - *NUM - ~^\d{2,5}$
        <<- \1.isdigit() and \2.isdigit() ~>> ␣

    ([lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche])  ?,¿  ?le¿  (~^\d\d?$) - (~^\d\d?$) - (~^\d{2,5}$)
        <<- /date/ not after("^ +av(?:ant|) +J(?:C|ésus-Christ)") and not checkDay(\1, \2, \3, \4)
        -1>> =getDay(\2, \3, \4)
        # 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

    ([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}$)
        <<- /date/ not after("^ +av(?:ant|) +J(?:C|ésus-Christ)") and not checkDay(\1, \2, \3, \4)
        -1>> =getDay(\2, \3, \4)
        # 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

TEST: {{samedi}}, le 10-06-2014                                           ->> mardi
TEST: {{lundi}} le 23-07-2019