Overview
| Comment: | [graphspell] JSON data clarification | 
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive | 
| Timelines: | family | ancestors | descendants | both | trunk | graphspell | 
| Files: | files | file ages | folders | 
| SHA3-256: | 
9c995c9f7f391a3d1b05d9489db57137 | 
| User & Date: | olr on 2018-02-11 09:22:51 | 
| Other Links: | manifest | tags | 
Context
| 
   2018-02-11 
 | ||
| 10:20 | [graphspell][build] dawg builder: new parameters + consistency check-in: ac98115a31 user: olr tags: trunk, build, graphspell | |
| 09:22 | [graphspell] JSON data clarification check-in: 9c995c9f7f user: olr tags: trunk, graphspell | |
| 08:31 | [graphspell] better variable name: nVersion -> nCompressionMethod check-in: 702572913c user: olr tags: trunk, graphspell | |
Changes
Modified graphspell-js/dawg.js from [c2ec626548] to [287e75028f].
| ︙ | |||
24 25 26 27 28 29 30  | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  | - +  | 
        This code is inspired from Steve Hanov’s DAWG, 2011. (http://stevehanov.ca/blog/index.php?id=115)
        We store suffix/affix codes and tags within the graph after the “real” word.
        A word is a list of numbers [ c1, c2, c3 . . . cN, iAffix, iTags]
        Each arc is an index in this.lArcVal, where are stored characters, suffix/affix codes for stemming and tags.
        Important: As usual, the last node (after ‘iTags’) is tagged final, AND the node after ‘cN’ is ALSO tagged final.
    */
 | 
| ︙ | |||
100 101 102 103 104 105 106  | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116  | - - + + +  | 
        let lKeyVal = [];
        for (let c of dChar.keys()) { lKeyVal.push([dChar.get(c), dCharOccur.get(c)]); }
        for (let sAff of dAff.keys()) { lKeyVal.push([dAff.get(sAff)+nChar, dAffOccur.get(sAff)]); }
        for (let sTag of dTag.keys()) { lKeyVal.push([dTag.get(sTag)+nChar+nAff, dTagOccur.get(sTag)]); }
        let dValOccur = new Map(lKeyVal);
        lKeyVal.length = 0; // clear the array
 | 
| ︙ | |||
367 368 369 370 371 372 373  | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402  | + + + - + - + - - - - - + - - - + + + + - - - - - + + + + + + +  | 
        if (nCompressionMethod == 1) {
            sByDic = this.oRoot.convToBytes1(this.nBytesArc, this.nBytesNodeAddress);
            for (let oNode of this.dMinimizedNodes.values()) {
                sByDic += oNode.convToBytes1(this.nBytesArc, this.nBytesNodeAddress);
            }
        }
        let oJSON = {
            "sHeader": "/pyfsa/",
            "sLangCode": this.sLangCode,
            "sLangName": this.sLangName,
 | 
| ︙ | 
Modified graphspell-js/ibdawg.js from [80397c1d3c] to [35c6ada92f].
| ︙ | |||
98 99 100 101 102 103 104  | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139  | - + - - + + + + -  | 
            Object.assign(this, oData);
        }
        catch (e) {
            throw Error("# Error. File not found or not loadable.\n" + e.message + "\n");
        }
        /*
            Properties:
 | 
| ︙ | |||
171 172 173 174 175 176 177  | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187  | + - +  | 
        }
        //console.log(this.getInfo());
        this.bOptNumSigle = true;
        this.bOptNumAtLast = false;
    }
    getInfo () {
        return  `  Language: ${this.sLangName}   Lang code: ${this.sLangCode}   Dictionary name: ${this.sDicName}\n` +
 | 
| ︙ | 
Modified graphspell/dawg.py from [1fe1ba5da8] to [8edab9530f].
| ︙ | |||
37 38 39 40 41 42 43  | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  | - +  | 
    """DIRECT ACYCLIC WORD GRAPH"""
    # This code is inspired from Steve Hanov’s DAWG, 2011. (http://stevehanov.ca/blog/index.php?id=115)
    # We store suffix/affix codes and tags within the graph after the “real” word.
    # A word is a list of numbers [ c1, c2, c3 . . . cN, iAffix, iTags]
    # Each arc is an index in self.lArcVal, where are stored characters, suffix/affix codes for stemming and tags.
    # Important: As usual, the last node (after ‘iTags’) is tagged final, AND the node after ‘cN’ is ALSO tagged final.
 | 
| ︙ | |||
98 99 100 101 102 103 104  | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115  | - - + + + +  | 
                        + [ (dAff[aff]+nChar, dAffOccur[aff]) for aff in dAff ] \
                        + [ (dTag[tag]+nChar+nAff, dTagOccur[tag]) for tag in dTag ] )
        #with open(spfSrc[:-8]+".valuesfreq.txt", 'w', encoding='utf-8') as hFreqDst:  # DEBUG
        #    for iKey, nOcc in sorted(dValOccur.items(), key=lambda t: t[1], reverse=True):
        #        hFreqDst.write("{}: {}\n".format(lVal[iKey], nOcc))
        #    hFreqDst.close()
        
 | 
| ︙ | |||
404 405 406 407 408 409 410  | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443  | + + + - + - + + - - + + + + + + + + + + + + - + - - - - - - - - - - - -  | 
            for oNode in self.lSortedNodes:
                byDic += oNode.convToBytes3(self.nBytesArc, self.nBytesNodeAddress, self.nBytesOffset)
        with open(spfDst, "w", encoding="utf-8", newline="\n") as hDst:
            if bInJSModule:
                hDst.write('// JavaScript\n// Generated data (do not edit)\n\n"use strict";\n\nconst dictionary = ')
            hDst.write(json.dumps({
                            "sHeader": "/pyfsa/",
                            "sLangCode": self.sLangCode,
                            "sLangName": self.sLangName,
 | 
| ︙ | |||
468 469 470 471 472 473 474  | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486  | - +  | 
        if not sPathFile.endswith(".bdic"):
            sPathFile += "."+str(nCompressionMethod)+".bdic"
        with open(sPathFile, 'wb') as hDst:
            # header
            hDst.write("/pyfsa/{}/".format(nCompressionMethod).encode("utf-8"))
            hDst.write(b"\0\0\0\0")
            # infos
 | 
| ︙ | |||
516 517 518 519 520 521 522  | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536  | - - - + + +  | 
    def writeResults (self, sPathFile):
        bFileExits = os.path.isfile("_lexicons.res.txt")
        with open("_lexicons.res.txt", "a", encoding='utf-8', newline="\n") as hDst:
            sFormat1 = "{:<12} {:>12} {:>5} {:>8} {:>8} {:>6} {:>8} {:>9} {:>9} {:>15} {:>12} {:>12}\n"
            sFormat2 = "{:<12} {:>12,} {:>5,} {:>8,} {:>8} {:>6,} {:>8,} {:>9,} {:>9,} {:>15,} {:>12,} {:>12,}\n"
            if not bFileExits:
                hDst.write(sFormat1.format("Lexicon", "Entries", "Chars", "Affixes", "Stemming", "Tags", "Values", "Nodes", "Arcs", "Lexicon (Kb)", "Dict (Kb)", "LT Dict (Kb)"))
 | 
| ︙ | 
Modified graphspell/ibdawg.py from [36cdf6641d] to [433de414a7].
| ︙ | |||
151 152 153 154 155 156 157  | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166  | + - +  | 
        else:
            raise ValueError("  # Error: unknown code: {}".format(self.nCompressionMethod))
        self.bOptNumSigle = False
        self.bOptNumAtLast = False
    def getInfo (self):
        return  "  Language: {0.sLangName}   Lang code: {0.sLangCode}   Dictionary name: {0.sDicName}" \
 | 
| ︙ |