本文整理匯總了Python中askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder.build_query_on_the_fly方法的典型用法代碼示例。如果您正苦於以下問題:Python SparqlQueryBuilder.build_query_on_the_fly方法的具體用法?Python SparqlQueryBuilder.build_query_on_the_fly怎麽用?Python SparqlQueryBuilder.build_query_on_the_fly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder
的用法示例。
在下文中一共展示了SparqlQueryBuilder.build_query_on_the_fly方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: moStateOnTPS
# 需要導入模塊: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 別名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import build_query_on_the_fly [as 別名]
def moStateOnTPS(self):
'''
check if module files state is saved on the TPS.
if not all modules files are saved with the unchecked status !
'''
sqb = SparqlQueryBuilder(self.settings, self.session)
ql = QueryLauncher(self.settings, self.session)
results = ql.process_query(sqb.build_query_on_the_fly({
'select': '?uri ?module ?comment ?version ?graph ?state',
'from' : [self.graph_modules],
'query': '{\n'+
'?uri rdfs:label ?module .\n'+
'?uri rdfs:comment ?comment .\n'+
'?uri :module_version ?version .\n'+
'?uri :module_state ?state .\n'+
'OPTIONAL { ?uri :module_graph ?graph . } \n'+
'}\n'
}, True).query)
self.log.debug(' ***** module on TPS ***** ')
listMoOnTps = {}
for result in results:
result['checked'] = (result['state'] == "ok")
result['wait'] = (result['state'] == "wait")
listMoOnTps[result['module']] = 0
self.log.debug('module : '+result['module'])
#=======================*************** A ENLEVER *********=======================================
#pour debugger
#if result['wait'] :
# result['wait'] = False
#==============================================================
self.log.debug(' ***** check Available Modules ***** ')
requestAgain = False
for mo in self.moduleFiles:
self.log.debug(" --> module "+mo);
if mo not in listMoOnTps:
self.log.debug(" --====== > new module < =======");
self.importMoSate(self.moduleFiles[mo],'off')
requestAgain = True
if requestAgain :
return False
return results
示例2: generateAbstractAskomicsRDF
# 需要導入模塊: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 別名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import build_query_on_the_fly [as 別名]
def generateAbstractAskomicsRDF(self, graph):
'''
'''
sqb = SparqlQueryBuilder(self.settings, self.session)
ql = QueryLauncher(self.settings, self.session)
results = ql.process_query(sqb.build_query_on_the_fly({
'select': '?entityDom ?entityDomLab ?relation ?entityRan ?entityRanLab',
'query': '{\n'+
'GRAPH ?g { \n' +
'?relation a owl:ObjectProperty.\n'+
'?relation rdfs:domain ?entityDom.\n'+
'?entityDom a owl:Class .\n'+
'OPTIONAL { ?entityDom rdfs:label ?entityDomLab }.\n'+
'?relation rdfs:range ?entityRan .\n'+
'?entityRan a owl:Class .\n'+
'OPTIONAL { ?entityRan rdfs:label ?entityRanLab }.\n'+
'FILTER ( isIRI(?entityDom)).\n ' +
'FILTER ( isIRI(?entityRan)).\n ' +
'}\n'+
'VALUES ?g {<'+graph+'>}'
'}\n'
}, True).query)
entities = {}
attributes = {}
label = {}
for r in results:
if r['entityDom'] not in entities:
entities[r['entityDom']] = {}
if r['entityRan'] not in entities:
entities[r['entityRan']] = {}
entities[r['entityDom']][r['relation']] = r['entityRan']
if ('entityDomLab' in r) and (r['entityDom'] not in label):
if r['entityDomLab'] != '':
label[r['entityDom']] = r['entityDomLab']
if ('entityRanLab' in r) and (r['entityRan'] not in label):
if r['entityRan'] != '':
label[r['entityRan']] = r['entityRanLab']
if len(entities)>0:
values = ""
for ent in entities:
values += '<'+ent+'> '
results = ql.process_query(sqb.build_query_on_the_fly({
'select': '?entity ?attribute ?basetype',
'query': '{\n'+
'GRAPH ?g { \n' +
'?attribute a owl:DatatypeProperty.\n'+
'?attribute rdfs:domain ?entity.\n'+
'?entity a owl:Class .\n'+
'?attribute rdfs:range ?basetype .\n'+
'FILTER ( isIRI(?basetype)).\n ' +
'VALUES ?entity {'+values+'}.\n ' +
'}\n'+
'VALUES ?g {<'+graph+'>}'
'}\n'
}, True).query)
for r in results:
if r['entity'] not in attributes:
attributes[r['entity']] = {}
attributes[r['entity']][r['attribute']] = r['basetype']
rdftab = []
rdftab.append("@prefix displaySetting: <"+self.ASKOMICS_prefix['displaySetting']+">.")
rdftab.append("@prefix rdfs: <"+self.ASKOMICS_prefix['rdfs']+">.")
for ent in entities:
rdftab.append("<"+ent +"> displaySetting:entity \"true\"^^xsd:boolean.")
if ent not in label:
label = ent
idxList = [ label.rfind('#'), label.rfind('/')]
idx = -1
for i in idxList:
if i>idx:
idx=i
if idx>=0:
label = self.escape['text'](self.reverse_prefix(label[:idx+1])+':'+label[idx+1:])
else:
label = self.escape['text'](label)
rdftab.append("<"+ent +"> rdfs:label "+label+"^^xsd:string.")
if len(entities[ent])>0:
rdftab.append("<"+ ent +"> displaySetting:startPoint \"true\"^^xsd:boolean.")
if ent in attributes:
for at in attributes[ent]:
rdftab.append("<"+ at +"> displaySetting:attribute \"true\"^^xsd:boolean.")
return rdftab