【发布时间】:2020-07-08 10:55:53
【问题描述】:
我正在使用 OWL-API 5 来加载我的本体中的所有对象属性公理,如下所示:
File ontology = new File("examples/ontology.owl");
File individual = new File("examples/individuals.owl");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
IRI documentIRI = IRI.create(ontology);
IRI ontologyIRI = IRI.create("http://www.semanticweb.org/2020/0/test");
SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI);
manager.getIRIMappers().add(mapper);
OWLOntology kb = manager.loadOntologyFromOntologyDocument(individual);
Stream<OWLObjectPropertyAssertionAxiom> objectPropertyAxioms = kb.axioms(AxiomType.OBJECT_PROPERTY_ASSERTION);
objectPropertyAxioms.forEach(axiom -> {
System.out.println("Found object property axiom " + axiom);
OWLIndividual object = axiom.getObject();
OWLIndividual subject = axiom.getSubject();
OWLObjectPropertyExpression property = axiom.getProperty();
});
返回:
Found object property axiom ObjectPropertyAssertion(<http://www.semanticweb.org/2020/0/test#Q> <http://www.semanticweb.org/2020/0/test#x> <http://www.semanticweb.org/2020/0/test#y>)
现在,我想确定该属性是否正常工作。这是我迄今为止尝试过的:
if (EntitySearcher.isFunctional(property, kb)) {
LOGGER.debug("Property " + property + " is declared as functional");
} else {
LOGGER.debug("Property " + property + " is NOT declared as functional");
}
返回:
Property <http://www.semanticweb.org/2020/0/test#Q> is NOT declared as functional
我认为EntitySearcher.isFunctional(p,o) 正在寻找使指定对象属性起作用的functional object property axioms,这在我的本体中似乎不存在(即ontology.axioms(AxiomType.FUNCTIONAL_OBJECT_PROPERTY) 不返回任何内容)。
这就是我的本体中的内容:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/2020/0/test#" xml:base="http://www.semanticweb.org/2020/0/test" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/2020/0/test"/>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/2020/0/test#Q">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
</owl:ObjectProperty>
</rdf:RDF>
个人:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/2020/0/test#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://www.semanticweb.org/2020/0/test"/>
</owl:Ontology>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/2020/0/test#x">
<Q rdf:resource="http://www.semanticweb.org/2020/0/test#y"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/2020/0/test#y"/>
</rdf:RDF>
(这两个文件都是使用 Protegé 5.5.0 创建的)。有什么建议么?谢谢。
【问题讨论】:
-
您为什么认为该属性是功能性的?您的本体中没有这样的公理,也不能由使用演绎推理的标准 OWL 推理器推断出来。如果您正在谈论您的实例数据,其中对于个人
x只有一个这样的属性断言,那么您必须阅读 OWL 中的开放世界假设,即使这不会改变任何东西,您想要的推断也只能实现通过归纳推理,即从具体到一般。只是我的两分钱...... -
要明确,我不是试图推断任何东西,我只是不想读取文件并“提取”功能对象属性公理跨度>
-
但是您调用的方法将适用于给定的示例数据......只要 Java 变量
property使用正确的 URIhttp://www.semanticweb.org/2020/0/test#Q指定正确的对象属性 - 还有,你确定你加载了正确的本体吗? -
是的,我确实加载了正确的本体(检查了两次哈哈),并且我已经更新了第一条消息以更明确地说明我如何导入我的本体(可能与我的问题有关? )
-
你从未提到本体导入...使用
isFunctional,第二个参数是你的本体的导入闭包
标签: owl ontology protege owl-api