Overview
Comment: | [core][bug] in Python all() sends True if the tested list is empty |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core | rg |
Files: | files | file ages | folders |
SHA3-256: |
29cdebf3f5e61ab2d9ad754215f145d5 |
User & Date: | olr on 2018-07-01 08:33:02 |
Other Links: | branch diff | manifest | tags |
Context
2018-07-01
| ||
11:53 | [fr] conversion: regex rules -> graph rules check-in: a67a9dcdd9 user: olr tags: fr, rg | |
08:33 | [core][bug] in Python all() sends True if the tested list is empty check-in: 29cdebf3f5 user: olr tags: core, rg | |
07:50 | [build] DARG: don’t check regex when equal to * (shortcut for nothing except required pattern) check-in: 52c97f487a user: olr tags: build, rg | |
Changes
Modified gc_core/py/lang_core/gc_engine.py from [afcee24576] to [e53fccaf02].
︙ | ︙ | |||
402 403 404 405 406 407 408 | if not tWord: return bNoWord lMorph = dTokenPos[tWord[0]]["lMorph"] if tWord[0] in dTokenPos and "lMorph" in dTokenPos[tWord[0]] else _oSpellChecker.getMorph(tWord[1]) if not lMorph: return False zPattern = re.compile(sPattern) if bStrict: | | | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | if not tWord: return bNoWord lMorph = dTokenPos[tWord[0]]["lMorph"] if tWord[0] in dTokenPos and "lMorph" in dTokenPos[tWord[0]] else _oSpellChecker.getMorph(tWord[1]) if not lMorph: return False zPattern = re.compile(sPattern) if bStrict: return bool(lMorph) and all(zPattern.search(s) for s in lMorph) return any(zPattern.search(s) for s in lMorph) def morphex (dTokenPos, tWord, sPattern, sNegPattern, bNoWord=False): "analyse a tuple (position, word), returns True if not sNegPattern in word morphologies and sPattern in word morphologies (disambiguation on)" if not tWord: return bNoWord |
︙ | ︙ | |||
429 430 431 432 433 434 435 | def analyse (sWord, sPattern, bStrict=True): "analyse a word, return True if sPattern in morphologies (disambiguation off)" lMorph = _oSpellChecker.getMorph(sWord) if not lMorph: return False zPattern = re.compile(sPattern) if bStrict: | | | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | def analyse (sWord, sPattern, bStrict=True): "analyse a word, return True if sPattern in morphologies (disambiguation off)" lMorph = _oSpellChecker.getMorph(sWord) if not lMorph: return False zPattern = re.compile(sPattern) if bStrict: return bool(lMorph) and all(zPattern.search(s) for s in lMorph) return any(zPattern.search(s) for s in lMorph) def analysex (sWord, sPattern, sNegPattern): "analyse a word, returns True if not sNegPattern in word morphologies and sPattern in word morphologies (disambiguation off)" lMorph = _oSpellChecker.getMorph(sWord) if not lMorph: |
︙ | ︙ | |||
666 667 668 669 670 671 672 | print(" MATCH: @" + sRegex) yield dGraph[dNode["<re_morph>"][sRegex]] else: # there is an anti-pattern sPattern, sNegPattern = sRegex.split("¬", 1) if sNegPattern == "*": # all morphologies must match with <sPattern> | > > | | | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | print(" MATCH: @" + sRegex) yield dGraph[dNode["<re_morph>"][sRegex]] else: # there is an anti-pattern sPattern, sNegPattern = sRegex.split("¬", 1) if sNegPattern == "*": # all morphologies must match with <sPattern> if sPattern: lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if lMorph and all(re.search(sPattern, sMorph) for sMorph in lMorph): if bDebug: print(" MATCH: @" + sRegex) yield dGraph[dNode["<re_morph>"][sRegex]] else: if sNegPattern and any(re.search(sNegPattern, sMorph) for sMorph in _oSpellChecker.getMorph(dToken["sValue"])): continue if not sPattern or any(re.search(sPattern, sMorph) for sMorph in _oSpellChecker.getMorph(dToken["sValue"])): if bDebug: print(" MATCH: @" + sRegex) yield dGraph[dNode["<re_morph>"][sRegex]] |
︙ | ︙ | |||
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) else: zNegPattern = re.compile(sNegPattern) if any(zNegPattern.search(sMorph) for sMorph in lMorph): return False # search sPattern | > > | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern if not lMorph: return False zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) else: zNegPattern = re.compile(sNegPattern) if any(zNegPattern.search(sMorph) for sMorph in lMorph): return False # search sPattern |
︙ | ︙ | |||
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | else: lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*": zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) else: zNegPattern = re.compile(sNegPattern) if any(zNegPattern.search(sMorph) for sMorph in lMorph): return False # search sPattern | > > > | 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | else: lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern if not lMorph: return False zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) else: zNegPattern = re.compile(sNegPattern) if any(zNegPattern.search(sMorph) for sMorph in lMorph): return False # search sPattern |
︙ | ︙ |