简体   繁体   English

使用 OWL API JAVA 从类中获取数据属性

[英]Obtain Data properties from class with OWL API JAVA

I'm trying to get the data properties of a class with the OWL API of java ( http://owlapi.sourceforge.net ) but I can't get it.我正在尝试使用 Java ( http://owlapi.sourceforge.net ) 的 OWL API 获取类的数据属性,但无法获取。

For example The class "person" has a data properties "hasGender" whose range is : {"F"^^xsd:string , "M"^^xsd:string}例如类“person”有一个数据属性“hasGender”,其范围是:{"F"^^xsd:string, "M"^^xsd:string}

    <owl:DatatypeProperty rdf:about="&lico;hasGender">
    <rdfs:domain rdf:resource="&lico;Patient"/>
    <rdfs:range>
        <rdfs:Datatype>
            <owl:oneOf>
                <rdf:Description>
                    <rdf:type rdf:resource="&rdf;List"/>
                    <rdf:first rdf:datatype="&xsd;string">F</rdf:first>
                    <rdf:rest>
                        <rdf:Description>
                            <rdf:type rdf:resource="&rdf;List"/>
                            <rdf:first rdf:datatype="&xsd;string">M</rdf:first>
                            <rdf:rest rdf:resource="&rdf;nil"/>
                        </rdf:Description>
                    </rdf:rest>
                </rdf:Description>
            </owl:oneOf>
        </rdfs:Datatype>
    </rdfs:range>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="&lico;hasName">
    <rdfs:domain rdf:resource="&lico;Patient"/>
    <rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>

I'm trying to get the data types as follows:我正在尝试按如下方式获取数据类型:

    OWLOntologyManager man = OWLManager.createOWLOntologyManager();
    OWLOntology ont;
    OWLDataFactory df = null;
    ont = man.loadOntologyFromOntologyDocument(file);
    df = ont.getOWLOntologyManager().getOWLDataFactory();

    OWLClass clase = df.getOWLClass(Class);

    Set<OWLDatatype> dataType = clase.getDatatypesInSignature();

How could I extract this property and range?我怎样才能提取这个属性和范围?

Thanks in advance!提前致谢!

Classes do not have properties in OWL - what you've tried will get datatype IRIs in the signature of an object, bit as the object is an entity its signature contains only a class IRI.类在 OWL 中没有属性 - 您尝试过的将在对象的签名中获得数据类型 IRI,因为对象是一个实体,它的签名仅包含一个类 IRI。

What you really are looking at is data properties that have the class as part of their domain, so you need to get all data property domain axioms from your ontology (probably including imports) and check if the domain subsumes the class - ie, the class appears in the signature of the axiom, or if you're using a reasoner, whether the class has the domain as a superclass.您真正看到的是将类作为其域的一部分的数据属性,因此您需要从本体中获取所有数据属性域公理(可能包括导入)并检查域是否包含该类 - 即类出现在公理的签名中,或者如果您使用的是推理器,则该类是否将域作为超类。

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

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