pwin / owlready2

GNU Lesser General Public License v3.0
137 stars 22 forks source link

TypeError: '<' not supported between instances of 'str' and 'int' #34

Open JordanTStrong opened 1 year ago

JordanTStrong commented 1 year ago

I am attempting to save dynamically created classes and subclasses to a rdfxml file. I got the class data from a csv that I managed with pandas df. When I try running onto.save(file = 'onto.rdfxml', format = 'rdfxml') the following error is returned:

'''TypeError: '<' not supported between instances of 'str' and 'int' on line 464 of driver.py'''

At first I thought that it had to do with special characters and ints being in the strings used in the class names. But, after removing all special characters and whitespaces and replacing all ints with their spelt out names (ie 1 = one), the same TypeError was returned.

Next, I tried seeing if the ontology was being saved as expected. Using the docs, I ran the code below, and it showed that the classes and subclasses were being successfully added. So, the issue was clearly with saving the file.

class_list = list(onto.classes())
for i in class_list:
    print(i, "is a subclass of: ", end='')
    for j in i.is_a:
        print(j, end=', ')
    print("\n")

Then, I tried to see if saving the ontology to a different file type would work. I tried turtle, xml, own, and omn, and while the onto.save line ran successfully, it never stored any data. The file size stayed at 0 bytes.

Again, the error is '''TypeError: '<' not supported between instances of 'str' and 'int' on line 464 of driver.py''' found at: File /opt/anaconda3/lib/python3.8/site-packages/owlready2/driver.py:466, in _save(f, format, graph, filter)