0

I've been at this for a few hours now, trying to get Pellet to work with Jenna. Now I finally got to the point it was working. Querying classes and inferenced classes is going well. For example:

SELECT * WHERE { ?x rdf:type uni:Adult}

However when trying to query for a label using this:

SELECT * WHERE { ?x ?y "Vincent"^^xsd:string}

returns:

 org.mindswap.pellet.jena.PelletReasoner@1b13b5d
PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
PREFIX  uni:  <http://localhost/SemanticSearch/semanticsearch.owl#>
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  *
WHERE
  { ?x ?y "Vincent"^^xsd:string }

    {
      "head": {
        "vars": [ "x" , "y" ]
      } ,
      "results": {
        "bindings": [
    mrt 18, 2015 1:06:41 PM org.mindswap.pellet.jena.graph.loader.DefaultGraphLoader addUnsupportedFeature
    WARNING: Unsupported axiom: Ignoring range axiom for AnnotationProperty http://www.w3.org/2000/01/rdf-schema#label
    mrt 18, 2015 1:06:41 PM org.mindswap.pellet.jena.graph.loader.DefaultGraphLoader addUnsupportedFeature
    WARNING: Unsupported axiom: Ignoring range axiom for AnnotationProperty http://localhost/SemanticSearch/semanticsearch.owl#altLabel

        ]
      }
    }

My full code is as follows:

            Model rawModel = ModelFactory.createDefaultModel();
            Reasoner r = PelletReasonerFactory.theInstance().create();
            Model data = FileManager.get().loadModel("file:C:/wamp/www/SemanticSearch/workspace/SemanticSearch/src/semanticsearch.owl");

            InfModel model = ModelFactory.createInfModel(r, data);
            InputStream in = new FileInputStream(new File("C:/wamp/www/SemanticSearch/semanticsearch.owl"));

            System.out.println(model.getReasoner()); 


             String sparqlQueryString1= "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
                 "PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
                     " PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
                     " PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"+
                     " PREFIX uni: <http://localhost/SemanticSearch/semanticsearch.owl#>"+
                     " SELECT * WHERE { ?x ?y \"Vincent\"^^xsd:string}";
                System.out.println(sparqlQueryString1); 


                          Query query = QueryFactory.create(sparqlQueryString1);
                          QueryExecution qexec = QueryExecutionFactory.create(query, model);

                          ResultSet results = qexec.execSelect();
                         //ORGINEEL ResultSetFormatter.out(System.out, results, query);       
                         //ALS RDF ResultSetFormatter.outputAsRDF("", results);    
                          ResultSetFormatter.outputAsJSON(results);
                         qexec.close() ;
        }

Are querying strings not available in Jena? Even not when I'm using Pellet? Is there any other way to query the altlabels of my ontology using Jena and Pellet?

vincent kleine
  • 724
  • 1
  • 6
  • 22

2 Answers2

0

That warning is only saying that the reasoner is ignoring ranges declared on annotation properties. Your query should not be affected by it.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • Yeah that's what I figured, however when I execute the query in Protege or Fuseki server it returns results. Using the exact same query in the java Jena returns 0, while the class query is working – vincent kleine Mar 18 '15 at 11:28
0

Ok, this was kinda stupid. Turned out I accidently exported my ontology using OWL/XML, saving it as RDF/XML fixed this.

vincent kleine
  • 724
  • 1
  • 6
  • 22