MCPcopy Create free account
hub / github.com/modelscope/modelscope / Trie

Class Trie

modelscope/utils/trie.py:12–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class Trie:
13
14 def __init__(self, eos):
15 self.root = TreeNode()
16 self.eos = eos
17
18 def insert(self, word):
19 cur = self.root
20 for c in word:
21 cur = cur.child[c]
22
23 def get_next_layer(self, word):
24 cur = self.root
25 for c in word:
26 cur = cur.child.get(c)
27 if cur is None:
28 return [self.eos]
29 return list(cur.child.keys())

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…