我是的新手。我正在使用来自这里的OWL广泛建议的文档。我使用的是同样著名的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>无论我在推理机中使用哪一种比萨,如果上面显示的话,它都不会进入其他地方。意味着无论属性是否存在,hasProperty函数都将返回true。助手hasProperty的使用与OWL文档完全相同。我不知道我是否应该在这里复制它。我不是为了保持简单而抄袭。提前谢谢。
发布于 2014-09-17 02:05:09
在这种情况下,您需要更仔细地查看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是不一致的。这意味着不可能出现这种情况。每个CheesesyVegetableTopping都必须有原籍国,这是空泛的事实,因为没有反例。也就是说,没有没有起源国的奶酪蔬菜配料。
https://stackoverflow.com/questions/25876069
复制相似问题