Index: gc_core/py/lang_core/gc_engine.py ================================================================== --- gc_core/py/lang_core/gc_engine.py +++ gc_core/py/lang_core/gc_engine.py @@ -404,11 +404,11 @@ 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 all(zPattern.search(s) for s in lMorph) + 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)" @@ -431,11 +431,11 @@ lMorph = _oSpellChecker.getMorph(sWord) if not lMorph: return False zPattern = re.compile(sPattern) if bStrict: - return all(zPattern.search(s) for s in lMorph) + 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)" @@ -668,14 +668,16 @@ else: # there is an anti-pattern sPattern, sNegPattern = sRegex.split("¬", 1) if sNegPattern == "*": # all morphologies must match with - if sPattern and all(re.search(sPattern, sMorph) for sMorph in _oSpellChecker.getMorph(dToken["sValue"])): - if bDebug: - print(" MATCH: @" + sRegex) - yield dGraph[dNode[""][sRegex]] + 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[""][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: @@ -1006,10 +1008,12 @@ 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): @@ -1030,10 +1034,13 @@ 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):