How to cast the generator into the list in Owlready2

72 views Asked by At

I have been trying to store the all classes and belongings with owlready2. Altough I convert the generators into the list, I am still getting the same ouput.

from owlready2 import *

onto = get_ontology("C:\\Users\\Kronos\\Desktop\\Ontology\\f3.owx").load()

class main():
    all_class= list(onto.classes())
    print(all_class)

Output goes on like this:

C:\Users\Kronos\Desktop\Ontology\f3.owx.Address, C:\Users\Kronos\Desktop\Ontology\f3.owx.BabyCare, ...
1

There are 1 answers

0
kronos_58 On

For now, I'm storing it by brute force by taking the (.)dot after point.

all_class = onto.classes()

class_names = [cls._name.split('.')[-1] for cls in all_class]