Overview
| Comment: | [lo][fr][py] générateur de conjugaisons: nouvelles fonctions |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | fr | lo | multid |
| Files: | files | file ages | folders |
| SHA3-256: |
456aa2a2aa3f0dc66e0693b16c7f8439 |
| User & Date: | olr on 2018-03-06 16:44:41 |
| Original Comment: | [lo][fr] générateur de conjugaisons: nouvelles fonctions |
| Other Links: | branch diff | manifest | tags |
Context
|
2018-03-06
| ||
| 18:16 | [fx][fr][js] générateur de conjugaisons: nouvelles fonctions check-in: 0230771aa5 user: olr tags: fr, fx, multid | |
| 16:44 | [lo][fr][py] générateur de conjugaisons: nouvelles fonctions check-in: 456aa2a2aa user: olr tags: fr, lo, multid | |
| 15:38 | [core][fr] générateur de conjugaisons comme module (déplacement de fichiers) check-in: fb9f2914eb user: olr tags: fr, core, multid | |
Changes
Modified gc_lang/fr/modules/conj_generator.py from [2b6010474b] to [908448219c].
|
| | > > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# Conjugation generator
# beta stage, unfinished, the root for a new way to generate flexions…
import re
def conjugate (sVerb, sVerbTag="i_____a", bVarPpas=True):
lConj = []
cGroup = getVerbGroupChar(sVerb)
for nCut, sAdd, sFlexTags, sPattern in getConjRules(sVerb):
if not sPattern or re.search(sPattern, sVerb):
lConj.append((sVerb[0:-nCut]+sAdd, ":V" + cGroup + "_" + sVerbTag + sFlexTags))
return lConj
def getVerbGroupChar (sVerb, ):
sVerb = sVerb.lower()
if sVerb.endswith("er"):
return "1"
if sVerb.endswith("ir"):
return "2"
if sVerb == "être" or sVerb == "avoir":
return "0"
if sVerb.endswith("re"):
return "3"
return "4"
def getConjRules (sVerb, bVarPpas=True, nGroup=2):
if sVerb.endswith("er"):
# premier groupe, conjugaison en fonction de la terminaison du lemme
# 5 lettres
if sVerb[-5:] in oConj["V1"]:
lConj = oConj["V1"][sVerb[-5:]]
# 4 lettres
elif sVerb[-4:] in oConj["V1"]:
if sVerb.endswith(("eler", "eter")):
lConj = oConj["V1"][sVerb[-4:]]["1"]
lConj = oConj["V1"][sVerb[-4:]]
# 3 lettres
elif sVerb[-3:] in oConj["V1"]:
lConj = oConj["V1"][sVerb[-3:]]
else:
lConj = oConj["V1"]["er"]
lConj.extend(oConj["V1_ppas"][bVarPpas])
elif sVerb.endswith("ir") and nGroup <= 2:
# deuxième groupe
lConj = oConj["V2"]
lConj.extend(oConj["V2_ppas"][bVarPpas])
else:
# TODO: troisième groupe
lConj = [ [0, "", ":Y/*", false] ]
return lConj
oConj = {
"V1_ppas": {
True: [
[2, "é", ":Q:A:1ŝ:m:s/*", False],
[2, "és", ":Q:A:m:p/*", False],
[2, "ée", ":Q:A:f:s/*", False],
[2, "ées", ":Q:A:f:p/*", False],
],
False: [
[2, "é", ":Q:e:i/*", False],
]
},
"V2_ppas": {
True: [
[2, "i", ":Q:A:m:s/*", False],
[2, "is", ":Q:A:m:p/*", False],
[2, "ie", ":Q:A:f:s/*", False],
[2, "ies", ":Q:A:f:p/*", False],
],
False: [
[2, "i", ":Q:e:i/*", False],
]
},
# deuxième groupe (le seul groupe régulier)
"V2": [
[2, "ir", ":Y/*", False],
|
| ︙ | ︙ |
Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [afd65cf50b] to [2c842dcb12].
| ︙ | ︙ | |||
397 398 399 400 401 402 403 |
c_m = "m" if self.xV_m.State else "_"
c_ae = "e" if self.xV_ae.State else "_"
c_aa = "a" if self.xV_aa.State else "_"
sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa
if not sVerbTag.endswith("__") and not sVerbTag.startswith("____"):
sVerbPattern = self.xVpattern.Text.strip()
if not sVerbPattern:
| < | < < < < < < < | < | | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
c_m = "m" if self.xV_m.State else "_"
c_ae = "e" if self.xV_ae.State else "_"
c_aa = "a" if self.xV_aa.State else "_"
sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa
if not sVerbTag.endswith("__") and not sVerbTag.startswith("____"):
sVerbPattern = self.xVpattern.Text.strip()
if not sVerbPattern:
# Utilisation du générateur de conjugaison
for sFlexion, sFlexTags in conjgen.conjugate(sLemma, sVerbTag, bool(self.xV_pp.State)):
self.lGeneratedFlex.append((sFlexion, sLemma, sFlexTags))
else:
# copie du motif d’un autre verbe : utilisation du conjugueur
if conj.isVerb(sVerbPattern):
oVerb = conj.Verb(sLemma, sVerbPattern)
for sTag1, dFlex in oVerb.dConj.items():
if sTag1 != ":Q":
for sTag2, sConj in dFlex.items():
|
| ︙ | ︙ | |||
442 443 444 445 446 447 448 |
# Autre
sFlexion = self.xFlexion.Text.strip()
sTags = self.xTags.Text.strip()
if sFlexion and sTags.startswith(":"):
self.lGeneratedFlex.append((sFlexion, sLemma, sTags))
self._showGenWords()
| < < < < < < < < < < < < < < < < < < < < < < | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# Autre
sFlexion = self.xFlexion.Text.strip()
sTags = self.xTags.Text.strip()
if sFlexion and sTags.startswith(":"):
self.lGeneratedFlex.append((sFlexion, sLemma, sTags))
self._showGenWords()
def _showGenWords (self):
xGridDataModel = self.xGridModelNew.GridDataModel
xGridDataModel.removeAllRows()
if not self.lGeneratedFlex:
self.xAdd.Enabled = False
return
for i, (sFlexion, sLemma, sTag) in enumerate(self.lGeneratedFlex):
|
| ︙ | ︙ |