I have an onology created in Protege. I loaded the ontology using Eclipse. I tried to delete a specific individual from ontology using the following code:
File file = new File("D:/diana/e/2012_2013/d/protege/picture8.owl");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology localPicture = manager.loadOntologyFromOntologyDocument(file);
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(localPicture, config);
OWLDataFactory fac = manager.getOWLDataFactory();
//the individual that I want to delete
OWLNamedIndividual ind = fac.getOWLNamedIndividual(IRI.create("http://www.semanticweb.org/diana/ontologies/2013/0/picture4.owl#Water1"));
OWLEntityRemover remover = new OWLEntityRemover(Collections.singleton(localPicture));
remover.visit(ind);
// or ind.accept(remover);
manager.applyChanges(remover.getChanges());
It seems that the individual was deleted, but when I open the ontology with Protege the individual is still there.
Could you tell me how can I delete the individual from Eclipse so as not to appear in Protege?
Have you saved the ontology afterwards?
You need to call manager.saveOntology(localPicture);
after applying the changes or they are only effective for the in memory copy of the ontology.