Grammalecte  Diff

Differences From Artifact [9e52227dd2]:

To Artifact [8d220fa67a]:


147
148
149
150
151
152
153














154
155
156
157
158
159
160
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174







+
+
+
+
+
+
+
+
+
+
+
+
+
+







            return False
    # search sPattern
    zPattern = re.compile(sPattern)
    return any(zPattern.search(sMorph)  for sMorph in lMorph)


#### Analyse tokens for graph rules

def g_info (dToken):
    "for debugging: retrieve info of word"
    if not dToken:
        echo("> no token")
        return True
    lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])
    if not lMorph:
        echo("> not in dictionary: " + dToken["sValue"])
        return True
    for sKey, val in dToken.items():
        echo(sKey + ":" + str(val))
    return True


def g_value (dToken, sValues, nLeft=None, nRight=None):
    "test if <dToken['sValue']> is in sValues (each value should be separated with |)"
    sValue = "|"+dToken["sValue"]+"|"  if nLeft is None  else "|"+dToken["sValue"][slice(nLeft, nRight)]+"|"
    if sValue in sValues:
        return True
    if dToken["sValue"][0:2].istitle(): # we test only 2 first chars, to make valid words such as "Laissez-les", "Passe-partout".