MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / Node

Class Node

subtitle/preprocess/langconv.py:39–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37MAPS = {}
38
39class Node(object):
40 def __init__(self, from_word, to_word=None, is_tail=True,
41 have_child=False):
42 self.from_word = from_word
43 if to_word is None:
44 self.to_word = from_word
45 self.data = (is_tail, have_child, from_word)
46 self.is_original = True
47 else:
48 self.to_word = to_word or from_word
49 self.data = (is_tail, have_child, to_word)
50 self.is_original = False
51 self.is_tail = is_tail
52 self.have_child = have_child
53
54 def is_original_long_word(self):
55 return self.is_original and len(self.from_word)>1
56
57 def is_follow(self, chars):
58 return chars != self.from_word[:-1]
59
60 def __str__(self):
61 return '<Node, %s, %s, %s, %s>' % (repr(self.from_word),
62 repr(self.to_word), self.is_tail, self.have_child)
63
64 __repr__ = __str__
65
66class ConvertMap(object):
67 def __init__(self, name, mapping=None):

Callers 1

__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected