本文整理汇总了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)
示例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
示例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)