有一天被困住了,有人会帮助他吗? 我加载了一个导入SWEET(地球和环境本体语义网)的本体。我对它做了一些SPARQL查询,我得到了这样的答案:"对象属性hasLowerBound与hasValue限制一起使用,其中值是文字:" 0" ^^整数"。 (hasLowerBound,我在SWEET中检查过,是SWEET中的数据类型本体)
我该如何解决这个问题?
这是我写的代码和我得到的错误,非常感谢你的帮助〜
public class load {
public static void main(String[] args) throws OWLOntologyCreationException {
// Get hold of an ontology manager
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
File file = new File("G:/Protege/owlfiles/Before_Gather.owl");
// Load the local copy
OWLOntology loadMODIS = manager.loadOntologyFromOntologyDocument(file);
PelletReasoner reasoner =
PelletReasonerFactory.getInstance().createNonBufferingReasoner( loadMODIS
);
KnowledgeBase kb = reasoner.getKB();
PelletInfGraph graph = new
org.mindswap.pellet.jena.PelletReasoner().bind( kb );
InfModel model = ModelFactory.createInfModel( graph );
String PREFIX = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-
ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +
"PREFIX seaice: <http://www.semanticweb.org/SeaIceOntology#>" +
"PREFIX repr: <http://sweet.jpl.nasa.gov/2.3/reprDataFormat.owl#>" +
"PREFIX realmCryo: <http://sweet.jpl.nasa.gov/2.3/realmCryo.owl#>" +
"PREFIX relaMath: <http://sweet.jpl.nasa.gov/2.3/relaMath.owl#>";
String SELECT = "select ?dataset ";
String WHERE = "where {" +
"?dataset relaMath:hasLowerBound " + "\"0\"^^xsd:integer" +
"}" ;
QueryExecution qe = SparqlDLExecutionFactory.create(QueryFactory.create(PREFIX + SELECT + WHERE), model);
ResultSet rs = qe.execSelect();
ResultSetFormatter.out(System.out,rs);
rs = null; qe.close();
reasoner.dispose();
//OWLReasonerSPARQLEngine sparqlEngine=new OWLReasonerSPARQLEngine(new MinimalPrintingMonitor());
//sparqlEngine.execQuery(str.toString(),dataset);
System.out.println("Loaded ontology: " + loadMODIS);
}
}
线程中的异常&#34; main&#34; org.mindswap.pellet.exceptions.InternalReasonerException:Object属性hasLowerBound与hasValue限制一起使用,其中值是文字:&#34; 0&#34; ^^整数 在org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.applySomeValuesRule(SomeValuesRule.java:204) 在org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.apply(SomeValuesRule.java:64) 在org.mindswap.pellet.tableau.completion.rule.AbstractTableauRule.apply(AbstractTableauRule.java:64) 在org.mindswap.pellet.tableau.completion.SROIQStrategy.complete(SROIQStrategy.java:157) 在org.mindswap.pellet.ABox.isConsistent(ABox.java:1423) 在org.mindswap.pellet.ABox.isConsistent(ABox.java:1260) 在org.mindswap.pellet.KnowledgeBase.consistency(KnowledgeBase.java:1987) 在org.mindswap.pellet.KnowledgeBase.isConsistent(KnowledgeBase.java:2061) 在org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:258) 在org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:241) 在com.clarkparsia.pellet.sparqldl.jena.SparqlDLExecutionFactory.create(SparqlDLExecutionFactory.java:113) 在com.clarkparsia.pellet.sparqldl.jena.SparqlDLExecutionFactory.create(SparqlDLExecutionFactory.java:261) 在com.clarkparsia.pellet.sparqldl.jena.SparqlDLExecutionFactory.create(SparqlDLExecutionFactory.java:226) 在loadMODIS.load.main(load.java:78)
答案 0 :(得分:0)
hasLowerBound
被解析为数据属性和注释属性。
Pellet正在检查数据属性情况,并假设如果属性不是数据属性,则它必须是对象属性。对于OWL 2本体来说总是如此,但是这个本体并没有被解析为OWL 2兼容本体 - 不允许对注释属性和数据属性进行处罚。
我还不确定问题是在本体还是OWLAPI解析中。
编辑:这是一个解析问题。 hasLowerBound
在relaMath.owl
中声明为{data}属性。但是relaMath.owl
导入reprMath.owl
,它使用hasLowerBound
但未声明它。 reprMath.owl
导入relaMath.owl
,因此存在循环导入。
问题是,在解析过程中:
- 解析relaMath.owl,找到导入,解析reprMath.owl导入;尚未解析任何声明。
- 解析reprMath.owl,找到导入。 relaMath.owl已被解析,因此调用什么都不做。解析reprMath.owl时包含在relaMath.owl中声明的所有实体。问题:尚未解析实体,因此该集合为空。在reprMath中找到hasLowerBound
但尚未存在声明。因此,OWLAPI默认为AnnotationProperty。
- relaMath.owl解析继续,找到声明。
最终结果:任何本体导入relaMath.owl
都会对hasLowerBound
进行非法惩罚。 OWLAPI错误。
解决方法:将数据属性声明添加到reprMath.owl
:
<owl:DatatypeProperty rdf:about="#hasLowerBound"/>
这可能需要在多个本体中完成。