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

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

Hi,

There was actually a bug in Thing.subclasses() : it missed GeologicFeature because GeologicFeature has a parent class, but this parent is not a named class but a construct.

Finding subclasses of Thing, i.e. the top-level classes, is actually tricky because some ontologies does not declare top-level class as subclass of Thing, and some others declare non-top-level classes as subclass of Thing.

I fixed this bug in the development version of Olwready on Bitbucket. You may also use the following SPARQL query to work around this problem:

print([x[0] for x in list(default_world.sparql("""SELECT ?x { ?x a owl:Class. FILTER(ISIRI(?x)). FILTER NOT EXISTS { ?x rdfs:subClassOf ?y. FILTER(ISIRI(?y) && ?y != owl:Thing) } }"""))])

onto.search(subclass_of = Thing) also include descendants classes, it is more complex and it takes longer. Here, it never terminates -- possibly there is some cycle somewhere?

Jiba