MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Tools/unicode/dawg.py:75–94  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73
74class Dawg:
75 def __init__(self):
76 self.previous_word = ""
77 self.next_id = 0
78 self.root = DawgNode(self)
79
80 # Here is a list of nodes that have not been checked for duplication.
81 self.unchecked_nodes = []
82
83 # To deduplicate, maintain a dictionary with
84 # minimized_nodes[canonical_node] is canonical_node.
85 # Based on __hash__ and __eq__, minimized_nodes[n] is the
86 # canonical node equal to n.
87 # In other words, self.minimized_nodes[x] == x for all nodes found in
88 # the dict.
89 self.minimized_nodes = {}
90
91 # word: value mapping
92 self.data = {}
93 # value: word mapping
94 self.inverse = {}
95
96 def insert(self, word, value):
97 if not all(0 <= ord(c) < 128 for c in word):

Callers

nothing calls this directly

Calls 1

DawgNodeClass · 0.85

Tested by

no test coverage detected