有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用SPARQL进行排名?

我有一个问题,我们如何使用SPARQL给出一个秩数?比方说,我有下图中的例子。因此,如果countKonsentrasi的数字最高,则排名为1,依此类推

result

查询我已完成但未满足我的需要:

String queryString =
                "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
                + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
                + "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
                + "SELECT ?e (COUNT (?e) AS ?countKonsentrasi) "
                + " (COUNT (*) AS ?ranking) "
                + " WHERE { ?x rdfs:label  ?a;"
                + " rdfs:subClassOf ?b ."
                + " ?b rdfs:subClassOf owl:Thing ."
                + " ?b rdfs:label ?e ."
                + " FILTER (regex(str(?a), '%s','i')) ."
                + "}"
                + "GROUP BY ?e "
                + "ORDER BY DESC (?countKonsentrasi) ";

SPARQL中是否有类似RANK的排序函数

更新

我尝试了这些新的语法。列ranking显示0个值

String queryString =
                "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
                + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
                + "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
                + "SELECT ?e (COUNT (?e) AS ?countKonsentrasi) "
                + "(COUNT (?countKonsentrasi) AS ?ranking) "
                + " WHERE { ?x rdfs:label  ?a;"
                + " rdfs:subClassOf ?b ."
                + " ?b rdfs:subClassOf owl:Thing ."
                + " ?b rdfs:label ?e ."
                + " FILTER (regex(str(?a), '%s','i')) ."
                + "}"
                + "GROUP BY ?e "
                + "ORDER BY DESC (?countKonsentrasi) LIMIT 5 ";

请帮帮我。我很感激所有的帮助。多谢各位


共 (0) 个答案