当前位置: 首页>>代码示例>>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;未经允许,请勿转载。