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


Python SparqlQueryBuilder.get_statistics_number_of_triples方法代码示例

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


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

示例1: test_statistics

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import get_statistics_number_of_triples [as 别名]
    def test_statistics(self):
        request = testing.DummyRequest()
        sqb = SparqlQueryBuilder(self.settings, request.session)
        ql = QueryLauncher(self.settings, request.session)

        sqb.get_statistics_number_of_triples()
        sqb.get_statistics_number_of_entities()
        sqb.get_statistics_distinct_classes()
        sqb.get_statistics_list_classes()
        sqb.get_statistics_nb_instances_by_classe()
        sqb.get_statistics_by_startpoint()
        sqb.get_list_named_graphs()
        res = ql.execute_query(sqb.get_list_named_graphs().query)

        for indexResult in range(len(res['results']['bindings'])):
                    sqb.get_delete_query_string(res['results']['bindings'][indexResult]['g']['value'])
                    sqb.get_metadatas(res['results']['bindings'][indexResult]['g']['value'])
开发者ID:cbettemb,项目名称:askomics,代码行数:19,代码来源:sparql_test.py

示例2: statistics

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import get_statistics_number_of_triples [as 别名]
    def statistics(self):
        """ Get information about triplet store """
        self.log.debug("== STATS ==")
        data = {}
        pm = ParamManager(self.settings, self.request.session)

        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        ql = QueryLauncher(self.settings, self.request.session)
        tse = TripleStoreExplorer(self.settings, self.request.session)

        results = ql.process_query(sqb.get_statistics_number_of_triples().query)
        data["ntriples"] = results[0]["no"]

        results = ql.process_query(sqb.get_statistics_number_of_entities().query)
        data["nentities"] = results[0]["no"]

        results = ql.process_query(sqb.get_statistics_distinct_classes().query)
        data["nclasses"] = results[0]["no"]

        # Get the list of classes
        res_list_classes = ql.process_query(sqb.get_statistics_list_classes().query)

        data["class"] = {}
        for obj in res_list_classes:
            class_name = pm.remove_prefix(obj['class'])
            data["class"][class_name] = {}

        # Get the number of instances by class
        res_nb_instances = ql.process_query(sqb.get_statistics_nb_instances_by_classe().query)

        for obj in res_nb_instances:
            if 'class' in obj:
                class_name = pm.remove_prefix(obj['class'])
                data["class"][class_name]["count"] = obj['count']

        # Get details on relations for each classes
        for obj in res_list_classes:
            if 'class' in obj:
                class_name = pm.remove_prefix(obj['class'])
                uri = obj['class']

                shortcuts_list = tse.has_setting(uri, 'shortcut')

                src = Node(class_name, # We don't care about counter in stats
                    uri,
                    class_name,
                    shortcuts_list)

                attributes, nodes, links = tse.get_neighbours_for_node(src, None)

                data["class"][class_name]["attributes"] = [a.to_dict() for a in attributes]
                data["class"][class_name]["neighbours"] = [n.to_dict() for n in nodes]
                data["class"][class_name]["relations"] = [l.to_dict() for l in links]

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

示例3: statistics

# 需要导入模块: from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder [as 别名]
# 或者: from askomics.libaskomics.rdfdb.SparqlQueryBuilder.SparqlQueryBuilder import get_statistics_number_of_triples [as 别名]
    def statistics(self):
        """ Get information about triplet store """
        self.log.debug("== STATS ==")
        data = {}
        pm = ParamManager(self.settings, self.request.session)

        sqb = SparqlQueryBuilder(self.settings, self.request.session)
        ql = QueryLauncher(self.settings, self.request.session)
        tse = TripleStoreExplorer(self.settings, self.request.session)

        results = ql.process_query(sqb.get_statistics_number_of_triples().query)
        resultsGraphs = ql.process_query(sqb.get_statistics_number_of_triples_AskOmics_graphs().query)
        data["ntriples"] = int(results[0]["no"]) + int(resultsGraphs[0]["no"])

        results = ql.process_query(sqb.get_statistics_number_of_entities().query)
        data["nentities"] = results[0]["no"]

        results = ql.process_query(sqb.get_statistics_distinct_classes().query)
        data["nclasses"] = results[0]["no"]

        # Get the number of graphs
        results = ql.process_query(sqb.get_statistics_number_of_graphs().query)
        data["ngraphs"] = results[0]["no"]

        self.log.debug("=== LIST OF METADATAS ")

        # Get the list of named graphs
        namedGraphsResults = ql.execute_query(sqb.get_list_named_graphs().query)

        namedGraphsMetadatas = {}

        # Get a dictionnary containing the metadatas for each graph
        for indexResult in range(len(namedGraphsResults['results']['bindings'])):
            metadatasResults = ql.execute_query(sqb.get_metadatas(namedGraphsResults['results']['bindings'][indexResult]['g']['value']).query)
            metadatas = {}
            for indexMetadatasResults in range(len(metadatasResults['results']['bindings'])):
                if metadatasResults['results']['bindings'][indexMetadatasResults]['p']['value'] == "http://www.w3.org/ns/prov#generatedAtTime":
                    metadatas['loadDate'] = metadatasResults['results']['bindings'][indexMetadatasResults]['o']['value']
                if metadatasResults['results']['bindings'][indexMetadatasResults]['p']['value'] == "http://purl.org/dc/elements/1.1/creator":
                    metadatas['username'] = metadatasResults['results']['bindings'][indexMetadatasResults]['o']['value']
                if metadatasResults['results']['bindings'][indexMetadatasResults]['p']['value'] == "http://purl.org/dc/elements/1.1/hasVersion":
                    metadatas['version'] = metadatasResults['results']['bindings'][indexMetadatasResults]['o']['value']
                if metadatasResults['results']['bindings'][indexMetadatasResults]['p']['value'] == "http://www.w3.org/ns/prov#describesService":
                    metadatas['server'] = metadatasResults['results']['bindings'][indexMetadatasResults]['o']['value']
                if metadatasResults['results']['bindings'][indexMetadatasResults]['p']['value'] == "http://www.w3.org/ns/prov#wasDerivedFrom":
                    metadatas['filename'] = metadatasResults['results']['bindings'][indexMetadatasResults]['o']['value']
            namedGraphsMetadatas[namedGraphsResults['results']['bindings'][indexResult]['g']['value']] = metadatas

        data['metadata'] = namedGraphsMetadatas

        # Get the list of classes
        res_list_classes = ql.process_query(sqb.get_statistics_list_classes().query)

        data["class"] = {}
        for obj in res_list_classes:
            print(obj['class'])
            class_name = pm.remove_prefix(obj['class'])
            print(class_name)
            data["class"][class_name] = {}

        # Get the number of instances by class
        res_nb_instances = ql.process_query(sqb.get_statistics_nb_instances_by_classe().query)

        for obj in res_nb_instances:
            if 'class' in obj:
                print(data['class'])
                class_name = pm.remove_prefix(obj['class'])
                data["class"][class_name]["count"] = obj['count']

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


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