Grammalecte  Check-in [ed091d83b9]

Overview
Comment:[graphspell][js] fix time calculation for suggestions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | graphspell | nodejs
Files: files | file ages | folders
SHA3-256: ed091d83b9e0e610529ecf3fa6aae4cfcdb538040442aac80f7398e75ecbda9f
User & Date: olr on 2018-10-17 13:30:29
Other Links: branch diff | manifest | tags
Context
2018-10-17
13:43
[njs] Fix some case in cli check-in: e0cae3263f user: IllusionPerdu tags: njs, nodejs
13:30
[graphspell][js] fix time calculation for suggestions check-in: ed091d83b9 user: olr tags: graphspell, nodejs
2018-10-16
10:16
[njs] Add TF option Chg how to set option check-in: ee5d077740 user: IllusionPerdu tags: njs, nodejs
Changes

Modified graphspell-js/ibdawg.js from [4598bbd432] to [820a95ea91].

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
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







-
+















-
+







            }
        }
        return l;
    }

    suggest (sWord, nSuggLimit=10) {
        // returns a array of suggestions for <sWord>
	//console.time("Suggestions for " + sWord + ");
        //console.time("Suggestions for " + sWord);
        sWord = char_player.spellingNormalization(sWord);
        let sPfx = "";
        let sSfx = "";
        [sPfx, sWord, sSfx] = char_player.cut(sWord);
        let nMaxSwitch = Math.max(Math.floor(sWord.length / 3), 1);
        let nMaxDel = Math.floor(sWord.length / 5);
        let nMaxHardRepl = Math.max(Math.floor((sWord.length - 5) / 4), 1);
        let nMaxJump = Math.max(Math.floor(sWord.length / 4), 1);
        let oSuggResult = new SuggResult(sWord);
        this._suggest(oSuggResult, sWord, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump);
        let aSugg = oSuggResult.getSuggestions(nSuggLimit);
        if (sSfx || sPfx) {
            // we add what we removed
            return aSugg.map( (sSugg) => { return sPfx + sSugg + sSfx; } );
        }
	//console.timeEnd("Suggestions for " + sWord + ");
        //console.timeEnd("Suggestions for " + sWord);
        return aSugg;
    }

    _suggest (oSuggResult, sRemain, nMaxSwitch=0, nMaxDel=0, nMaxHardRepl=0, nMaxJump=0, nDist=0, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) {
        // returns a set of suggestions
        // recursive function
        if (sRemain == "") {