当前位置: 首页>>代码示例>>Python>>正文


Python SparqlQueryBuilder.load_from_query_json方法代码示例

本文整理汇总了Python中askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder.load_from_query_json方法的典型用法代码示例。如果您正苦于以下问题:Python SparqlQueryBuilder.load_from_query_json方法的具体用法?Python SparqlQueryBuilder.load_from_query_json怎么用?Python SparqlQueryBuilder.load_from_query_json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder的用法示例。


在下文中一共展示了SparqlQueryBuilder.load_from_query_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_print_ids

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import load_from_query_json [as 别名]
    def test_print_ids(self):
        from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder

        request = testing.DummyRequest()

        sqb = SparqlQueryBuilder(self.settings, request.session)

        graph = {'limit': 30, 'return_only_query': False, 'filter_cat': [], 'constraint': [{'type': 'node', 'id': 'entity1', 'uri': 'http://www.semanticweb.org/irisa/ontologies/2016/1/igepp-ontology#entity'}], 'filter_str': [{'id': 'entity1', 'value': 'xxxx'}], 'display': [{'id': 'entity1'}, {}], 'export': 0, 'filter_num': [], 'uploaded': ''}

        query = sqb.load_from_query_json(graph).query

        self.assertIn('?entity1 a :entity .\n\tFILTER (regex(str(?entity1), "xxxx", "i")) .', query)
开发者ID:odameron,项目名称:askomics,代码行数:14,代码来源:sparql_test.py

示例2: launch_query

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import load_from_query_json [as 别名]
    def launch_query(self):
        """ Converts the constraints table created by the graph to a sparql query, send it to the database and compile the results"""
        data = {}
        body = self.request.json_body

        export = bool(int(body['export']))
        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        return_only_query = bool(int(body['return_only_query']))

        if body['uploaded'] != '':
            if export:
                query = body['uploaded'].replace('LIMIT 30', 'LIMIT 10000')
            else:
                query = body['uploaded']
        else:
            query = sqb.load_from_query_json(body).query

        if return_only_query:
            data['query'] = query
            return data

        ql = QueryLauncher(self.settings, self.request.session)
        rb = ResultsBuilder(self.settings, self.request.session)


        results = ql.process_query(query)

        if export:
            data['file'] = ql.format_results_csv(rb.build_csv_table(results))
        else:
            entity_name_list, entity_list_attributes = rb.organize_attribute_and_entity(results, body['constraint'])

            data['results_entity_name'] = entity_name_list
            data['results_entity_attributes'] = entity_list_attributes

            data['results'] = [
                {
                    k: res[k].replace(self.settings["askomics.prefix"], '')
                    for k in res.keys()
                }
                for res in results
            ]

        self.log.debug("== results ==")
        for elt in results:
            self.log.debug(elt)

    #    data['query'] = query

        return data
开发者ID:odameron,项目名称:askomics,代码行数:52,代码来源:ask_view.py


注:本文中的askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder.load_from_query_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。