Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete individuals with owlready2


I am using owlready2 I load my ontology and I tried to delete the individuals of a class :

from owlready2 import *
onto = get_ontology("file://C:/Users/stef/Desktop/my_onto.owl").load()

country_list=onto.search(type=onto.Country)
len(country_list) ----> Out[27]: 219

for indiv in country_list :
    destroy_entity(indiv)

onto.search(type=onto.Country)-----> Out[29]: []

onto.save

it seems to me that the individuals in the class Country are deleted But when I open the ontology with protégé I found the individuals
someone tell me what I am missing !

like image 565
kloud Avatar asked Dec 07 '25 08:12

kloud


1 Answers

I have fixed this issue by replacing this line

onto.save

by this :

onto.save(file = "file://C:/Users/stef/Desktop/my_onto.owl")

like image 178
kloud Avatar answered Dec 09 '25 20:12

kloud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!