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 @@ -990,16 +990,21 @@ #### Analyse tokens -def g_morph (dToken, sPattern, sNegPattern=""): +def g_morph (dToken, sPattern, sNegPattern="", nLeft=None, nRight=None, bMemorizeMorph=True): "analyse a token, return True if not in morphologies and in morphologies" if "lMorph" in dToken: lMorph = dToken["lMorph"] else: - lMorph = _oSpellChecker.getMorph(dToken["sValue"]) + if nLeft is not None: + lMorph = _oSpellChecker.getMorph(dToken["sValue"][slice(nLeft, nRight)]) + if bMemorizeMorph: + dToken["lMorph"] = lMorph + else: + lMorph = _oSpellChecker.getMorph(dToken["sValue"]) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*": @@ -1013,13 +1018,14 @@ # search sPattern zPattern = re.compile(sPattern) return any(zPattern.search(sMorph) for sMorph in lMorph) -def g_analyse (dToken, sPattern, sNegPattern=""): +def g_analyse (dToken, sPattern, sNegPattern="", nLeft=None, nRight=None, bMemorizeMorph=True): "analyse a token, return True if not in morphologies and in morphologies (disambiguation off)" - lMorph = _oSpellChecker.getMorph(dToken["sValue"]) + sValue = dToken["sValue"] if nLeft is not None else dToken["sValue"][slice(nLeft, nRight)] + lMorph = _oSpellChecker.getMorph(sValue) if not lMorph: return False # check negative condition if sNegPattern: if sNegPattern == "*":