本文整理汇总了Python中nltk.tree.Tree.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.draw方法的具体用法?Python Tree.draw怎么用?Python Tree.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.tree.Tree
的用法示例。
在下文中一共展示了Tree.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visualize_sentence_tree
# 需要导入模块: from nltk.tree import Tree [as 别名]
# 或者: from nltk.tree.Tree import draw [as 别名]
def visualize_sentence_tree(sentence_tree):
processed_tree = process_sentence_tree(sentence_tree)
processed_tree = [
Tree( item[0],
[
Tree(x[1], [x[0]])
for x in item[1]
]
)
for item in processed_tree
]
tree = Tree('S', processed_tree )
tree.draw()
示例2: Tree
# 需要导入模块: from nltk.tree import Tree [as 别名]
# 或者: from nltk.tree.Tree import draw [as 别名]
the_tree = Tree("sentence", tokenize.sent_tokenize(initial_sentence))
#the_tree.draw()
print(the_tree)
list_of_sentences = []
for i in tokenize.sent_tokenize(initial_sentence):
list_of_sentences.append(tag.pos_tag(tokenize.word_tokenize(i)))
print(list_of_sentences)
x = Tree("ID:50", list_of_sentences)
print(x)
x.draw()
'''
for index, value in enumerate(the_tree):
print("index" + str(index))
print("value" + str(value))
print(tokenize.word_tokenize(the_tree[index]))
the_tree = Tree(tokenize.word_tokenize(the_tree[index]))
the_tree.draw()
'''
'''
print(tokenize.sent_tokenize(initial_sentence))
print("FOR LOOP")
for i in tokenize.sent_tokenize(initial_sentence):