15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
if sVerb.endswith(("-t", "-le", "-la", "-les", "-nous", "-vous", "-leur", "-lui")):
iRight = sVerb.rfind("-")
sSuffix = sVerb[iRight:] + sSuffix
sVerb = sVerb[:iRight]
return sVerb, sSuffix
def suggVerb (sFlex, sWho, funcSugg2=None, bVC=False):
"change <sFlex> conjugation according to <sWho>"
if bVC:
sFlex, sSfx = splitVerb(sFlex)
dSugg = {}
for sStem in _oSpellChecker.getLemma(sFlex):
tTags = conj._getTags(sStem)
if tTags:
|
|
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
if sVerb.endswith(("-t", "-le", "-la", "-les", "-nous", "-vous", "-leur", "-lui")):
iRight = sVerb.rfind("-")
sSuffix = sVerb[iRight:] + sSuffix
sVerb = sVerb[:iRight]
return sVerb, sSuffix
def suggVerb (sFlex, sWho, bVC=False, funcSugg2=None, *args):
"change <sFlex> conjugation according to <sWho>"
if bVC:
sFlex, sSfx = splitVerb(sFlex)
dSugg = {}
for sStem in _oSpellChecker.getLemma(sFlex):
tTags = conj._getTags(sStem)
if tTags:
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
aTense[m.group(1)] = ""
for sTense in aTense.keys():
if sWho == ":1ś" and not conj._hasConjWithTags(tTags, sTense, ":1ś"):
sWho = ":1s"
if conj._hasConjWithTags(tTags, sTense, sWho):
dSugg[conj._getConjWithTags(sStem, tTags, sTense, sWho)] = ""
if funcSugg2:
sSugg2 = funcSugg2(sFlex)
if sSugg2:
dSugg[sSugg2] = ""
if dSugg:
if bVC:
return "|".join([ joinVerbAndSuffix(sSugg, sSfx) for sSugg in dSugg.keys() ])
return "|".join(dSugg.keys())
return ""
|
|
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
aTense[m.group(1)] = ""
for sTense in aTense.keys():
if sWho == ":1ś" and not conj._hasConjWithTags(tTags, sTense, ":1ś"):
sWho = ":1s"
if conj._hasConjWithTags(tTags, sTense, sWho):
dSugg[conj._getConjWithTags(sStem, tTags, sTense, sWho)] = ""
if funcSugg2:
sSugg2 = funcSugg2(*args) if args else funcSugg2(sFlex)
if sSugg2:
dSugg[sSugg2] = ""
if dSugg:
if bVC:
return "|".join([ joinVerbAndSuffix(sSugg, sSfx) for sSugg in dSugg.keys() ])
return "|".join(dSugg.keys())
return ""
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
"returns infinitive forms of <sFlex>"
return "|".join([ sStem for sStem in _oSpellChecker.getLemma(sFlex) if conj.isVerb(sStem) ])
_dQuiEst = { "je": ":1s", "j’": ":1s", "tu": ":2s", "il": ":3s", "on": ":3s", "elle": ":3s", "iel": ":3s", \
"nous": ":1p", "vous": ":2p", "ils": ":3p", "elles": ":3p", "iels": ":3p" }
def suggVerbMode (sFlex, cMode, sSuj):
"returns other conjugations of <sFlex> acconding to <cMode> and <sSuj>"
if cMode == ":I":
lMode = [":Ip", ":Iq", ":Is", ":If"]
elif cMode == ":S":
lMode = [":Sp", ":Sq"]
elif cMode.startswith((":I", ":S")):
lMode = [cMode]
else:
return ""
sWho = _dQuiEst.get(sSuj.lower(), ":3s")
dSugg = {}
for sStem in _oSpellChecker.getLemma(sFlex):
tTags = conj._getTags(sStem)
if tTags:
for sTense in lMode:
if conj._hasConjWithTags(tTags, sTense, sWho):
dSugg[conj._getConjWithTags(sStem, tTags, sTense, sWho)] = ""
if dSugg:
return "|".join(dSugg.keys())
return ""
## Nouns and adjectives
|
>
>
>
>
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
"returns infinitive forms of <sFlex>"
return "|".join([ sStem for sStem in _oSpellChecker.getLemma(sFlex) if conj.isVerb(sStem) ])
_dQuiEst = { "je": ":1s", "j’": ":1s", "tu": ":2s", "il": ":3s", "on": ":3s", "elle": ":3s", "iel": ":3s", \
"nous": ":1p", "vous": ":2p", "ils": ":3p", "elles": ":3p", "iels": ":3p" }
_dModeSugg = { "es": "aies", "aies": "es", "est": "ait", "ait": "est" }
def suggVerbMode (sFlex, cMode, sSuj):
"returns other conjugations of <sFlex> acconding to <cMode> and <sSuj>"
if cMode == ":I":
lMode = [":Ip", ":Iq", ":Is", ":If"]
elif cMode == ":S":
lMode = [":Sp", ":Sq"]
elif cMode.startswith((":I", ":S")):
lMode = [cMode]
else:
return ""
sWho = _dQuiEst.get(sSuj.lower(), ":3s")
dSugg = {}
for sStem in _oSpellChecker.getLemma(sFlex):
tTags = conj._getTags(sStem)
if tTags:
for sTense in lMode:
if conj._hasConjWithTags(tTags, sTense, sWho):
dSugg[conj._getConjWithTags(sStem, tTags, sTense, sWho)] = ""
if sFlex in _dModeSugg:
dSugg[_dModeSugg[sFlex]] = ""
if dSugg:
return "|".join(dSugg.keys())
return ""
## Nouns and adjectives
|
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
if bSuggSimil:
for e in phonet.selectSimil(sFlex, ":f:[pi]"):
dSugg[e] = ""
if dSugg:
return "|".join(dSugg)
return ""
def g_suggAgree (dTokenDst, dTokenSrc):
"returns suggestions for <dTokenDst> that matches agreement with <dTokenSrc>"
lMorphSrc = dTokenSrc["lMorph"] if "lMorph" in dTokenSrc else _oSpellChecker.getMorph(dTokenSrc["sValue"])
if not lMorphSrc:
return ""
sGender, sNumber = cr.getGenderNumber(lMorphSrc)
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
if bSuggSimil:
for e in phonet.selectSimil(sFlex, ":f:[pi]"):
dSugg[e] = ""
if dSugg:
return "|".join(dSugg)
return ""
def suggAgree (sFlexDest, sFlexSrc):
"returns suggestions for <sFlexDest> that matches agreement with <sFlexSrc>"
lMorphSrc = _oSpellChecker.getMorph(sFlexSrc)
if not lMorphSrc:
return ""
sGender, sNumber = cr.getGenderNumber(lMorphSrc)
if sGender == ":m":
if sNumber == ":s":
return suggMasSing(sFlexDest)
elif sNumber == ":p":
return suggMasPlur(sFlexDest)
return suggMasSing(sFlexDest)
elif sGender == ":f":
if sNumber == ":s":
return suggFemSing(sFlexDest)
elif sNumber == ":p":
return suggFemPlur(sFlexDest)
return suggFemSing(sFlexDest)
elif sGender == ":e":
if sNumber == ":s":
return suggSing(sFlexDest)
elif sNumber == ":p":
return suggPlur(sFlexDest)
return sFlexDest
return ""
def g_suggAgree (dTokenDst, dTokenSrc):
"returns suggestions for <dTokenDst> that matches agreement with <dTokenSrc>"
lMorphSrc = dTokenSrc["lMorph"] if "lMorph" in dTokenSrc else _oSpellChecker.getMorph(dTokenSrc["sValue"])
if not lMorphSrc:
return ""
sGender, sNumber = cr.getGenderNumber(lMorphSrc)
|