Overview
| Comment: | [graphspell][js] dawg: fix bug in select() |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk | graphspell |
| Files: | files | file ages | folders |
| SHA3-256: |
dd59a31d136e3d951c24f33d4ac95206 |
| User & Date: | olr on 2018-02-09 15:30:00 |
| Other Links: | manifest | tags |
Context
|
2018-02-10
| ||
| 07:53 | [fx] update: lexicon editor check-in: 778321169e user: olr tags: trunk, fx | |
|
2018-02-09
| ||
| 15:30 | [graphspell][js] dawg: fix bug in select() check-in: dd59a31d13 user: olr tags: trunk, graphspell | |
| 15:26 | [graphspell][js] ibdawg: fix bug in select() check-in: 22ff60980a user: olr tags: trunk, graphspell | |
Changes
Modified graphspell-js/dawg.js from [1d70a20f79] to [3e8b9a6207].
| ︙ | ︙ | |||
153 154 155 156 157 158 159 |
}
// BUILD DAWG
insert (aEntry) {
if (aEntry < this.aPreviousEntry) {
throw "Error: Words must be inserted in alphabetical order.";
}
| | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
}
// BUILD DAWG
insert (aEntry) {
if (aEntry < this.aPreviousEntry) {
throw "Error: Words must be inserted in alphabetical order.";
}
// find common prefix between word and previous word
let nCommonPrefix = 0;
for (let i = 0; i < Math.min(aEntry.length, this.aPreviousEntry.length); i++) {
if (aEntry[i] != this.aPreviousEntry[i]) {
break;
}
nCommonPrefix += 1;
|
| ︙ | ︙ | |||
304 305 306 307 308 309 310 |
zPattern = new RegExp(sPattern);
}
catch (e) {
console.log("Error in regex pattern");
console.log(e.message);
}
}
| | | | | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
zPattern = new RegExp(sPattern);
}
catch (e) {
console.log("Error in regex pattern");
console.log(e.message);
}
}
yield* this._select(zPattern, this.oRoot, "");
}
* _select (zPattern, oNode, sWord) {
// recursive generator
for (let [nVal, oNextNode] of oNode.arcs.entries()) {
if (nVal <= this.nChar) {
// simple character
yield* this._select(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];
}
}
|
| ︙ | ︙ |