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

Method _minimize

Tools/unicode/dawg.py:146–156  ·  view source on GitHub ↗
(self, down_to)

Source from the content-addressed store, hash-verified

144 return self.compute_packed(topoorder), linear_data, inverse
145
146 def _minimize(self, down_to):
147 # proceed from the leaf up to a certain point
148 for i in range(len(self.unchecked_nodes) - 1, down_to - 1, -1):
149 (parent, letter, child) = self.unchecked_nodes[i]
150 if child in self.minimized_nodes:
151 # replace the child with the previously encountered one
152 parent.edges[letter] = self.minimized_nodes[child]
153 else:
154 # add the state to the minimized nodes.
155 self.minimized_nodes[child] = child
156 self.unchecked_nodes.pop()
157
158 def _lookup(self, word):
159 """ Return an integer 0 <= k < number of strings in dawg

Callers 2

insertMethod · 0.95
finishMethod · 0.95

Calls 1

popMethod · 0.45

Tested by

no test coverage detected