Searching all object properties for specific individual

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

Searching all object properties for specific individual

Martina
Good afternoon,

may I have a question? Is it possible to search all (e. g.) object properties for specific individual?
I can imagine that my ontology contains a name John and I would like to receive all its object properties with their values. Is it possible to do this without Sparql? I know that if I would like to receive all object properties from my ontology, I can do this: allObjectProperties = list(onto.object_properties()), where onto is a variable name with my loaded ontology.

Thank you very much for some feedback from you :-)

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

Re: Searching all object properties for specific individual

Jiba
Administrator
Hi,

I think you mean "search all the properties for which individual x has at least one relation"?

This can be done with already using x.get_properties(). You can also filter ObjectProperty as follows :

for Prop in x.get_properties():
          if isinstance(Prop, ObjectPropertyClass):
                      ....

For SPARQL, I am not an expert, but maybe someone else could help you.

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

Re: Searching all object properties for specific individual

Martina
Dear Jiba,

really, ..., whow, it works :-) Again, thank you a lot for your help!!!
It also works for annotation properties and datatype properties.

Mmm, ..., is it possible to receive full documentation for OWLReady2? I mean a documentation that is often provided for some Java-based frameworks --> JAVA API doc where all methods (with arguments, returned values) and attributes are mentioned. I tried to find isinstance() methods in the https://pythonhosted.org/Owlready2/ documentation, but I was not successful. Maybe, I did not search more, but ... mmm, I did not find them :-(

Thank you a lot and have a great day :-)

Many greetings,
Martina
Reply | Threaded
Open this post in threaded view
|

Re: Searching all object properties for specific individual

Jiba
Administrator
Hi,

I'm sorry, there is no such reference documentation for Owlready, at least not yet.

Best regards,
Jiba