本文整理汇总了Python中nltk.draw.util.CanvasWidget.__getitem__方法的典型用法代码示例。如果您正苦于以下问题:Python CanvasWidget.__getitem__方法的具体用法?Python CanvasWidget.__getitem__怎么用?Python CanvasWidget.__getitem__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.draw.util.CanvasWidget
的用法示例。
在下文中一共展示了CanvasWidget.__getitem__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getitem__
# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __getitem__ [as 别名]
def __getitem__(self, attr):
if attr[:5] == 'node_':
return self._nodeattribs.get(attr[5:], None)
elif attr[:5] == 'leaf_':
return self._leafattribs.get(attr[5:], None)
elif attr[:4] == 'loc_':
return self._locattribs.get(attr[4:], None)
elif attr == 'line_color':
return self._line_color
elif attr == 'line_width':
return self._line_width
elif attr == 'roof_color':
return self._roof_color
elif attr == 'roof_fill':
return self._roof_fill
elif attr == 'shapeable':
return self._shapeable
elif attr == 'xspace':
return self._xspace
elif attr == 'yspace':
return self._yspace
elif attr == 'orientation':
return self._orientation
else:
return CanvasWidget.__getitem__(self, attr)
示例2: __getitem__
# 需要导入模块: from nltk.draw.util import CanvasWidget [as 别名]
# 或者: from nltk.draw.util.CanvasWidget import __getitem__ [as 别名]
def __getitem__(self, attr):
if attr == 'roof': return self._roof
elif attr == 'width':
return self.canvas().itemcget(self._polygon, attr)
elif attr == 'color':
return self.canvas().itemcget(self._polygon, 'outline')
elif isinstance(attr, tuple) and attr[0] == 'color':
l = self._lines[int(attr[1])]
return self.canvas().itemcget(l, 'fill')
elif attr == 'xspace': return self._xspace
elif attr == 'yspace': return self._yspace
elif attr == 'orientation':
if self._horizontal: return 'horizontal'
else: return 'vertical'
elif attr == 'ordered':
return self._ordered
else:
return CanvasWidget.__getitem__(self, attr)