本文整理汇总了Python中Node.Node.father方法的典型用法代码示例。如果您正苦于以下问题:Python Node.father方法的具体用法?Python Node.father怎么用?Python Node.father使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.father方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: constructTreeFromRulesFile
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import father [as 别名]
def constructTreeFromRulesFile(self, rulesFileP):
'''
#-----------------------------------------------------------
# rdrpostaggerv1.1: New implementation scheme: using FWObject
# Build tree from file containing rules
#-----------------------------------------------------------
'''
self.root = Node(FWObject(False), "NN", None, None, None, [], 0)
currentNode = self.root
currentDepth = 0
rulesFile = open(rulesFileP, "r")
lines = rulesFile.readlines()
for i in xrange(1, len(lines)):
line = lines[i]
depth = 0
for c in line:
if c == '\t':
depth = depth + 1
else:
break
line = line.strip()
if len(line) == 0:
continue
temp = line.find("cc")
if temp == 0:
continue
condition = getCondition(line.split(" : ", 1)[0].strip())
conclusion = getConclusion(line.split(" : ", 1)[1].strip())
node = Node(condition, conclusion, None, None, None, [], depth)
#print line
#print condition.toStr(), conclusion
if depth > currentDepth:
currentNode.exceptChild = node
elif depth == currentDepth:
currentNode.elseChild = node
else:
while currentNode.depth != depth:
currentNode = currentNode.father;
currentNode.elseChild = node
node.father = currentNode;
currentNode = node;
currentDepth = depth;
示例2: constructSCRDRtreeFromRDRfile
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import father [as 别名]
def constructSCRDRtreeFromRDRfile(self, rulesFilePath):
self.root = Node(FWObject(False), "NN", None, None, None, [], 0)
currentNode = self.root
currentDepth = 0
rulesFile = open(rulesFilePath, "r")
lines = rulesFile.readlines()
for i in xrange(1, len(lines)):
line = lines[i]
depth = 0
for c in line:
if c == "\t":
depth = depth + 1
else:
break
line = line.strip()
if len(line) == 0:
continue
temp = line.find("cc")
if temp == 0:
continue
condition = getCondition(line.split(" : ", 1)[0].strip())
conclusion = getConcreteValue(line.split(" : ", 1)[1].strip())
node = Node(condition, conclusion, None, None, None, [], depth)
if depth > currentDepth:
currentNode.exceptChild = node
elif depth == currentDepth:
currentNode.elseChild = node
else:
while currentNode.depth != depth:
currentNode = currentNode.father
currentNode.elseChild = node
node.father = currentNode
currentNode = node
currentDepth = depth