HermiT推理器显示错误的结果

时间:2014-09-16 18:34:22

标签: java eclipse api owl ontology

我是OWL API的新手。我正在使用来自here的OWL API大量建议的文档。我正在使用同样着名的Pizza.owl。请考虑以下代码段

OWLClass mozzarellaTopping = manager.getOWLDataFactory().getOWLClass(IRI.create(prefix + "CheeseyVegetableTopping"));  
OWLObjectProperty hasOrigin = manager.getOWLDataFactory().getOWLObjectProperty(IRI.create(prefix + "hasCountryOfOrigin"));  

if (hasProperty(manager, reasoner, mozzarellaTopping, hasOrigin)) 
    System.out.println("Instances of " + mozzarellaTopping  + " have a country of origin" + hasOrigin);  
else
    System.out.println("No country of origin does not exist");  

现在“CheeseyVegetableTopping”肯定没有属性“hasCountryOfOrigin”,但if语句将打印出以下内容: -

Instances of <http://localhost:3030/Pizza.owl#CheeseyVegetableTopping> have a country of origin<http://localhost:3030/Pizza.owl#hasCountryOfOrigin>

无论我在推理器中使用哪种Pizza,它都不会出现在上面显示的if中。意味着无论属性是否存在,hasProperty函数都将返回true。来自OWL-API-documentation的助手hasProperty使用完全相同。我不知道我是否应该复制这里。我不是在复制以保持简单。提前谢谢。

1 个答案:

答案 0 :(得分:3)

在这种情况下,你需要仔细看看pizza.owl:

<owl:Class rdf:about="#CheeseyVegetableTopping">
    <rdfs:label xml:lang="pt"
        >CoberturaDeQueijoComVegetais</rdfs:label>
    <rdfs:comment xml:lang="en"
        >This class will be inconsistent. This is because we have given it 2 disjoint parents, which means it could never have any members (as nothing can simultaneously be a CheeseTopping and a VegetableTopping). NB Called ProbeInconsistentTopping in the ProtegeOWL Tutorial.</rdfs:comment>
    <rdfs:subClassOf>
        <owl:Class rdf:about="#CheeseTopping"/>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
        <owl:Class rdf:about="#VegetableTopping"/>
    </rdfs:subClassOf>
</owl:Class>

请注意 CheeseyVegetableTopping 不一致。这意味着它可以有 no 个实例。真的是每个 CheesesyVegetableTopping 都必须有原产国,因为没有反例。也就是说,没有奶酪蔬菜配料有原产国。