Problem with really simple queries

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

Problem with really simple queries

Martina
Good afternoon,

I have a problem with simple queries like subclass_of, is_a, type, etc.
I have created the ontology in the Protege 5 (rdf/xml syntax). It is about autoimmune diseases.
I can see that my Ontology IRI is http://www.autoimmunediseases-ontology/ in the Protege tab. Classes have the same IRI as ontology, ... of course ... the end of their IRI is different according to the name of the class, etc. My goal is to print all subclasses of the class named Symptom. This class has the following IRI http://www.autoimmunediseases-ontology/Symptom.

I wrote the following code with the Owlready2 and Python 3 where the first three printing methods are only for testing purposes:
.........................................................................................
from owlready2 import *

onto = get_ontology("file://C:\Temp\AD-OWLOntology-aciids2019-rdf-xmlSyntax.owl").load()
print(onto) #output: get_ontology("http://www.autoimmunediseases-ontology/")
print(onto.Symptom) #output:c:\Temp\AD-OWLOntology-aciids2019-rdf-xmlSyntax.Symptom
print(onto.Symptom.iri)  #output: http://www.autoimmunediseases-ontology/Symptom

onto.search(subclass_of = onto.Symptom)
..........................................................................................

The output of the above mentioned code is that nothing is displayed, but I am sure that the Symptom class has 10 subclasses. I feel that the problem can be in the namespaces, but I am not sure. I have already read everything about namespaces and Owlready, but this did not help me.

I would be very very glad for any feedback.
Thank you a lot in advance.

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

Re: Problem with really simple queries

mafi
Doesn’t search return instances though?  If you want to look at classes just do it from Protoge.  For your search to work, create some instances of the classes you are interested in.

Reply | Threaded
Open this post in threaded view
|

Re: Problem with really simple queries

Jiba
Administrator
In reply to this post by Martina
Hello,

.search() can find any entity, including individuals and classes.

I've started investigating your problem, and I found some bugs related to ontologies whose IRI ends with /(which is your case). I fixed those bugs in the development version on BitBucket, could you try it ?

It it still don't work, please send me your ontology (or at least a small part).

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

Re: Problem with really simple queries

Martina
Good afternoon,

thank you very much for your fast feedback!
I tried to instal the new version of the OWLReady2 (https://bitbucket.org/jibalamy/owlready2/overview). The problem still exist, but one difference occurred. The following error appeared: "TypeError: descriptor '_obj' for 'CallbackList' objects doesn't apply to 'CallbackList' object."
I am sending my small ontology about autoimmune diseases (AD-OWLOntology-rdf-xml-jiba.owl) to you.
I would be very glad for any feedback. Maybe, I make mistake somewhere, but I do not know where :-( :-)
Ontology was developed in the Protégé 5.2.0. I use the Anaconda software for working with the OWLReady2.

Best regards and many thanks for any help,
Martina

AD-OWLOntology-rdf-xml-jiba.owl 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with really simple queries

Martina
In reply to this post by mafi
Good afternoon,

thank you for your feedback! If I look into the documentation (https://pythonhosted.org/Owlready2/onto.html#simple-queries) there is the information that search() method with the subclass_of keyword should search subclasses of the particular class. The symptom class has several subclasses in my ontology, but the search method did not search them.

I would like not to use the Protégé, because I would like to build own application which will be able to work with the ontology without the Protégé.

Best regards,
Martina Husáková
Reply | Threaded
Open this post in threaded view
|

Re: Problem with really simple queries

Jiba
Administrator
In reply to this post by Martina
Hello,

I tested your ontology with Owlready 2-0.10 (after saving it as /tmp/ad.owl), but the search() method seems working. I get 10 subclasses, as shown below.


from owlready2 import *
onto = get_ontology("file:///tmp/ad.owl").load()
print(onto.search(subclass_of = onto.Symptom))

[ad.BladderSymptom, ad.BowelSymptom, ad.BreathingSymptom, ad.EyeSymptom, ad.HormoneBasedSymptom, ad.MentalSymptom, ad.MuscleSymptom, ad.NerveSymptom, ad.SkinSymptom, ad.SwallowingSymptom]


Can you send me the script that causes the error?

Best regards,
Jean-Baptiste Lamy
MCF HDR, Laboratoire LIMICS, Université Paris 13
Reply | Threaded
Open this post in threaded view
|

Re: Problem with really simple queries

Martina
Good afternoon,

thank you a lot for your feedback! I think that you will laugh, because I forgot the print() method before onto.search(subclass_of = onto. Symptom) :-o :-o Really trivial mistake! It works just now :-))
I did not see this mistake at all :-))

Thank you a lot for your help!

Many greetings,
Martina