Grammalecte  Check-in [cb404dd67a]

Overview
Comment:[core] gc engine: fix morphx()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | mtok
Files: files | file ages | folders
SHA3-256: cb404dd67a4b3f5de292098262359109c95f3b12567c71ffaa01eb0c04f4ed95
User & Date: olr on 2021-03-13 09:53:56
Other Links: branch diff | manifest | tags
Context
2021-03-13
11:34
[fr] ajustements check-in: b62d7a4807 user: olr tags: fr, mtok
09:53
[core] gc engine: fix morphx() check-in: cb404dd67a user: olr tags: core, mtok
08:07
[core][fr] fix getLemmaOfMorph() check-in: 392ae92308 user: olr tags: fr, core, mtok
Changes

Modified gc_core/js/lang_core/gc_functions.js from [f3e99affe4] to [ed16810cd6].

231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245







-
+







            }
        }
    }
    // search sPattern
    return lMorph.some(sMorph  =>  (sMorph.search(sPattern) !== -1));
}

function g_morphx (oToken, sPattern, sNegPattern="", nLeft=null, nRight=null) {
function g_morphx (oToken, sPattern, sNegPattern="") {
    // analyse a multi-token, return True if <sNegPattern> not in morphologies and <sPattern> in morphologies
    if (!oToken.hasOwnProperty("oMultiToken")) {
        return false;
    }
    let lMorph = oToken["oMultiToken"]["lMorph"];
    if (lMorph.length == 0) {
        return false;

Modified gc_core/py/lang_core/gc_engine.py from [a2c2a9d3d4] to [caa8d936e0].

704
705
706
707
708
709
710


711

712
713
714
715
716
717
718
704
705
706
707
708
709
710
711
712

713
714
715
716
717
718
719
720







+
+
-
+







                                    "lTokens": self.lTokens[nTokenStart:nTokenEnd+1],
                                    "lMorph": sAction.split("|")  if sAction else  [":HM"]
                                }
                                self.lTokens[nTokenStart]["nMultiStartTo"] = nTokenEnd
                                self.lTokens[nTokenEnd]["nMultiEndFrom"] = nTokenStart
                                self.lTokens[nTokenStart]["dMultiToken"] = dMultiToken
                                self.lTokens[nTokenEnd]["dMultiToken"] = dMultiToken
                                if bDebug:
                                    echo("    MULTI-TOKEN: ({})  [{}:{}]".format(sAction, self.lTokens[nTokenOffset+1]["sValue"], self.lTokens[nLastToken]["sValue"]))
                                print(dMultiToken)
                                #print(dMultiToken)
                            else:
                                echo("# error: unknown action at " + sLineId)
                        elif cActionType == ">":
                            if bDebug:
                                echo("    COND_BREAK")
                            break
                except Exception as e:

Modified gc_core/py/lang_core/gc_functions.py from [2a974cece8] to [8b75051fd9].

209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223







-
+







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


def g_morphx (dToken, sPattern, sNegPattern):
def g_morphx (dToken, sPattern, sNegPattern=""):
    "analyse a multi-token, return True if <sNegPattern> not in morphologies and <sPattern> in morphologies"
    if not "dMultiToken" in dToken:
        return False
    lMorph = dToken["dMultiToken"]["lMorph"]
    if not lMorph:
        return False
    # check negative condition