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


Python Node.createNode方法代码示例

本文整理汇总了Python中Node.Node.createNode方法的典型用法代码示例。如果您正苦于以下问题:Python Node.createNode方法的具体用法?Python Node.createNode怎么用?Python Node.createNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.createNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createTree

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import createNode [as 别名]
 def createTree(self, wurzel):
     queue = [wurzel]
     this_iteration = []
     results = [wurzel]
     iterator = 0
     while iterator < 3:
         iterator += 1
         for node in queue:
             neighbouries = set()
             for neighbour in Onti.dataDictionary[node.name]:
                 neighbour_node = Node.createNode(neighbour)
                 self.nodes.add(neighbour_node)
                 neighbour_node.neighbours.add(node)
                 neighbouries.add(neighbour_node)
                 if not neighbour_node in results:
                     results.append(neighbour_node)
                     this_iteration.append(neighbour_node)
                     neighbour_node.tree_dictionary[wurzel] = [[node], iterator]
                 else:
                     if not wurzel.name == neighbour_node.name:
                         if neighbour_node.tree_dictionary[wurzel][1] == iterator: #diese vier zeilen braucht man um ggf das tree_dictionary um node zu erweitern
                             neighbour_node.tree_dictionary[wurzel][0].append(node)
             node.neighbours = neighbouries
         queue = this_iteration
         this_iteration = []
     subtree = Tree(results)
     self.raw_trees.append(subtree)
开发者ID:teamSemantik,项目名称:wsd_pageRank,代码行数:29,代码来源:WordNetSearcher.py

示例2: getMeaningsForWord

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import createNode [as 别名]
 def getMeaningsForWord(self, word):
     lemma = word.name
     dict = Onti.indexDictionary
     if lemma in dict:
         for synsetString in dict[lemma]:
             newNode = Node.createNode(synsetString)
             word.synsets.add(newNode)
             self.root_nodes.add(newNode)
             self.nodes.add(newNode)
             
     else:
         word.DeadWord = True
开发者ID:teamSemantik,项目名称:wsd_pageRank,代码行数:14,代码来源:WordNetSearcher.py

示例3: createTrees

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import createNode [as 别名]
 def createTrees(self):
     # should create a tree for each synset
     #nodes = []
     for word in self.inputWords:
         self.getMeaningsForWord(word)
         synsetsForWord = word.synsets
         # for sense in word.synsets:
             # word_bag.append(sense)
         # for node in self.root_nodes:
             # for other_node in node.tree_dictionary.keys():
                 # if not other_node in word_bag:
                     # print "yummi"
         for root in synsetsForWord:
             self.root_nodes.add(root)
             root.neighbours = set(Onti.dataDictionary[root.name])
             for neighbour in root.neighbours:
                 neighbour = Node.createNode(neighbour)
                 neighbour.neighbours.add(root)
             self.createTree(root)
开发者ID:teamSemantik,项目名称:wsd_pageRank,代码行数:21,代码来源:WordNetSearcher.py


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