本文整理汇总了Python中cogent.parse.tree.DndParser.RankNames方法的典型用法代码示例。如果您正苦于以下问题:Python DndParser.RankNames方法的具体用法?Python DndParser.RankNames怎么用?Python DndParser.RankNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.parse.tree.DndParser
的用法示例。
在下文中一共展示了DndParser.RankNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_score_tree
# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import RankNames [as 别名]
def test_score_tree(self):
"""Determine's the tree's fmeasure score"""
# set RankNames and RankNameScores
# if name in RankNames, check score, look at tips, etc
t_str = "(((a,b),(c,d))e,(f,g),h)i;"
t = DndParser(t_str)
t.RankNames = ['i',None,None,None] # 1.0 * 6
t.RankNameScores = [1.0,None,None,None]
t.Children[0].RankNames = [None,'e','foo',None] # 0.5 * 3, 0.6 * 3
t.Children[0].RankNameScores = [None, 0.5, 0.6, None]
t.Children[0].Children[0].RankNames = [None] * 7
t.Children[0].Children[1].RankNames = [None] * 7
t.Children[1].RankNames = [None] * 7
t.Children[1].RankNameScores = [None] * 7
tips = t.tips()
tips[0].Consensus = [None] * 7
tips[1].Consensus = [1,3,None,None]
tips[2].Consensus = [2,4,5,None]
tips[3].Consensus = [None,1,None,None]
tips[4].Consensus = [None,1,None,None]
tips[5].Consensus = [2,None,3,None]
tips[6].Consensus = [None,4,None,None]
decorate_ntips(t)
exp = ((1.0 * 6) + (0.5 * 3) + (0.6 * 3)) / (6 + 3 + 3)
obs = score_tree(t)
self.assertEqual(obs, exp)