Grammalecte  Check-in [b181054462]

Overview
Comment:[graphspell][py] dawg: code clarification
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256: b18105446204be57c08da90bb65cf610471849014c3f5f7789f07b606a0dc374
User & Date: olr on 2018-02-06 10:22:31
Other Links: manifest | tags
Context
2018-02-06
10:23
[graphspell][js] dawg: bug fixing + code clarification check-in: e7f46d5ce1 user: olr tags: graphspell, trunk
10:22
[graphspell][py] dawg: code clarification check-in: b181054462 user: olr tags: graphspell, trunk
2018-02-05
10:34
[graphspell] code consistency check-in: 4414e62e0b user: olr tags: graphspell, trunk
Changes

Modified graphspell/dawg.py from [1a8e51e627] to [a0b57fd216].

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
470
471
472
473
474
475
476
477
478
479
480
481

482
483
484
485
486
487
488
        for aEntry in lWord:
            self.insert(aEntry)
            oProgBar.increment(1)
        oProgBar.done()
        self.finish()
        self.countNodes()
        self.countArcs()
        self.sortNodes()
        self.sortNodeArcs(dValOccur)
        #self.sortNodeArcs2 (self.oRoot, "")
        self.displayInfo()

    # BUILD DAWG
    def insert (self, aEntry):
        if aEntry < self.aPreviousEntry:
................................................................................

    def setPos (self): # version 2
        self.pos = DawgNode.NextPos
        DawgNode.NextPos += 1

    def __str__ (self):
        # Caution! this function is used for hashing and comparison!
        l = []
        if self.final: 
            l.append("1")
        else:
            l.append("0")

        for (key, node) in self.arcs.items():
            l.append(str(key))
            l.append(str(node.i))
        return "_".join(l)

    def __hash__ (self):
        # Used as a key in a python dictionary.







|







 







<
|
<
<
<
>







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
470
471
472
473
474
475
476

477



478
479
480
481
482
483
484
485
        for aEntry in lWord:
            self.insert(aEntry)
            oProgBar.increment(1)
        oProgBar.done()
        self.finish()
        self.countNodes()
        self.countArcs()
        self.sortNodes()         # version 2 and 3 
        self.sortNodeArcs(dValOccur)
        #self.sortNodeArcs2 (self.oRoot, "")
        self.displayInfo()

    # BUILD DAWG
    def insert (self, aEntry):
        if aEntry < self.aPreviousEntry:
................................................................................

    def setPos (self): # version 2
        self.pos = DawgNode.NextPos
        DawgNode.NextPos += 1

    def __str__ (self):
        # Caution! this function is used for hashing and comparison!

        sFinalChar = "1"  if self.final  else "0";



        l = [sFinalChar]
        for (key, node) in self.arcs.items():
            l.append(str(key))
            l.append(str(node.i))
        return "_".join(l)

    def __hash__ (self):
        # Used as a key in a python dictionary.