Grammalecte  Check-in [bd591492d4]

Overview
Comment:[core] remove useless parameter
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256: bd591492d4fa1ed4a4925238578713c63b94d840e06bb0785291266cc7de783c
User & Date: olr on 2020-11-25 21:38:40
Other Links: manifest | tags
Context
2020-11-25
22:37
[core][fr] rename functions check-in: 55b6bb4791 user: olr tags: trunk, fr, core, build
21:38
[core] remove useless parameter check-in: bd591492d4 user: olr tags: trunk, core
21:26
[core][build][fr] rename functions check-in: e4fab36fc5 user: olr tags: trunk, fr, core, build
Changes

Modified gc_core/js/lang_core/gc_functions.js from [4922b66d6d] to [66aee0aeb8].

347
348
349
350
351
352
353
354

355
356
357
358
359
360
361
362
363
364
365
366
367

368
369

370
371
372
373
374
375
376
377

378
379
380
381
382
383
384
385
386
387
388
389
390

391
392

393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408

409
410
411
412
413
414
415
416
417
418

419
420
421


422
423
424
425
426
427
428

429
430
431
432
433
434
435
436
437
438

439
440

441
442
443
444
445
446
447
448
449
450
347
348
349
350
351
352
353

354
355
356
357
358
359
360
361
362
363
364
365
366

367


368



369
370
371
372

373
374
375
376
377
378
379
380
381
382
383
384
385

386


387



388
389
390
391
392
393
394
395
396
397
398
399

400
401
402
403



404
405
406

407



408
409



410
411
412

413
414
415
416



417
418
419

420


421



422
423
424
425
426
427
428







-
+












-
+
-
-
+
-
-
-




-
+












-
+
-
-
+
-
-
-












-
+



-
-
-



-
+
-
-
-
+
+
-
-
-



-
+



-
-
-



-
+
-
-
+
-
-
-







    }
    return lToken[i];
}


//////// Disambiguator for regex rules

function select (dTokenPos, nPos, sWord, sPattern, lDefault=null) {
function select (dTokenPos, nPos, sWord, sPattern) {
    if (!sWord) {
        return true;
    }
    if (!dTokenPos.has(nPos)) {
        console.log("Error. There should be a token at this position: ", nPos);
        return true;
    }
    let lMorph = gc_engine.oSpellChecker.getMorph(sWord);
    if (lMorph.length === 0  ||  lMorph.length === 1) {
        return true;
    }
    let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 );
    if (lSelect.length > 0) {
    if (lSelect.length > 0 && lSelect.length != lMorph.length) {
        if (lSelect.length != lMorph.length) {
            dTokenPos.get(nPos)["lMorph"] = lSelect;
        dTokenPos.get(nPos)["lMorph"] = lSelect;
        }
    } else if (lDefault) {
        dTokenPos.get(nPos)["lMorph"] = lDefault;
    }
    return true;
}

function exclude (dTokenPos, nPos, sWord, sPattern, lDefault=null) {
function exclude (dTokenPos, nPos, sWord, sPattern) {
    if (!sWord) {
        return true;
    }
    if (!dTokenPos.has(nPos)) {
        console.log("Error. There should be a token at this position: ", nPos);
        return true;
    }
    let lMorph = gc_engine.oSpellChecker.getMorph(sWord);
    if (lMorph.length === 0  ||  lMorph.length === 1) {
        return true;
    }
    let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) === -1 );
    if (lSelect.length > 0) {
    if (lSelect.length > 0 && lSelect.length != lMorph.length) {
        if (lSelect.length != lMorph.length) {
            dTokenPos.get(nPos)["lMorph"] = lSelect;
        dTokenPos.get(nPos)["lMorph"] = lSelect;
        }
    } else if (lDefault) {
        dTokenPos.get(nPos)["lMorph"] = lDefault;
    }
    return true;
}

function define (dTokenPos, nPos, sMorphs) {
    dTokenPos.get(nPos)["lMorph"] = sMorphs.split("|");
    return true;
}


//// Disambiguation for graph rules

function g_select (oToken, sPattern, lDefault=null) {
function g_select (oToken, sPattern) {
    // select morphologies for <oToken> according to <sPattern>, always return true
    let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]);
    if (lMorph.length === 0  || lMorph.length === 1) {
        if (lDefault) {
            oToken["lMorph"] = lDefault;
        }
        return true;
    }
    let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) !== -1 );
    if (lSelect.length > 0) {
    if (lSelect.length > 0 && lSelect.length != lMorph.length) {
        if (lSelect.length != lMorph.length) {
            oToken["lMorph"] = lSelect;
        }
        oToken["lMorph"] = lSelect;
    }
    } else if (lDefault) {
        oToken["lMorph"] = lDefault;
    }
    return true;
}

function g_exclude (oToken, sPattern, lDefault=null) {
function g_exclude (oToken, sPattern) {
    // select morphologies for <oToken> according to <sPattern>, always return true
    let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]);
    if (lMorph.length === 0  || lMorph.length === 1) {
        if (lDefault) {
            oToken["lMorph"] = lDefault;
        }
        return true;
    }
    let lSelect = lMorph.filter( sMorph => sMorph.search(sPattern) === -1 );
    if (lSelect.length > 0) {
    if (lSelect.length > 0 && lSelect.length != lMorph.length) {
        if (lSelect.length != lMorph.length) {
            oToken["lMorph"] = lSelect;
        oToken["lMorph"] = lSelect;
        }
    } else if (lDefault) {
        oToken["lMorph"] = lDefault;
    }
    return true;
}

function g_add_morph (oToken, sNewMorph) {
    // Disambiguation: add a morphology to a token
    let lMorph = (oToken.hasOwnProperty("lMorph")) ? oToken["lMorph"] : gc_engine.oSpellChecker.getMorph(oToken["sValue"]);

Modified gc_core/py/lang_core/gc_functions.py from [1dce18157c] to [2ffbd61317].

294
295
296
297
298
299
300
301

302
303
304
305
306
307
308
309
310
311
312
313
314


315
316
317
318
319
320

321
322
323
324
325
326
327
328
329
330
331
332
333


334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350

351
352
353
354
355
356
357
358
359
360
361


362
363
364
365
366
367
368

369
370
371
372
373
374
375
376
377
378
379


380
381
382
383
384
385
386
387
388
294
295
296
297
298
299
300

301
302
303
304
305
306
307
308
309
310
311



312
313


314
315
316

317
318
319
320
321
322
323
324
325
326
327



328
329


330
331
332
333
334
335
336
337
338
339
340
341
342
343

344
345
346
347



348
349



350
351


352
353
354
355

356
357
358
359



360
361



362
363


364
365
366
367
368
369
370







-
+










-
-
-
+
+
-
-



-
+










-
-
-
+
+
-
-














-
+



-
-
-


-
-
-
+
+
-
-




-
+



-
-
-


-
-
-
+
+
-
-







        return lToken[-1]
    return lToken[i]



#### Disambiguator for regex rules

def select (dTokenPos, nPos, sWord, sPattern, lDefault=None):
def select (dTokenPos, nPos, sWord, sPattern):
    "Disambiguation: select morphologies of <sWord> matching <sPattern>"
    if not sWord:
        return True
    if nPos not in dTokenPos:
        echo("Error. There should be a token at this position: ", nPos)
        return True
    lMorph = _oSpellChecker.getMorph(sWord)
    if not lMorph or len(lMorph) == 1:
        return True
    lSelect = [ sMorph  for sMorph in lMorph  if re.search(sPattern, sMorph) ]
    if lSelect:
        if len(lSelect) != len(lMorph):
            dTokenPos[nPos]["lMorph"] = lSelect
    if lSelect and len(lSelect) != len(lMorph):
        dTokenPos[nPos]["lMorph"] = lSelect
    elif lDefault:
        dTokenPos[nPos]["lMorph"] = lDefault
    return True


def exclude (dTokenPos, nPos, sWord, sPattern, lDefault=None):
def exclude (dTokenPos, nPos, sWord, sPattern):
    "Disambiguation: exclude morphologies of <sWord> matching <sPattern>"
    if not sWord:
        return True
    if nPos not in dTokenPos:
        echo("Error. There should be a token at this position: ", nPos)
        return True
    lMorph = _oSpellChecker.getMorph(sWord)
    if not lMorph or len(lMorph) == 1:
        return True
    lSelect = [ sMorph  for sMorph in lMorph  if not re.search(sPattern, sMorph) ]
    if lSelect:
        if len(lSelect) != len(lMorph):
            dTokenPos[nPos]["lMorph"] = lSelect
    if lSelect and len(lSelect) != len(lMorph):
        dTokenPos[nPos]["lMorph"] = lSelect
    elif lDefault:
        dTokenPos[nPos]["lMorph"] = lDefault
    return True


def define (dTokenPos, nPos, sMorphs):
    "Disambiguation: set morphologies of token at <nPos> with <sMorphs>"
    if nPos not in dTokenPos:
        echo("Error. There should be a token at this position: ", nPos)
        return True
    dTokenPos[nPos]["lMorph"] = sMorphs.split("|")
    return True


#### Disambiguation for graph rules

def g_select (dToken, sPattern, lDefault=None):
def g_select (dToken, sPattern):
    "Disambiguation: select morphologies for <dToken> according to <sPattern>, always return True"
    lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])
    if not lMorph or len(lMorph) == 1:
        if lDefault:
            dToken["lMorph"] = lDefault
            #echo("DA:", dToken["sValue"], dToken["lMorph"])
        return True
    lSelect = [ sMorph  for sMorph in lMorph  if re.search(sPattern, sMorph) ]
    if lSelect:
        if len(lSelect) != len(lMorph):
            dToken["lMorph"] = lSelect
    if lSelect and len(lSelect) != len(lMorph):
        dToken["lMorph"] = lSelect
    elif lDefault:
        dToken["lMorph"] = lDefault
    #echo("DA:", dToken["sValue"], dToken["lMorph"])
    return True


def g_exclude (dToken, sPattern, lDefault=None):
def g_exclude (dToken, sPattern):
    "Disambiguation: select morphologies for <dToken> according to <sPattern>, always return True"
    lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])
    if not lMorph or len(lMorph) == 1:
        if lDefault:
            dToken["lMorph"] = lDefault
            #echo("DA:", dToken["sValue"], dToken["lMorph"])
        return True
    lSelect = [ sMorph  for sMorph in lMorph  if not re.search(sPattern, sMorph) ]
    if lSelect:
        if len(lSelect) != len(lMorph):
            dToken["lMorph"] = lSelect
    if lSelect and len(lSelect) != len(lMorph):
        dToken["lMorph"] = lSelect
    elif lDefault:
        dToken["lMorph"] = lDefault
    #echo("DA:", dToken["sValue"], dToken["lMorph"])
    return True


def g_add_morph (dToken, sNewMorph):
    "Disambiguation: add a morphology to a token"
    lMorph = dToken["lMorph"]  if "lMorph" in dToken  else _oSpellChecker.getMorph(dToken["sValue"])