當前位置: 首頁>>代碼示例>>Python>>正文


Python Ontology.merge_all方法代碼示例

本文整理匯總了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')
開發者ID:moonwatcher,項目名稱:mp4pack.py,代碼行數:28,代碼來源:material.py

示例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'])
開發者ID:moonwatcher,項目名稱:mp4pack.py,代碼行數:12,代碼來源:queue.py


注:本文中的ontology.Ontology.merge_all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。