本文整理汇总了Python中ontology.Ontology.merge_all方法的典型用法代码示例。如果您正苦于以下问题:Python Ontology.merge_all方法的具体用法?Python Ontology.merge_all怎么用?Python Ontology.merge_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ontology.Ontology
的用法示例。
在下文中一共展示了Ontology.merge_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tag
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import merge_all [as 别名]
def tag(self, task):
update = Ontology(self.env, 'ns.medium.resource.meta.tag')
meta = self.meta.project('ns.medium.resource.meta.tag')
knowledge = Ontology(self.env, 'ns.medium.resource.meta.tag', self.knowledge['body'])
genealogy = Ontology(self.env, 'ns.service.genealogy', self.knowledge['head']['genealogy'])
knowledge.merge_all(genealogy)
# Everything that is in meta but doesn't fit knowledge
# should be replaced with the value in knowledge
for i in meta.keys():
if meta[i] != knowledge[i]:
update[i] = knowledge[i]
# Everything that is in knowledge but not in meta
# should be set to the value in knowledge
for i in knowledge.keys():
if i not in meta:
update[i] = knowledge[i]
modify = []
for k,v in update.iteritems():
prototype = update.namespace.find(k)
if prototype and prototype.node['subler']:
modify.append(u'{{{}:{}}}'.format(prototype.node['subler'],v))
print unicode(modify).encode('utf-8')
示例2: set
# 需要导入模块: from ontology import Ontology [as 别名]
# 或者: from ontology.Ontology import merge_all [as 别名]
def set(self):
genealogy = Ontology(self.env, 'ns.service.genealogy', self.document['head']['genealogy'])
genealogy.merge_all(self.ontology['genealogy'])
self.document['head']['genealogy'] = genealogy.node
# persist document
self.env.resolver.save(self.document)
# refetch the document
self.document = self.env.resolver.resolve(self.uri, self.ontology['query'])