Grammalecte  Check-in [29e54c7426]

Overview
Comment:[graphspell][js] update for dawg: export as JSON
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256: 29e54c742609084011a70825b98405617c85ba0d84c58a85830b2933405df033
User & Date: olr on 2018-02-07 16:38:17
Other Links: manifest | tags
Context
2018-02-07
16:39
[fx] update: lexicon editor check-in: 00eca59ea8 user: olr tags: fx, trunk
16:38
[graphspell][js] update for dawg: export as JSON check-in: 29e54c7426 user: olr tags: graphspell, trunk
16:15
[graphspell][js] dawg: convert Map to Object when exporting to JSON check-in: e1707a65be user: olr tags: graphspell, trunk
Changes

Modified graphspell-js/dawg.js from [ba2376ee6f] to [a299d0be58].

    24     24           This code is inspired from Steve Hanov’s DAWG, 2011. (http://stevehanov.ca/blog/index.php?id=115)
    25     25           We store suffix/affix codes and tags within the graph after the “real” word.
    26     26           A word is a list of numbers [ c1, c2, c3 . . . cN, iAffix, iTags]
    27     27           Each arc is an index in this.lArcVal, where are stored characters, suffix/affix codes for stemming and tags.
    28     28           Important: As usual, the last node (after ‘iTags’) is tagged final, AND the node after ‘cN’ is ALSO tagged final.
    29     29       */
    30     30   
    31         -    constructor (lEntrySrc, sLangName, cStemming, xProgressBarNode=null) {
           31  +    constructor (lEntrySrc, sLang, cStemming, xProgressBarNode=null) {
    32     32           console.log("===== Direct Acyclic Word Graph - Minimal Acyclic Finite State Automaton =====");
    33     33           let funcStemmingGen = null;
    34     34           switch (cStemming.toUpperCase()) {
    35     35               case "A":
    36     36                   funcStemmingGen = str_transform.defineAffixCode; break;
    37     37               case "S":
    38     38                   funcStemmingGen = str_transform.defineSuffixCode; break;
................................................................................
   100    100           let lKeyVal = [];
   101    101           for (let c of dChar.keys()) { lKeyVal.push([dChar.get(c), dCharOccur.get(c)]); }
   102    102           for (let sAff of dAff.keys()) { lKeyVal.push([dAff.get(sAff)+nChar, dAffOccur.get(sAff)]); }
   103    103           for (let sTag of dTag.keys()) { lKeyVal.push([dTag.get(sTag)+nChar+nAff, dTagOccur.get(sTag)]); }
   104    104           let dValOccur = new Map(lKeyVal);
   105    105           lKeyVal.length = 0; // clear the array
   106    106   
   107         -        this.sLang = sLangName;
          107  +        this.sHeader = "/pyfsa/";
          108  +        this.sLang = sLang;
   108    109           this.nEntry = lWord.length;
   109    110           this.aPreviousEntry = [];
   110    111           oNodeCounter.reset();
   111    112           this.oRoot = new DawgNode();
   112    113           this.lUncheckedNodes = [];          // list of nodes that have not been checked for duplication.
   113    114           this.dMinimizedNodes = new Map();   // list of unique nodes that have been checked for duplication.
   114    115           this.nNode = 0;
................................................................................
   364    365               sByDic = this.oRoot.convToBytes1(this.nBytesArc, this.nBytesNodeAddress);
   365    366               for (let oNode of this.dMinimizedNodes.values()) {
   366    367                   sByDic += oNode.convToBytes1(this.nBytesArc, this.nBytesNodeAddress);
   367    368               }
   368    369           }
   369    370           let oJSON = {
   370    371               "sName": this.sName,
   371         -            "nVersion": this.nMethod,
   372         -            "sHeader": this.sHeader,
          372  +            "nVersion": nMethod,
          373  +            "sHeader": this.sHeader + nMethod + "/",
   373    374               "lArcVal": this.lArcVal,
   374    375               "nArcVal": this.nArcVal,
   375    376               "byDic": sByDic,
   376    377               "sLang": this.sLang,
   377    378               "nChar": this.nChar,
   378    379               "nBytesArc": this.nBytesArc,
   379    380               "nBytesNodeAddress": this.nBytesNodeAddress,