-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathExtractLabels.groovy
29 lines (24 loc) · 1.08 KB
/
ExtractLabels.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
import java.util.logging.Logger
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.*
import org.semanticweb.owlapi.reasoner.*
import org.semanticweb.owlapi.profiles.*
import org.semanticweb.owlapi.util.*
import org.semanticweb.owlapi.io.*
import org.semanticweb.elk.owlapi.*
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary
OWLOntologyManager manager = OWLManager.createOWLOntologyManager()
OWLDataFactory fac = manager.getOWLDataFactory()
OWLDataFactory factory = fac
OWLOntology ont = manager.loadOntologyFromOntologyDocument(new File(args[0]))
def id2label = [:] // maps a name to an OWLClass
OWLAnnotationProperty label = fac.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())
ont.getClassesInSignature(true).each { cl ->
def annos = cl.getAnnotations(ont, label)
annos.each { anno ->
if (anno.getValue() instanceof OWLLiteral) {
OWLLiteral val = (OWLLiteral) anno.getValue()
println cl.toString().replaceAll("<http://phenomebrowser.net/plant-phenotype.owl#","").replaceAll(">","") + "\t" + val.getLiteral()
}
}
}