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


Python SparqlQueryBuilder.custom_query方法代碼示例

本文整理匯總了Python中askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder.custom_query方法的典型用法代碼示例。如果您正苦於以下問題:Python SparqlQueryBuilder.custom_query方法的具體用法?Python SparqlQueryBuilder.custom_query怎麽用?Python SparqlQueryBuilder.custom_query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder的用法示例。


在下文中一共展示了SparqlQueryBuilder.custom_query方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_sparql_query_from_json

# 需要導入模塊: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 別名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import custom_query [as 別名]
    def build_sparql_query_from_json(self, fromgraphs, variates, constraintes_relations,limit, send_request_to_tps=True):
        """
        Build a sparql query from JSON constraints
        """

        select = ' '.join(variates)

        sqb = SparqlQueryBuilder(self.settings, self.session)
        query_launcher = QueryLauncher(self.settings, self.session)
        query = self.build_recursive_block('', constraintes_relations)

        # if limit != None and limit > 0:
        #     query += ' LIMIT ' + str(limit)

        if send_request_to_tps:
            results = query_launcher.process_query(sqb.custom_query(fromgraphs, select, query).query)
        else:
            results = []

        return results, sqb.custom_query(fromgraphs, select, query).query
開發者ID:ofilangi,項目名稱:askomics,代碼行數:22,代碼來源:TripleStoreExplorer.py

示例2: build_sparql_query_from_json

# 需要導入模塊: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 別名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import custom_query [as 別名]
    def build_sparql_query_from_json(self,listEndpoints, typeEndpoints, fromgraphs, variates, constraintes_relations,limit, send_request_to_tps=True):
        """
        Build a sparql query from JSON constraints
        """
        if len(typeEndpoints) != len(listEndpoints):
            self.log.warn("listEndpoints:"+str(listEndpoints))
            self.log.warn("typeEndpoints:"+str(typeEndpoints))
            raise ValueError("Devel error. Different size for List Endpoints and List type Endpoints. ")

        select = ' '.join(variates)

        sqb = SparqlQueryBuilder(self.settings, self.session)
        query = self.build_recursive_block('', constraintes_relations)


        # if limit != None and limit > 0:
        #     query += ' LIMIT ' + str(limit)
        self.log.debug("============ build_sparql_query_from_json ========")
        self.log.debug("type_endpoints:"+str(typeEndpoints))
        self.log.debug("endpoints:"+str(listEndpoints))
        self.log.debug("graphs"+str(fromgraphs))

        extreq = False
        typeQuery = ''

        if send_request_to_tps:
            if len(listEndpoints) == 0:
                #raise ValueError("None endpoint are defined fo the current SPARLQ query !")
                query_launcher = QueryLauncher(self.settings, self.session)
            elif len(listEndpoints)==1:
                self.log.debug("============ QueryLauncher ========")

                endpoint = ''
                type_endpoint='askomics'
                if len(listEndpoints) == 1 :
                    endpoint = listEndpoints[0]

                if typeEndpoints[0] != 'askomics':
                    extreq = True

                query_launcher = QueryLauncher(self.settings, self.session,name = endpoint, endpoint = endpoint)
            else:

                self.log.debug("============ FederationQueryLauncher ========")

                typeQuery = '(Federation)'
                lE = []
                iCount = 0

                for i in range(0, len(listEndpoints)):
                    iCount+=1
                    end = {}
                    end['name'] = "endpoint"+str(iCount)
                    end['endpoint'] =  listEndpoints[i]
                    end['askomics'] =  (typeEndpoints[i] == 'askomics')
                    end['auth'] = 'Basic'
                    end['username'] = None
                    end['password'] = None
                    lE.append(end)


                query_launcher = FederationQueryLauncher(self.settings, self.session,lE)
            req = sqb.custom_query(fromgraphs, select, query,externalrequest=extreq).query
            results = query_launcher.process_query(req)
        else:
            results = []

        return results, sqb.custom_query(fromgraphs, select, query).query,typeQuery
開發者ID:abretaud,項目名稱:askomics,代碼行數:70,代碼來源:TripleStoreExplorer.py


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