Reasoning with data properties

Posted by liam on
URL: http://owlready.306.s1.nabble.com/Reasoning-with-data-properties-tp600.html

Dear Jean-Baptiste,

I have been enjoying using Owlready2 to reason with ontologies generated using Protégé. However, I haven’t fully understood how to create an instance with data properties that gets properly classified. Unfortunately, I’ve been unable to find any documentation or trouble shooting help in the forum, etc.

In the below example, the "LabValue1" instance "TestLabValue1Increased" does not get classified into the class "IncreasedLabValue1" (which it does in Protege, as expected).

Please find the Python script and ontology (in RDF/OWL format) below the signature.

Any advice or help would be appreciated.

Yours sincerely,
Nicolai


Script for classification
```
import owlready2

ontology = owlready2.get_ontology("file:///home/liam/Documents/test.owl").load()
lab_value = ontology['LabValue1']()
lab_value.isOfValue = 5.
owlready2.sync_reasoner()
print(lab_value.__class__)
```

Ontology for classification
```
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/liamchilds/test#"
     xml:base="http://www.semanticweb.org/liamchilds/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:disease_onto="http://www.gotthardt.com/nicolaischoch/disease_onto#">
    <owl:Ontology rdf:about="http://www.semanticweb.org/liamchilds/test"/>
    <owl:DatatypeProperty rdf:about="http://www.gotthardt.com/nicolaischoch/disease_onto#isOfValue">
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
    </owl:DatatypeProperty>
    <owl:Class rdf:about="http://www.semanticweb.org/liamchilds/test#IncreasedLabValue1">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="http://www.semanticweb.org/liamchilds/test#LabValue1"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="http://www.gotthardt.com/nicolaischoch/disease_onto#isOfValue"/>
                        <owl:someValuesFrom>
                            <rdfs:Datatype>
                                <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
                                <owl:withRestrictions rdf:parseType="Collection">
                                    <rdf:Description>
                                        <xsd:minExclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#float">4.0</xsd:minExclusive>
                                    </rdf:Description>
                                </owl:withRestrictions>
                            </rdfs:Datatype>
                        </owl:someValuesFrom>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/liamchilds/test#LabValue1"/>
    </owl:Class>
    <owl:Class rdf:about="http://www.semanticweb.org/liamchilds/test#LabValue"/>
    <owl:Class rdf:about="http://www.semanticweb.org/liamchilds/test#LabValue1">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/liamchilds/test#LabValue"/>
    </owl:Class>
    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/liamchilds/test#TestLabValue1Increased">
        <rdf:type rdf:resource="http://www.semanticweb.org/liamchilds/test#LabValue1"/>
        <disease_onto:isOfValue rdf:datatype="http://www.w3.org/2001/XMLSchema#float">5.0</disease_onto:isOfValue>
    </owl:NamedIndividual>
</rdf:RDF>
```