如何导航实例方法?

时间:2013-12-12 16:42:43

标签: python tree

我正在使用posStatParser

from stat_parser import Parser, display_tree
parser = Parser()

evaluate =  parser.parse("""    

In it's first elections, Aam Aadmi Party beats Sheila Dixit winning the Delhi Elections.  

""")
print (evaluate.treepositions)

返回:

<bound method Tree.treepositions of Tree(u'S+SBAR', [Tree(u'IN', ['in']), Tree(u'S', [Tree(u'NP', [Tree(u'PRP', ['it'])]), Tree(u'VP', [Tree(u'VBZ', ["'s"]), Tree(u'NP', [Tree(u'JJ', ['first']), Tree(u'NNS', ['elections'])])])]), Tree(u',', [',']), Tree(u'S', [Tree(u'NP', [Tree(u'NNP', ['Aam']), Tree(u'NNP', ['Aadmi'])]), Tree(u'NP', [Tree(u'NNP', ['Party']), Tree(u'NNP', ['beats'])]), Tree(u'NP', [Tree(u'NNP', ['Sheila']), Tree(u'NNP', ['Dixit'])]), Tree(u'VP', [Tree(u'VBG', ['winning']), Tree(u'NP', [Tree(u'DT', ['the']), Tree(u'NNP', ['Delhi']), Tree(u'NNP', ['Elections'])])]), Tree(u'.', ['.'])])])>

如何浏览此实例方法,以便操作各个部分。

1 个答案:

答案 0 :(得分:2)

你的问题毫无意义。你没有“导航”方法。

您实际上从未调用该方法。你所看到的只是班级的__repr__。如果你想要方法返回的实际值,你应该调用它:

values = evaluate.treepositions()