简体   繁体   English

使用OWL API检索owl:限制

[英]Retrieve owl:restrictions using the OWL API

Good morning, I am working with the OWL API and I am trying to retrieve the data inside of an owl:Restriction. 早上好,我正在使用OWL API,并且正在尝试检索owl:Restriction内部的数据。 For instance, I am using the pizza ontology and I want to get the data for onProperty and someValuesFrom which is a part of 例如,我正在使用披萨本体,我想获取onProperty和someValuesFrom的数据,这是

<owl:Class rdf:about="#American">
   <rdfs:label xml:lang="pt">Americana</rdfs:label>
   <rdfs:subClassOf>
     <owl:Restriction>
       <owl:onProperty rdf:resource="#hasTopping"/>
       <owl:someValuesFrom rdf:resource="#TomatoTopping"/>
     </owl:Restriction>
   </rdfs:subClassOf>
   ...
</owl:Class>

So if I have the American OWLClass, how can I get a list of the OwlRestrictions and the properties it applies to. 因此,如果我拥有美国的OWLClass,如何获得OwlRestrictions及其适用属性的列表。 Something like American -> subClassOf -> Restriction -> onProperty -> hasTopping. 类似于American-> subClassOf-> Restriction-> onProperty-> hasTopping。 Is there a way to create a data structure that has all of these steps in it? 有没有一种创建包含所有这些步骤的数据结构的方法?

I am not sure what exactly you mean by "steps", but I think you have a class and you need all the restrictions that applies to subclasses. 我不确定“步骤”到底是什么意思,但是我认为您有一个类,并且需要适用于子类的所有限制。 However, what will happen if you also want restrictions applied to equivalent classes? 但是,如果您还希望将限制应用于等效类,将会发生什么? Therefore, I thought to write a more general one. 因此,我想写一个更笼统的书。 Here goes: 开始:

    PrefixManager pm= new DefaultPrefixManager("http://www.co-ode.org/ontologies/pizza/pizza.owl#");
    OWLClass american=factory.getOWLClass("American", pm);
    Set<OWLClassAxiom> tempAx=localOntology.getAxioms(american);
    for(OWLClassAxiom ax: tempAx){
        for(OWLClassExpression nce:ax.getNestedClassExpressions())
            if(nce.getClassExpressionType()!=ClassExpressionType.OWL_CLASS)
                System.out.println(ax);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM