Thanks a lot, error is no longer there but not displaying the required
result either i-e instance of StudentExpert class. I, for test case,
created instance of StudentExpert and it display it (so no problem in
ontology) but when I remove the instance, again it display nothing. It
means reasoner not working
.
code is here:

public class Student {
public static void main(String args[])

{

OntModel
model=ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF);
InputStream in= FileManager.get().open("D://Jena/std.owl");
if (in==null) {
throw new IllegalArgumentException( "File: " +  " not there");
}
model.read(in, null);

    * String rule = "[rule1:(?x http://www.semanticweb.org/141#hasResearch
<http://www.semanticweb.org/141#hasResearch> ?y) " +*
*                      "(?x
http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
<http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
http://www.semanticweb.org/141#Phd <http://www.semanticweb.org/141#Phd>)"
+ *

*         "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
<http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
http://www.semanticweb.org/141#StudentExpert)
<http://www.semanticweb.org/141#StudentExpert)>]";*

String str= "Prefix std:<http://www.semanticweb.org/141#> " +
        "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+

        *"Select  *  " + "where {   ?x rdf:type std:StudentExpert  }";*

Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
InfModel inf = ModelFactory.createInfModel(reasoner2, model);

Query query=QueryFactory.create(str);
QueryExecution qe=QueryExecutionFactory.create(query, inf);
ResultSet rs=qe.execSelect();

     ResultSetFormatter.out(System.out, rs, query);
}}

On Tue, Jul 26, 2016 at 2:41 AM, Lorenz B. <
[email protected]> wrote:

> As Dave said, wrong PREFIX declaration.
> >>
> >>          "Select *" + "where {   ?x rdf:type std:StudentExpert  }";
> >>
> Moreover, your String concatenation will lead to
>
> Select *where {   ?x rdf:type std:StudentExpert  }
>
> i.e. there is a missing whitespace before "where".
>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Reply via email to