How does 'is_a' work with the search() method?

Posted by kuoks on
URL: http://owlready.306.s1.nabble.com/How-does-is-a-work-with-the-search-method-tp2421.html

Hi Jiba,

System Information: MacOS 10.15.7; Python 3.8.2; owlready2 0.30

I am a novice to ontology and the owlready2 package, but I have spent a week or so exploring it. I am trying to use the python anytree package with SWEET ontology to build a tree representation of the ontology.

Basically, my strategy is to start off at the head of the ontoloty as the root node of the tree, find and create tree nodes for its children, and assign them the root node as their parent node, then proceed recurrsively down the chain. However, I noticed the following (code and returns below):

>>> from owlready import *
>>>  onto = get_ontology('data/owlapi.xrdf').load() # I have downloaded the SWEET xrdf file to local drive.
>>> print(list(Thing.subclasses()))
[phen.Phenomena, proc.Process, prop.Property, realm.Realm, state.State, repr.Representation, human.HumanActivity, matr.Substance, sosa.Sensor, matrParticle.Nucleon, phenCryo.PhysicalProcess, procChemical.Sorption, reprSciModel.Sample, schema.org.Organization]

and

>>> onto.search(iri = '*GeologicFea*')
[realmGeol.GeologicFeature]
>>> onto.search(iri = '*GeologicFea*')[0].is_a
[owl.Thing, rela.hasRealm.only(realm.Geosphere)]

So, apparently, 'Thing' is a parent of 'realmGeol.GeologicFeature' but the latter does not appear in the subclasses of 'Thing'! Thus, I alternatively tried to use 'onto.search(is_a = Thing)' to find 'rela.hasRealm.only(realm.Geosphere)' as a 'subclass' of 'Thing' and construct it as a child node on the tree. But, the search simply hung (with CPU usage around 100%), and worse still, once the search started, I couldn't interrupt it. I had to force quit the python shell or kill the terminal it was executed in. Out of curiosity, I tried 'onto.search(subclass_of = Thing). That hangs too! I have also asked a friend of mine (who is more familiar with ontology than me) to try it on his platform, same results.

My question is: Did I misunderstand the usage of the search method and use it incorrectly? Or, is there possibly a bug?

Thanks,
Kuo