Overview
Comment: | [graphspell][js] dawg: select() function |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | graphspell |
Files: | files | file ages | folders |
SHA3-256: |
7f19889b76ffe08960590ae2655ab616 |
User & Date: | olr on 2018-02-09 10:30:35 |
Other Links: | manifest | tags |
Context
2018-02-09
| ||
10:31 | [fx] lexicon editor: graph debugging check-in: e7ea319f54 user: olr tags: trunk, fx | |
10:30 | [graphspell][js] dawg: select() function check-in: 7f19889b76 user: olr tags: trunk, graphspell | |
10:12 | [fr] faux positif: pt: <à le lui Vinf> check-in: 53a5114b97 user: olr tags: trunk, fr | |
Changes
Modified graphspell-js/dawg.js from [fdeac2dc31] to [38b261de93].
︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | 291 292 293 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | console.log("\n * Values:\n"); let i = 0; for (let s of this.lArcVal) { console.log(i + ": " + s); i++; } } * 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, this.oRoot, ""); } * _select1 (zPattern, oNode, sWord) { // recursive generator for (let [nVal, oNextNode] of oNode.arcs.entries()) { if (nVal < this.nChar) { // simple character yield* this._select1(zPattern, oNextNode, sWord + this.lArcVal[nVal]); } else { let sEntry = sWord + "\t" + this.funcStemming(sWord, this.lArcVal[nVal]); for (let [nMorphVal, _] of oNextNode.arcs.entries()) { if (!zPattern || zPattern.test(this.lArcVal[nMorphVal])) { yield sEntry + "\t" + this.lArcVal[nMorphVal]; } } } } } // BINARY CONVERSION createBinary (nMethod) { console.log("Write DAWG as an indexable binary dictionary [method: "+nMethod+"]"); if (nMethod == 1) { this.nBytesArc = Math.floor( (this.nArcVal.toString(2).length + 2) / 8 ) + 1; // We add 2 bits. See DawgNode.convToBytes1() this._calcNumBytesNodeAddress() |
︙ |