我正在和耶娜一起使用佩莱推理器。我将一些数据插入TDB存储。我在一个文件中也有模式本体和Jena规则。我将泛型规则推理器和Pellet分层。然而,由于文本数据类型,我得到了不一致的本体错误,但插入的数据具有和模式定义相同的数据类型。我的数据:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:resource="http://www.cs.kaist.ac.kr/medication/resource#"
xmlns:time="http://www.w3.org/2006/time#"
xmlns:medication="http://www.cs.kaist.ac.kr/medication/ontology#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" >
.......
<rdf:Description rdf:about="http://www.cs.kaist.ac.kr/medication/resource#TimeDesc300">
<rdf:type rdf:resource="http://www.w3.org/2006/time#TimeDescription"/>
<time:hour rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</time:hour>
<time:year rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2014</time:year>
<time:month rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">8</time:month>
<time:day rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">26</time:day>
<time:minute rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</time:minute>
<time:second rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0</time:second>
</rdf:Description>
.......
原因:
.......
TDBConnection connection = new TDBConnection();
connection.getDataset().begin(ReadWrite.WRITE);
Model dataTDB = connection.getDataset().getDefaultModel();
/*OntModel ontology = ModelFactory.createOntologyModel();
ontology.read("data//medtimeOnto.owl");*/
Model ontMedical = FileManager.get().loadModel("data//medtimeOnto.owl");
ontMedical.add(FileManager.get().loadModel("data//myOwnTimeFinal.owl"));
OntModel ontology = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC,
ontMedical );
//Reasoner owlReasoner = (Reasoner) ReasonerRegistry.getOWLReasoner();
//InfModel owlInfModel = ModelFactory.createInfModel(owlReasoner, ontology, dataTDB);
List <Rule> rules= Rule.rulesFromURL("data//testrule.rules");
GenericRuleReasoner ruleReasoner = new GenericRuleReasoner(rules);
InfModel ruleInfModel = ModelFactory.createInfModel(ruleReasoner, ontology,dataTDB);
Reasoner pelletReasoner = PelletReasonerFactory.theInstance().create();
InfModel pelletInfModel = ModelFactory.createInfModel(pelletReasoner, ruleInfModel);
ExtendedIterator<Statement> stmts = pelletInfModel.listStatements().
filterDrop( new Filter<Statement>() {
public boolean accept(Statement o) {
return ontology.add(dataTDB).contains( o );
}
});
Model deductions = ModelFactory.createDefaultModel().add( new StmtIteratorImpl( stmts ));
deductions.write( System.out);
错误正在得到:
............
Realizing finished in 00:00
Exception in thread "main" org.mindswap.pellet.exceptions.InconsistentOntologyException:
Cannot do reasoning with inconsistent ontologies!
Reason for inconsistency: Literal value "2014"^^integer does not belong to datatype integer
at org.mindswap.pellet.KnowledgeBase.ensureConsistency(KnowledgeBase.java:2076)
at org.mindswap.pellet.KnowledgeBase.isSameAs(KnowledgeBase.java:2973)
at rg.mindswap.pellet.jena.graph.query.GraphQueryHandler$94.contains
(GraphQueryHandler.java:1457)
at org.mindswap.pellet.jena.graph.query.GraphQueryHandler.containsTriple
(GraphQueryHandler.java:1554)
at org.mindswap.pellet.jena.PelletInfGraph.containsTriple(PelletInfGraph.java:472)
at org.mindswap.pellet.jena.PelletInfGraph.graphBaseContains(PelletInfGraph.java:319)
at com.hp.hpl.jena.graph.impl.GraphBase.contains(GraphBase.java:301)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.contains(ModelCom.java:1207)
at com.kaist.medserver.MyReasoner$1.accept(MyReasoner.java:63)
at com.kaist.medserver.MyReasoner$1.accept(MyReasoner.java:1)
at com.hp.hpl.jena.util.iterator.FilterDropIterator.accept(FilterDropIterator.java:33)
at com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at com.hp.hpl.jena.util.iterator.Map1Iterator.hasNext(Map1Iterator.java:48)
at com.hp.hpl.jena.util.IteratorCollection.iteratorToList(IteratorCollection.java:63)
at com.hp.hpl.jena.graph.GraphUtil.add(GraphUtil.java:165)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:197)
at com.kaist.medserver.MyReasoner.main(MyReasoner.java:66)
time:year xsd:gYear?不是xsd:intger(或派生类型)。
时间:月是gMonth,时间:日是gDay
http://www.w3.org/TR/owl-time/#summary