-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDeprecateDumbClasses.groovy
42 lines (38 loc) · 2.08 KB
/
DeprecateDumbClasses.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@Grapes([
@Grab(group='org.semanticweb.elk', module='elk-owlapi', version='0.4.2'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-api', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-apibinding', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-impl', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-parsers', version='4.1.0'),
@GrabConfig(systemClassLoader=true)
])
import org.semanticweb.owlapi.model.parameters.*
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.elk.owlapi.ElkReasonerConfiguration
import org.semanticweb.elk.reasoner.config.*
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.reasoner.*
import org.semanticweb.owlapi.reasoner.structural.StructuralReasoner
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.io.*;
import org.semanticweb.owlapi.owllink.*;
import org.semanticweb.owlapi.util.*;
import org.semanticweb.owlapi.search.*;
import org.semanticweb.owlapi.manchestersyntax.renderer.*;
import org.semanticweb.owlapi.reasoner.structural.*
OWLOntologyManager manager = OWLManager.createOWLOntologyManager()
def ont = manager.loadOntologyFromOntologyDocument(new File("ontology/flopo.owl"))
OWLDataFactory fac = manager.getOWLDataFactory()
ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor()
OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor)
ElkReasonerFactory f1 = new ElkReasonerFactory()
OWLReasoner reasoner = f1.createReasoner(ont,config)
reasoner.getEquivalentClasses(fac.getOWLNothing()).each { cl ->
EntitySearcher.getEquivalentClasses(cl, ont).each { equiv ->
manager.removeAxiom(ont, fac.getOWLEquivalentClassesAxiom(cl, equiv))
}
def anno = fac.getOWLAnnotation(fac.getOWLDeprecated(), fac.getOWLLiteral(true))
manager.addAxiom(ont, fac.getOWLAnnotationAssertionAxiom(cl.getIRI(), anno))
}
manager.saveOntology(ont, IRI.create("file:/tmp/flopo-clean.owl"))