Dear Dave, Please show me how to use Pellet with my code. I am totally newbie, I try many way but it it not right way. Please help me. Thank you, Binh
On Wed, Nov 30, 2011 at 4:53 PM, Dave Reynolds <[email protected]>wrote: > On Wed, 2011-11-30 at 12:15 +0100, Tran Thai Binh wrote: > > Dear all, > > I have a problem with inference value. I create two rdf files. One for > > schema, one for data > > For schema rdf file, I create subclass a2 of a1, and one dataproperty p1. > > a2 have definition "a1 and p1 some float[>2]". For data rdf file, I > create > > some instant belongs to class a1 which have property p1. > > > > I want to run reasoner in Jena to get instant of class a2. I expect some > > instant when I query for a2 but Jena returns nothing. I attach rdf files > > and my code below. Could anyone help me to solve problem. > > As explained earlier on jena-dev you need OWL 2 reasoning for your > specific example. > > > At the moment i want to use Pellet as a reasoner but I donnot know how to > > join these two rdf files. Please help me. > > You don't need to "join" those files. You can simply use the Pellet > Reasoner the same way you currently are (bindSchema). > > If you want to join those files in your program you can use Model.add, > for example data.add( schema ). > > The other option is to use owl:imports in your source data document to > import the ontology file and then use the OntModel machinery to handle > the imports for you. > > Dave > > > > > Thank in advance. > > Binh > > > > > > > > *(1) for schema* > > > > <?xml version="1.0"?> > > <!DOCTYPE rdf:RDF [ > > <!ENTITY owl "http://www.w3.org/2002/07/owl#" > > > <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > > > <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > > > <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > > <!ENTITY Ontology1322586150669 " > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#" > > > > ]> > > <rdf:RDF xmlns=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl# > " > > xml:base=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl" > > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > > xmlns:owl="http://www.w3.org/2002/07/owl#" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > xmlns:Ontology1322586150669=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl# > "> > > <owl:Ontology rdf:about=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl > "/> > > <!-- > > ////////////////////////////// > > ////////////////////////////// > > /////////////////////////// > > // > > // Datatypes > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Data properties > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#p1-- > > > > <owl:DatatypeProperty rdf:about="&Ontology1322586150669;p1"/> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Classes > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a1-- > > > > <owl:Class rdf:about="&Ontology1322586150669;a1"/> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a2-- > > > > <owl:Class rdf:about="&Ontology1322586150669;a2"> > > <rdfs:subClassOf> > > <owl:Class> > > <owl:intersectionOf rdf:parseType="Collection"> > > <rdf:Description > rdf:about="&Ontology1322586150669;a1"/> > > <owl:Restriction> > > <owl:onProperty > > rdf:resource="&Ontology1322586150669;p1"/> > > <owl:someValuesFrom> > > <rdfs:Datatype> > > <owl:onDatatype > rdf:resource="&xsd;float"/> > > <owl:withRestrictions > > rdf:parseType="Collection"> > > <rdf:Description> > > <xsd:minExclusive > > rdf:datatype="&xsd;integer">2</xsd:minExclusive> > > </rdf:Description> > > </owl:withRestrictions> > > </rdfs:Datatype> > > </owl:someValuesFrom> > > </owl:Restriction> > > </owl:intersectionOf> > > </owl:Class> > > </rdfs:subClassOf> > > </owl:Class> > > </rdf:RDF> > > <!-- Generated by the OWL API (version 3.2.3.22702) > > http://owlapi.sourceforge.net --> > > > > *(2) for data* > > <?xml version="1.0"?> > > <!DOCTYPE rdf:RDF [ > > <!ENTITY owl "http://www.w3.org/2002/07/owl#" > > > <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > > > <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > > > <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > > <!ENTITY Ontology1322586150669 " > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#" > > > > ]> > > <rdf:RDF xmlns=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.owl# > " > > xml:base=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.owl" > > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > > xmlns:owl="http://www.w3.org/2002/07/owl#" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > xmlns:Ontology1322586150669=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl# > "> > > <owl:Ontology rdf:about=" > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586466073.owl > "/> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Datatypes > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Data properties > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#p1-- > > > > <owl:DatatypeProperty rdf:about="&Ontology1322586150669;p1"/> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Classes > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#a1-- > > > > <owl:Class rdf:about="&Ontology1322586150669;a1"/> > > <!-- > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > // > > // Individuals > > // > > > > > /////////////////////////////////////////////////////////////////////////////////////// > > --> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#c-- > > > > > > <owl:NamedIndividual rdf:about="&Ontology1322586150669;c"> > > <rdf:type rdf:resource="&Ontology1322586150669;a1"/> > > <Ontology1322586150669:p1 > > rdf:datatype="&xsd;float">5</Ontology1322586150669:p1> > > </owl:NamedIndividual> > > <owl:NamedIndividual rdf:about="&Ontology1322586150669;q"> > > <rdf:type rdf:resource="&Ontology1322586150669;a1"/> > > <Ontology1322586150669:p1 > > rdf:datatype="&xsd;float">1</Ontology1322586150669:p1> > > </owl:NamedIndividual> > > <!-- > > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl#rf-- > > > > <owl:NamedIndividual rdf:about="&Ontology1322586150669;rf"> > > <rdf:type rdf:resource="&Ontology1322586150669;a1"/> > > <Ontology1322586150669:p1 > > rdf:datatype="&xsd;float">16</Ontology1322586150669:p1> > > </owl:NamedIndividual> > > </rdf:RDF> > > <!-- Generated by the OWL API (version 3.2.3.22702) > > http://owlapi.sourceforge.net --> > > > > *This is my code in Jena* > > > > package query; > > import com.hp.hpl.jena.query.*; > > import com.hp.hpl.jena.rdf.model.*; > > import com.hp.hpl.jena.reasoner.*; > > import com.hp.hpl.jena.util. > > FileManager; > > > > public class query { > > > > public static void main(String[] args) { > > > > Model schema = FileManager.get().loadModel("O1.owl"); > > Model data = FileManager.get().loadModel("O2.owl"); > > > > Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); > > reasoner = reasoner.bindSchema(schema); > > InfModel infmodel = ModelFactory.createInfModel(reasoner, data); > > > > 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 test: < > > http://www.semanticweb.org/ontologies/2011/10/Ontology1322586150669.owl# > >"+ > > "select ?data " + > > "where {?data a test:a2}"; > > > > Query query = QueryFactory.create(queryString); > > > > System.out.println("----------------------"); > > System.out.println("Query Result Sheet"); > > System.out.println("----------------------"); > > System.out.println("Direct&Indirect Descendants (inf)"); > > System.out.println("-------------------"); > > > > // Execute the query and obtain results > > QueryExecution qe = QueryExecutionFactory.create(query, > > infmodel); > > ResultSet results = qe.execSelect(); > > > > // Output query results > > ResultSetFormatter.out(System.out, results, query); > > > > qe.close(); > > System.out.println("----------------------"); > > > > > > } > > } > > > > > > > > -- Trần Thái Bình GIS and Remote Sensing [email protected] [email protected] Phone: (848) 38247360 mobile: - Việt Nam -
