Overview
Comment: | [core][fr][py] suggestions: don’t use set anymone, use list, to keep order insertion |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fr | core |
Files: | files | file ages | folders |
SHA3-256: |
e98e6badf3b7695215fa2e005b2b71c9 |
User & Date: | olr on 2021-01-23 15:10:14 |
Other Links: | manifest | tags |
Context
2021-01-23
| ||
15:50 | [fr] ajustements check-in: 852cbe9312 user: olr tags: trunk, fr | |
15:10 | [core][fr][py] suggestions: don’t use set anymone, use list, to keep order insertion check-in: e98e6badf3 user: olr tags: trunk, fr, core | |
14:02 | [core][fr][js] fix getGenderNumber() check-in: 3607227671 user: olr tags: trunk, fr, core | |
Changes
Modified gc_lang/fr/modules/conj.py from [7b2f58ec61] to [9d698bfb2e].
︙ | ︙ | |||
57 58 59 60 61 62 63 | "returns raw informations about sVerb" if sVerb not in _dVerb: return None return _lVtyp[_dVerb[sVerb][0]] def getSimil (sWord, sMorph, bSubst=False): | | | | | > | > | > | > | > | > | > | > | > | > | > | | | | | < | | > | > | > | < < > | | > | > | > | > | > | > | < | 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | "returns raw informations about sVerb" if sVerb not in _dVerb: return None return _lVtyp[_dVerb[sVerb][0]] def getSimil (sWord, sMorph, bSubst=False): "returns a list of verbal forms similar to <sWord>, according to <sMorph>" if ":V" not in sMorph: return [] sInfi = sMorph[1:sMorph.find("/")] aSugg = [] tTags = _getTags(sInfi) if tTags: if not bSubst: # we suggest conjugated forms if ":V1" in sMorph: aSugg.append(sInfi) if _hasConjWithTags(tTags, ":Ip", ":3s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":3s")) if _hasConjWithTags(tTags, ":Ip", ":2p"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":2p")) if _hasConjWithTags(tTags, ":Iq", ":1s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Iq", ":1s")) if _hasConjWithTags(tTags, ":Iq", ":3s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Iq", ":3s")) if _hasConjWithTags(tTags, ":Iq", ":3p"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Iq", ":3p")) elif ":V2" in sMorph: if _hasConjWithTags(tTags, ":Ip", ":1s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":1s")) if _hasConjWithTags(tTags, ":Ip", ":3s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":3s")) elif ":V3" in sMorph: if _hasConjWithTags(tTags, ":Ip", ":1s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":1s")) if _hasConjWithTags(tTags, ":Ip", ":3s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Ip", ":3s")) if _hasConjWithTags(tTags, ":Is", ":1s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Is", ":1s")) if _hasConjWithTags(tTags, ":Is", ":3s"): aSugg.append(_getConjWithTags(sInfi, tTags, ":Is", ":3s")) elif ":V0a" in sMorph: aSugg.append("eus") aSugg.append("eut") else: aSugg.append("étais") aSugg.append("était") else: if sInfi in _dVerbNames: # there are names derivated from the verb aSugg.extend(_dVerbNames[sInfi]) else: # we suggest past participles aSugg.append(_getConjWithTags(sInfi, tTags, ":PQ", ":Q1")) if _hasConjWithTags(tTags, ":PQ", ":Q2"): aSugg.append(_getConjWithTags(sInfi, tTags, ":PQ", ":Q2")) if _hasConjWithTags(tTags, ":PQ", ":Q3"): aSugg.append(_getConjWithTags(sInfi, tTags, ":PQ", ":Q3")) if _hasConjWithTags(tTags, ":PQ", ":Q4"): aSugg.append(_getConjWithTags(sInfi, tTags, ":PQ", ":Q4")) # if there is only one past participle (epi inv), unreliable. if len(aSugg) == 1: return [] return aSugg def getConjSimilInfiV1 (sInfi): "returns verbal forms phonetically similar to infinitive form (for verb in group 1)" if sInfi not in _dVerb: return [] aSugg = [] tTags = _getTags(sInfi) if tTags: if _hasConjWithTags(tTags, ":Iq", ":2s"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2s")) if _hasConjWithTags(tTags, ":Iq", ":3s"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s")) if _hasConjWithTags(tTags, ":Iq", ":3p"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p")) if _hasConjWithTags(tTags, ":Is", ":1s"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s")) if _hasConjWithTags(tTags, ":Ip", ":2p"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p")) if _hasConjWithTags(tTags, ":Iq", ":2p"): aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2p")) return aSugg def _getTags (sVerb): "returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)" if sVerb not in _dVerb: return None |
︙ | ︙ |
Modified gc_lang/fr/modules/gce_suggestions.py from [1f53e39acb] to [9319456bd1].
︙ | ︙ | |||
19 20 21 22 23 24 25 | return sVerb, sSuffix def suggVerb (sFlex, sWho, funcSugg2=None, bVC=False): "change <sFlex> conjugation according to <sWho>" if bVC: sFlex, sSfx = splitVerb(sFlex) | | | | | | | | | | | | | > | > | > | < | | | | | | | | > | < > | > | > | | | | | | | | | | | | 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | return sVerb, sSuffix def suggVerb (sFlex, sWho, funcSugg2=None, bVC=False): "change <sFlex> conjugation according to <sWho>" if bVC: sFlex, sSfx = splitVerb(sFlex) aSugg = [] for sStem in _oSpellChecker.getLemma(sFlex): tTags = conj._getTags(sStem) if tTags: # we get the tense aTense = {} # we use dict as ordered set for sMorph in _oSpellChecker.getMorph(sFlex): for m in re.finditer(">"+sStem+"/.*?(:(?:Y|I[pqsf]|S[pq]|K|P|Q))", sMorph): # stem must be used in regex to prevent confusion between different verbs (e.g. sauras has 2 stems: savoir and saurer) if m: if m.group(1) == ":Y" or m.group(1) == ":Q": aTense[":Ip"] = "" aTense[":Iq"] = "" aTense[":Is"] = "" elif m.group(1) == ":P": aTense[":Ip"] = "" else: 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): aSugg.append(conj._getConjWithTags(sStem, tTags, sTense, sWho)) if funcSugg2: sSugg2 = funcSugg2(sFlex) if sSugg2: aSugg.append(sSugg2) if aSugg: if bVC: aSugg = [ joinVerbAndSuffix(sSugg, sSfx) for sSugg in aSugg ] return "|".join(aSugg) return "" def joinVerbAndSuffix (sFlex, sSfx): if sSfx.startswith(("-t-", "-T-")) and sFlex.endswith(("t", "d", "T", "D")): return sFlex + sSfx[2:] if sFlex.endswith(("e", "a", "c", "E", "A", "C")): if re.match("(?i)-(?:en|y)$", sSfx): return sFlex + "s" + sSfx if re.match("(?i)-(?:ie?l|elle|on)$", sSfx): return sFlex + "-t" + sSfx return sFlex + sSfx def suggVerbPpas (sFlex, sPattern=None): "suggest past participles for <sFlex>" aSugg = [] for sStem in _oSpellChecker.getLemma(sFlex): tTags = conj._getTags(sStem) if tTags: if not sPattern: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) if conj._hasConjWithTags(tTags, ":PQ", ":Q2"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q2")) if conj._hasConjWithTags(tTags, ":PQ", ":Q3"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q3")) if conj._hasConjWithTags(tTags, ":PQ", ":Q4"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q4")) elif sPattern == ":m:s": aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) elif sPattern == ":m:p": if conj._hasConjWithTags(tTags, ":PQ", ":Q2"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q2")) else: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) elif sPattern == ":f:s": if conj._hasConjWithTags(tTags, ":PQ", ":Q3"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q3")) else: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) elif sPattern == ":f:p": if conj._hasConjWithTags(tTags, ":PQ", ":Q4"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q4")) else: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) elif sPattern == ":s": aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) if conj._hasConjWithTags(tTags, ":PQ", ":Q3"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q3")) elif sPattern == ":p": if conj._hasConjWithTags(tTags, ":PQ", ":Q2"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q2")) else: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) if conj._hasConjWithTags(tTags, ":PQ", ":Q4"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q4")) else: aSugg.append(conj._getConjWithTags(sStem, tTags, ":PQ", ":Q1")) if aSugg: return "|".join(aSugg) return "" def suggVerbTense (sFlex, sTense, sWho): "change <sFlex> to a verb according to <sTense> and <sWho>" aSugg = [] for sStem in _oSpellChecker.getLemma(sFlex): if conj.hasConj(sStem, sTense, sWho): aSugg.append(conj.getConj(sStem, sTense, sWho)) if aSugg: return "|".join(aSugg) return "" def suggVerbFrom (sStem, sFlex, sWho=""): "conjugate <sStem> according to <sFlex> (and eventually <sWho>)" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): lTenses = [ m.group(0) for m in re.finditer(":(?:Y|I[pqsf]|S[pq]|K|P|Q)", sMorph) ] if sWho: for sTense in lTenses: if conj.hasConj(sStem, sTense, sWho): aSugg.append(conj.getConj(sStem, sTense, sWho)) else: for sTense in lTenses: for sWho in [ m.group(0) for m in re.finditer(":[123][sp]", sMorph) ]: if conj.hasConj(sStem, sTense, sWho): aSugg.append(conj.getConj(sStem, sTense, sWho)) if aSugg: return "|".join(aSugg) return "" def suggVerbImpe (sFlex, bVC=False): "change <sFlex> to a verb at imperative form" if bVC: sFlex, sSfx = splitVerb(sFlex) aSugg = [] for sStem in _oSpellChecker.getLemma(sFlex): tTags = conj._getTags(sStem) if tTags: if conj._hasConjWithTags(tTags, ":E", ":2s"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":E", ":2s")) if conj._hasConjWithTags(tTags, ":E", ":1p"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":E", ":1p")) if conj._hasConjWithTags(tTags, ":E", ":2p"): aSugg.append(conj._getConjWithTags(sStem, tTags, ":E", ":2p")) if aSugg: if bVC: aSugg = [ joinVerbAndSuffix(sSugg, sSfx) for sSugg in aSugg ] return "|".join(aSugg) return "" |
︙ | ︙ | |||
178 179 180 181 182 183 184 | elif cMode == ":S": lMode = [":Sp", ":Sq"] elif cMode.startswith((":I", ":S")): lMode = [cMode] else: return "" sWho = _dQuiEst.get(sSuj.lower(), ":3s") | | | | | | | | | | | | | | < | | | | | | | < | | | | | < | | | | | | < | | | | | < | | | | | < | 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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | elif cMode == ":S": lMode = [":Sp", ":Sq"] elif cMode.startswith((":I", ":S")): lMode = [cMode] else: return "" sWho = _dQuiEst.get(sSuj.lower(), ":3s") aSugg = [] for sStem in _oSpellChecker.getLemma(sFlex): tTags = conj._getTags(sStem) if tTags: for sTense in lMode: if conj._hasConjWithTags(tTags, sTense, sWho): aSugg.append(conj._getConjWithTags(sStem, tTags, sTense, sWho)) if aSugg: return "|".join(aSugg) return "" ## Nouns and adjectives def suggPlur (sFlex, bSelfSugg=False): "returns plural forms assuming sFlex is singular" aSugg = [] if sFlex.endswith("l"): if sFlex.endswith("al") and len(sFlex) > 2 and _oSpellChecker.isValid(sFlex[:-1]+"ux"): aSugg.append(sFlex[:-1]+"ux") if sFlex.endswith("ail") and len(sFlex) > 3 and _oSpellChecker.isValid(sFlex[:-2]+"ux"): aSugg.append(sFlex[:-2]+"ux") if sFlex.endswith("L"): if sFlex.endswith("AL") and len(sFlex) > 2 and _oSpellChecker.isValid(sFlex[:-1]+"UX"): aSugg.append(sFlex[:-1]+"UX") if sFlex.endswith("AIL") and len(sFlex) > 3 and _oSpellChecker.isValid(sFlex[:-2]+"UX"): aSugg.append(sFlex[:-2]+"UX") if sFlex[-1:].islower(): if _oSpellChecker.isValid(sFlex+"s"): aSugg.append(sFlex+"s") if _oSpellChecker.isValid(sFlex+"x"): aSugg.append(sFlex+"x") else: if _oSpellChecker.isValid(sFlex+"S"): aSugg.append(sFlex+"S") if _oSpellChecker.isValid(sFlex+"X"): aSugg.append(sFlex+"X") if mfsp.hasMiscPlural(sFlex): aSugg.extend(mfsp.getMiscPlural(sFlex)) if not aSugg and bSelfSugg and sFlex.endswith(("s", "x", "S", "X")): aSugg.append(sFlex) if aSugg: return "|".join(aSugg) return "" def suggSing (sFlex, bSelfSugg=True): "returns singular forms assuming sFlex is plural" aSugg = [] if sFlex.endswith("ux"): if _oSpellChecker.isValid(sFlex[:-2]+"l"): aSugg.append(sFlex[:-2]+"l") if _oSpellChecker.isValid(sFlex[:-2]+"il"): aSugg.append(sFlex[:-2]+"il") if sFlex.endswith("UX"): if _oSpellChecker.isValid(sFlex[:-2]+"L"): aSugg.append(sFlex[:-2]+"L") if _oSpellChecker.isValid(sFlex[:-2]+"IL"): aSugg.append(sFlex[:-2]+"IL") if sFlex.endswith(("s", "x", "S", "X")) and _oSpellChecker.isValid(sFlex[:-1]): aSugg.append(sFlex[:-1]) if bSelfSugg and not aSugg: aSugg.append(sFlex) if aSugg: return "|".join(aSugg) return "" def suggMasSing (sFlex, bSuggSimil=False): "returns masculine singular forms" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): if not ":V" in sMorph: # not a verb if ":m" in sMorph or ":e" in sMorph: aSugg.append(suggSing(sFlex)) else: sStem = cr.getLemmaOfMorph(sMorph) if mfsp.isMasForm(sStem): aSugg.append(sStem) else: # a verb sVerb = cr.getLemmaOfMorph(sMorph) if conj.hasConj(sVerb, ":PQ", ":Q1") and conj.hasConj(sVerb, ":PQ", ":Q3"): # We also check if the verb has a feminine form. # If not, we consider it’s better to not suggest the masculine one, as it can be considered invariable. aSugg.append(conj.getConj(sVerb, ":PQ", ":Q1")) if bSuggSimil: for e in phonet.selectSimil(sFlex, ":m:[si]"): aSugg.append(e) if aSugg: return "|".join(aSugg) return "" def suggMasPlur (sFlex, bSuggSimil=False): "returns masculine plural forms" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): if not ":V" in sMorph: # not a verb if ":m" in sMorph or ":e" in sMorph: aSugg.append(suggPlur(sFlex)) else: sStem = cr.getLemmaOfMorph(sMorph) if mfsp.isMasForm(sStem): aSugg.append(suggPlur(sStem, True)) else: # a verb sVerb = cr.getLemmaOfMorph(sMorph) if conj.hasConj(sVerb, ":PQ", ":Q2"): aSugg.append(conj.getConj(sVerb, ":PQ", ":Q2")) elif conj.hasConj(sVerb, ":PQ", ":Q1"): sSugg = conj.getConj(sVerb, ":PQ", ":Q1") # it is necessary to filter these flexions, like “succédé” or “agi” that are not masculine plural. if sSugg.endswith("s"): aSugg.append(sSugg) if bSuggSimil: for e in phonet.selectSimil(sFlex, ":m:[pi]"): aSugg.append(e) if aSugg: return "|".join(aSugg) return "" def suggFemSing (sFlex, bSuggSimil=False): "returns feminine singular forms" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): if not ":V" in sMorph: # not a verb if ":f" in sMorph or ":e" in sMorph: aSugg.append(suggSing(sFlex)) else: sStem = cr.getLemmaOfMorph(sMorph) if mfsp.isMasForm(sStem): aSugg.extend(mfsp.getFemForm(sStem, False)) else: # a verb sVerb = cr.getLemmaOfMorph(sMorph) if conj.hasConj(sVerb, ":PQ", ":Q3"): aSugg.append(conj.getConj(sVerb, ":PQ", ":Q3")) if bSuggSimil: for e in phonet.selectSimil(sFlex, ":f:[si]"): aSugg.append(e) if aSugg: return "|".join(aSugg) return "" def suggFemPlur (sFlex, bSuggSimil=False): "returns feminine plural forms" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): if not ":V" in sMorph: # not a verb if ":f" in sMorph or ":e" in sMorph: aSugg.append(suggPlur(sFlex)) else: sStem = cr.getLemmaOfMorph(sMorph) if mfsp.isMasForm(sStem): aSugg.extend(mfsp.getFemForm(sStem, True)) else: # a verb sVerb = cr.getLemmaOfMorph(sMorph) if conj.hasConj(sVerb, ":PQ", ":Q4"): aSugg.append(conj.getConj(sVerb, ":PQ", ":Q4")) if bSuggSimil: for e in phonet.selectSimil(sFlex, ":f:[pi]"): aSugg.append(e) if aSugg: return "|".join(aSugg) return "" def g_suggAgree (dTokenDst, dTokenSrc): "returns suggestions for <dTokenDst> that matches agreement with <dTokenSrc>" |
︙ | ︙ | |||
409 410 411 412 413 414 415 | if phonet.hasSimil(sFlex, ":m"): return True return False def switchGender (sFlex, bPlur=None): "return feminine or masculine form(s) of <sFlex>" | | | | | | | | | | | | | | | | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | if phonet.hasSimil(sFlex, ":m"): return True return False def switchGender (sFlex, bPlur=None): "return feminine or masculine form(s) of <sFlex>" aSugg = [] if bPlur is None: for sMorph in _oSpellChecker.getMorph(sFlex): if ":f" in sMorph: if ":s" in sMorph: aSugg.append(suggMasSing(sFlex)) elif ":p" in sMorph: aSugg.append(suggMasPlur(sFlex)) elif ":m" in sMorph: if ":s" in sMorph: aSugg.append(suggFemSing(sFlex)) elif ":p" in sMorph: aSugg.append(suggFemPlur(sFlex)) else: aSugg.append(suggFemSing(sFlex)) aSugg.append(suggFemPlur(sFlex)) elif bPlur: for sMorph in _oSpellChecker.getMorph(sFlex): if ":f" in sMorph: aSugg.append(suggMasPlur(sFlex)) elif ":m" in sMorph: aSugg.append(suggFemPlur(sFlex)) else: for sMorph in _oSpellChecker.getMorph(sFlex): if ":f" in sMorph: aSugg.append(suggMasSing(sFlex)) elif ":m" in sMorph: aSugg.append(suggFemSing(sFlex)) if aSugg: return "|".join(aSugg) return "" def switchPlural (sFlex): "return plural or singular form(s) of <sFlex>" aSugg = [] for sMorph in _oSpellChecker.getMorph(sFlex): if ":s" in sMorph: aSugg.append(suggPlur(sFlex)) elif ":p" in sMorph: aSugg.append(suggSing(sFlex)) if aSugg: return "|".join(aSugg) return "" def hasSimil (sWord, sPattern=None): "return True if there is words phonetically similar to <sWord> (according to <sPattern> if required)" return phonet.hasSimil(sWord, sPattern) def suggSimil (sWord, sPattern=None, bSubst=False, bVC=False): "return list of words phonetically similar to sWord and whom POS is matching sPattern" if bVC: sWord, sSfx = splitVerb(sWord) aSugg = phonet.selectSimil(sWord, sPattern) if not aSugg or not bSubst: for sMorph in _oSpellChecker.getMorph(sWord): aSugg.extend(conj.getSimil(sWord, sMorph, bSubst)) break if aSugg: if bVC: aSugg = [ joinVerbAndSuffix(sSugg, sSfx) for sSugg in aSugg ] return "|".join(aSugg) return "" |
︙ | ︙ |
Modified gc_lang/fr/modules/phonet.py from [cf22067e41] to [5f35e74371].
︙ | ︙ | |||
38 39 40 41 42 43 44 | sWord = sWord.lower() if sWord in _dWord: return _lSet[_dWord[sWord]] return [] def selectSimil (sWord, sPattern): | | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | sWord = sWord.lower() if sWord in _dWord: return _lSet[_dWord[sWord]] return [] def selectSimil (sWord, sPattern): "return a list of words phonetically similar to <sWord> and whom POS is matching <sPattern>" if not sPattern: return getSimil(sWord) aSelect = [] for sSimil in getSimil(sWord): for sMorph in _dMorph.get(sSimil, []): if re.search(sPattern, sMorph): aSelect.append(sSimil) return aSelect def _getSetNumber (sWord): "return the set number where <sWord> belongs, else -1" if sWord in _dWord: return _dWord[sWord] |
︙ | ︙ |