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


Python Node.father方法代码示例

本文整理汇总了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;
开发者ID:ankittare,项目名称:NLP_QuestionGeneration,代码行数:53,代码来源:RDRTree.py

示例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
开发者ID:,项目名称:,代码行数:45,代码来源:


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