-->

Comparing two SPARQL queries in Jena

2019-09-12 16:40发布

问题:

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));
标签: sparql jena