def get_seg_path(self, word):
path = Path(word)
while not path.is_ended():
child = path.get_fringe_word()
parts = child.split("'")
if len(parts) == 2 and len(parts[0]) > 0 and self.lang == 'eng':
path.expand(child, parts[0], 'APOSTR')
else:
parts = child.split('-')
if len(parts) > 1:
p1, p2 = parts[0], child[len(parts[0]) + 1:]
path.expand(child, (p1, p2), 'HYPHEN')
else:
parent, type_ = self.predict(child)
path.expand(child, parent, type_)
return path
评论列表
文章目录