Comparing two SPARQL queries in Jena

天大地大妈咪最大 提交于 2019-12-12 02:08:23

问题


I want to know whether two SPARQL queries are logically equivalent, for e.g. suppose I have two queries as follows, how can I know if they are equivalent ?

String query1= "SELECT ?name where { <http://www.example.com/P500> a <http://www.example.com/Parking>; " +
                "<http://www.example.com/name> ?name .}";

        String query2= "SELECT ?name where { <http://www.example.com/P500> <http://www.example.com/name> ?name;" +
                " a <http://www.example.com/Parking> .}";

The codes below doesn't perform a logical comparison:

System.out.println("Compare query pattern");
        System.out.println(q1.getQueryPattern().equalTo(q2.getQueryPattern(),null));

        Op qop1 = Algebra.compile(q1) ;
        Op qop2 = Algebra.compile(q2) ;

        System.out.println("Compare query operator");
        System.out.println(qop1.equalTo(qop2,null));

来源:https://stackoverflow.com/questions/42879509/comparing-two-sparql-queries-in-jena

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!