当前位置: 首页>>代码示例>>Python>>正文


Python Tree.draw方法代码示例

本文整理汇总了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()
开发者ID:000Nelson000,项目名称:text-analytics-with-python,代码行数:16,代码来源:shallow_parsing.py

示例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):
开发者ID:fmerakos,项目名称:NLTK_sentence_entailments,代码行数:33,代码来源:simple_sentence_to_tree.py


注:本文中的nltk.tree.Tree.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。