Search only classes

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

Search only classes

Arciniegas
Hi, Jiba,

I wanna search in my world the classes (only the classes) that have a dynamic word inside its labels, so i am doing this

labels = default_world.search(label="*" + word + "*",  _case_sensitive=False)

but it finds also properties and other stufs.

can i do something like this:

labels = default_world.search(label="*" + word + "*", type="http://www.w3.org/2002/07/owl#Class", _case_sensitive=False)

or this:

labels = default_world.search(label="*" + word + "*", type= owl.Class, _case_sensitive=False)
labels = default_world.search(label="*" + word + "*", type= owl.Thing, _case_sensitive=False)

please, don't ignore me again ( u.u)
Reply | Threaded
Open this post in threaded view
|

Re: Search only classes

Jiba
Administrator
Hi,

You can use :

labels = default_world.search(label="*" + word + "*", type= owl_class)

NB: owl_class is the Store-ID for OWL Class (i.e. "http://www.w3.org/2002/07/owl#Class").

Sorry for being long to reply; I am very busy and my child was sick last week,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Search only classes

Arciniegas
Yeah, i know that i must pass a Class in the type, but i don't know how to get it.

It's necessary to load the ontology owl or how? i'm trying to do this:

owl = default_world.get_ontology("https://www.w3.org/2002/07/owl#").load()
        print(owl,owl.Class)

but it fails:

owlready2.base.OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in https://www.w3.org/2002/07/owl, line 8.

I wanna know if there are another way to filter the search only for the classes.

:3 I appreciate your work with OwlReady and the forum. That's great!
Reply | Threaded
Open this post in threaded view
|

Re: Search only classes

Jiba
Administrator
> It's necessary to load the ontology owl or how?

No, just use "owl_class" (which is a constant imported from the owlready2 module).

Jiba