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


Python Tree.draw方法代码示例

本文整理汇总了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'
开发者ID:hillelweintraub,项目名称:NLP,代码行数:12,代码来源:parse.py

示例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()
开发者ID:kawasaki2013,项目名称:archive,代码行数:31,代码来源:nltk_demo.py


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