Skip to content
Advertisement

can not get my individuals from my ontology using search method in owlready python

I have an ontology : https://raw.githubusercontent.com/amiraelsayed/lumiere/master/lumiere3.owl

I want to get all lessons for specific class called CS-Java

I have tried to use owlready search method and add to it filtration with lesson name and object properties but always give 0 while it should retrieve about 19 item

This is my individual

JavaScript

this is the class and it is contain list of lesson individuals

onto.search(part_of="*") it brings all lessons in all courses and when I used onto.search(part_of="CS-Java") it return 0 while I need it to return only lessons in this course

Advertisement

Answer

I guess your search returns 0 result because the search method can only be used to perform Full Text Search on the content of the annotations.

It seems that what you need is to perform a query against the knowledge contained in your ontology, so maybe using SPARQL could be an idea ?

Owlready offers a way to perform SPARQL queries on an ontology, so you could express something like “Select all the things that CS-Java contains” :

JavaScript

The other way the go could simply be to read the content of the contains property on your CS-Java class :

JavaScript

Both methods returns a list a Owlready2 objects (18 in your example case).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement