【问题标题】:Is object property functional?对象属性是否有效?
【发布时间】: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 使用正确的 URI http://www.semanticweb.org/2020/0/test#Q 指定正确的对象属性 - 还有,你确定你加载了正确的本体吗?
  • 是的,我确实加载了正确的本体(检查了两次哈哈),并且我已经更新了第一条消息以更明确地说明我如何导入我的本体(可能与我的问题有关? )
  • 你从未提到本体导入...使用isFunctional,第二个参数是你的本体的导入闭包

标签: owl ontology protege owl-api


【解决方案1】:

要回答关于EntitySearcher::isFunctional 的隐含问题,是的,它会检查输入中接收到的属性是否存在函数属性公理。

我相信你的本体有足够的信息。

提供一个完整的例子:

<?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#" xmlns:test="http://www.semanticweb.org/owlapi/test#">
    <owl:Ontology rdf:about="http://www.semanticweb.org/2020/0/test"/>
    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/owlapi/test#Q">
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
    </owl:ObjectProperty>
    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/owlapi/test#x">
        <test:Q rdf:resource="http://www.semanticweb.org/owlapi/test#y"/>
    </owl:NamedIndividual>
    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/owlapi/test#y"/>
</rdf:RDF>

使用此本体,EntitySearcher 在检查功能属性时返回 true。

编辑:在您更新的问题中,您使用的是kb.axioms(AxiomType),您需要告诉它包含导入。

【讨论】:

  • 试过你的例子——它完美无缺!但在我的情况下,当本体存储为单独的文件(ABox 和 TBox)时,它似乎不起作用。我已更新第一条消息以提供完整代码。
猜你喜欢
  • 1970-01-01
  • 2016-08-10
  • 2010-12-04
  • 2012-01-05
  • 2017-12-11
  • 1970-01-01
  • 1970-01-01
  • 2013-12-26
  • 2015-09-20
相关资源
最近更新 更多