How to make implicit properties explicit

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make implicit properties explicit

Stefan
Hi,

I'm trying to plot my ontology as a graph. For this I need to add explicit property relations for inverse properties.

E.g. I have the following object properties: A, B; A is the inverse of B
And the individuals: Ind1, Ind2

The ontology contains the following information: Ind1 A Ind2

Implicitly, it also contains Ind2 B Ind1. How do I make this explicit?
I tried using the reasoners, which works in Protege, but didn't help in OR2. I also have tried using the new infer_property_values (Even though I don't quite understand what it's supposed to do), but that just gave me an error message.

I also tried exporting my inferred relations from protege somehow, which would be an acceptable workaround, but didn't manage to do that, either.
Reply | Threaded
Open this post in threaded view
|

Re: How to make implicit properties explicit

Jiba
Administrator
Hi,

In ontologies, it is usually common to not store explicitely invert property values (to save space).

What kind of error do you get with infer_property_values ? I think it is the right approach (although I might prevented saving the invert property values for saving space, I need to check that).

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How to make implicit properties explicit

Stefan
Hi,

Thank you for your quick response.

> In ontologies, it is usually common to not store explicitely invert property values (to save space).

As an alternative, a way to query implicit property relations would work, too. I've been using get_properties(), and going with the example above, it would only return A when querying from Ind1, but not B when querying from Ind2.

When trying to use infer_property_values, I get the following error:

Traceback (most recent call last):
  File "<PATH>/main.py", line 106, in <module>
    or2.sync_reasoner(infer_property_values=True)
  File "<PATH>/venv/lib/python3.5/site-packages/owlready2/reasoning.py", line 177, in sync_reasoner_hermit
    a, b = pair[1:-1].split(">, <", 1)
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<PATH>/main.py", line 106, in <module>
    or2.sync_reasoner(infer_property_values=True)
  File "<PATH>/venv/lib/python3.5/site-packages/owlready2/namespace.py", line 666, in __exit__
    Namespace.__exit__(self, exc_type, exc_val, exc_tb)
  File "<PATH>/venv/lib/python3.5/site-packages/owlready2/namespace.py", line 68, in __exit__
    if self.world.graph: self.world.graph.release_write_lock()
  File "<PATH>/venv/lib/python3.5/site-packages/owlready2/triplelite.py", line 373, in release_write_lock
    self.lock.release()
RuntimeError: cannot release un-acquired lock
Reply | Threaded
Open this post in threaded view
|

Re: How to make implicit properties explicit

Jiba
Administrator
Hi,

get_properties() does not return inverse properties, but that was never intended -- it is more a bug or a missing feature.
I fixed it in the development version on Bitbucket : get_properties() now considers inverse properties.

Regarding the reasoning error, could you send me some ontology that I can use to reproduce the problem ?

Best regards,
Jiba

Reply | Threaded
Open this post in threaded view
|

Re: How to make implicit properties explicit

Stefan
Hi,

thanks a lot for the quick fix.

I was able to reproduce the error using the following setup:

Python script:
import owlready2 as or2

o = or2.get_ontology("file://<PATH>.owl").load()

with o:
    or2.sync_reasoner(infer_property_values=True)


OWL file:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#"
     xml:base="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117"
     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#">
    <owl:Ontology rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117"/>
   


   

   


   

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#Prop1"/>
   


   

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#Prop2"/>
   


   

   


   

    <owl:Class rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#A"/>
   


   

    <owl:Class rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#B"/>
   


   

    <owl:Class rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#C"/>
   


   

   


   

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#a"/>
   


   

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#b"/>
   


   

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#c"/>
   


   

    <rdf:Description>
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDisjointClasses"/>
        <owl:members rdf:parseType="Collection">
            <rdf:Description rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#A"/>
            <rdf:Description rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#B"/>
            <rdf:Description rdf:about="http://www.semanticweb.org/stlu/ontologies/2019/1/untitled-ontology-117#C"/>
        </owl:members>
    </rdf:Description>
</rdf:RDF>





Reply | Threaded
Open this post in threaded view
|

Re: How to make implicit properties explicit

Jiba
Administrator
Hi,

There was a bug in the parsing of the HermiT results. I fixed it in the development version. (NB Pellet was not affected by this bug).

Thank you for reporting this problem.

Best regards,
Jiba