本文整理汇总了Python中nltk.Tree.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.draw方法的具体用法?Python Tree.draw怎么用?Python Tree.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.Tree
的用法示例。
在下文中一共展示了Tree.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawTrees
# 需要导入模块: from nltk import Tree [as 别名]
# 或者: from nltk.Tree import draw [as 别名]
def drawTrees(chart):
for state in chart[-1]:
if state.isParse(grammar):
treeString = buildTreeString(state,'')
tree = Tree(treeString)
print 'Showing parse tree. Close window to continue.'
tree.draw()
ans = raw_input('Do you want to see another parse tree?(y/n): ')
if ans == 'n': return
print 'No more valid parses'
示例2: Tree
# 需要导入模块: from nltk import Tree [as 别名]
# 或者: from nltk.Tree import draw [as 别名]
cfd.tabulate()
# <markdowncell>
# ### Missing functionality
#
# #### Head word identification
#
# NLTK has no functionality to identify the head words of phrases. In this noun phrase, 'man' is the head word,
# but it is not straightforward to identify it.
# <codecell>
np = Tree('(NP (D The) (N man) (PP (P with) (NP (D a) (N gun))))')
np.draw()
# <markdowncell>
# # Last words:
#
# ## A tip
#
# Did you know you can add arbitrary attributes to an object instance?
# <codecell>
class MyClass: pass
mc = MyClass()