Grammalecte  Check-in [fe54076259]

Overview
Comment:[graphspell][js] ibdawg: add select() function
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256: fe540762594466d7b774dfea60e41b4a90cc2f05b4d644e50bd702f1beaa5553
User & Date: olr on 2018-02-07 15:19:52
Other Links: manifest | tags
Context
2018-02-07
16:14
[graphspell][js] dawg: fix bugs in select() check-in: a227ad5a87 user: olr tags: trunk, graphspell
15:19
[graphspell][js] ibdawg: add select() function check-in: fe54076259 user: olr tags: trunk, graphspell
15:19
[graphspell][py] ibdawg: select(), don’t compile pattern if empty check-in: 418b212030 user: olr tags: trunk, graphspell
Changes

Modified graphspell-js/ibdawg.js from [46212759e7] to [6074b8efa8].

379
380
381
382
383
384
385















386


















387
388
389
390
391
392
393
        return aTails;
    }

    // morph (sWord) {
    //     is defined in constructor
    // }
    















    // VERSION 1


















    _morph1 (sWord) {
        // returns morphologies of sWord
        let iAddr = 0;
        for (let c of sWord) {
            if (!this.dChar.has(c)) {
                return [];
            }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
        return aTails;
    }

    // morph (sWord) {
    //     is defined in constructor
    // }
    
    * select (sPattern="") {
        // generator: returns all entries which morphology fits <sPattern>
        let zPattern = null;
        if (sPattern !== "") {
            try {
                zPattern = new RegExp(sPattern);
            }
            catch (e) {
                console.log("Error in regex pattern");
                console.log(e.message);
            }
        }
        yield* this._select1(zPattern, 0, "");
    }

    // VERSION 1

    _select1 (zPattern, iAddr, sWord) {
        // recursive generator
        for (let [nVal, jAddr] of self._getArcs1(iAddr)) {
            if (nVal < this.nChar) {
                // simple character
                yield* self._select1(zPattern, jAddr, sWord + self.lArcVal[nVal])
            } else {
                let sEntry = sWord + "\t" + this.funcStemming(sWord, this.lArcVal[nVal]);
                for (let [nMorphVal, _] of this._getArcs1(jAddr)) {
                    if (!zPattern || zPattern.search(this.lArcVal[nMorphVal])) {
                        yield sEntry + "\t" + this.lArcVal[nMorphVal];
                    }
                }
            }
        }
    }            

    _morph1 (sWord) {
        // returns morphologies of sWord
        let iAddr = 0;
        for (let c of sWord) {
            if (!this.dChar.has(c)) {
                return [];
            }