Grammalecte  Diff

Differences From Artifact [75a3af0350]:

To Artifact [d31e5f26d5]:


425
426
427
428
429
430
431
432

433
434




435


436
437
438
439
440
441
442
425
426
427
428
429
430
431

432
433
434
435
436
437
438

439
440
441
442
443
444
445
446
447







-
+


+
+
+
+
-
+
+







    // Disambiguation: add a morphology to a token
    let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]);
    lMorph.push(...sNewMorph.split("|"));
    oToken["lMorph"] = lMorph;
    return true;
}

function g_rewrite (oToken, sToReplace, sReplace) {
function g_rewrite (oToken, sToReplace, sReplace, bRegEx=false) {
    // Disambiguation: rewrite morphologies
    let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]);
    if (bRegEx) {
        oToken["lMorph"] = lMorph.map(sMorph => sMorph.replace(new RegExp(sToReplace), sReplace));
    }
    else {
    oToken["lMorph"] = lMorph.map(s => s.replace(sToReplace, sReplace));
        oToken["lMorph"] = lMorph.map(sMorph => sMorph.replace(sToReplace, sReplace));
    }
    return true;
}

function g_define (oToken, sMorphs) {
    // set morphologies of <oToken>, always return true
    oToken["lMorph"] = sMorphs.split("|");
    return true;