Grammalecte  Check-in [21d482a03e]

Overview
Comment:[core] morph and analyse: parameters to check slice instead of the full value
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | rg
Files: files | file ages | folders
SHA3-256: 21d482a03e30f568b9755f88eeb4539708ef8cb1285f105309fc05f15226b2aa
User & Date: olr on 2018-06-27 07:35:25
Other Links: branch diff | manifest | tags
Context
2018-06-27
07:42
[fr] mots composés avec -là (utilisation de slice) check-in: 3449bb65ee user: olr tags: fr, rg
07:35
[core] morph and analyse: parameters to check slice instead of the full value check-in: 21d482a03e user: olr tags: core, rg
07:14
[core] morph and analyse: parameters to check slice instead of the full value check-in: 366a0b9969 user: olr tags: core, rg
Changes

Modified gc_core/py/lang_core/gc_engine.py from [c252d197b9] to [ca7f3318b7].

1018
1019
1020
1021
1022
1023
1024

1025



1026
1027
1028
1029
1030
1031
1032
1033
    # search sPattern
    zPattern = re.compile(sPattern)
    return any(zPattern.search(sMorph)  for sMorph in lMorph)


def g_analyse (dToken, sPattern, sNegPattern="", nLeft=None, nRight=None, bMemorizeMorph=True):
    "analyse a token, return True if <sNegPattern> not in morphologies and <sPattern> in morphologies (disambiguation off)"

    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 == "*":
            zPattern = re.compile(sPattern)
            return all(zPattern.search(sMorph)  for sMorph in lMorph)







>
|
>
>
>
|







1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
    # search sPattern
    zPattern = re.compile(sPattern)
    return any(zPattern.search(sMorph)  for sMorph in lMorph)


def g_analyse (dToken, sPattern, sNegPattern="", nLeft=None, nRight=None, bMemorizeMorph=True):
    "analyse a token, return True if <sNegPattern> not in morphologies and <sPattern> in morphologies (disambiguation off)"
    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 == "*":
            zPattern = re.compile(sPattern)
            return all(zPattern.search(sMorph)  for sMorph in lMorph)