Created
March 31, 2021 19:30
-
-
Save balhoff/e8aac49ce0b744821937afc2f7987f6f to your computer and use it in GitHub Desktop.
Demonstrate slowdown in second ELK query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scala 2.13.3 | |
// ammonite 2.3.8 | |
import $ivy.`net.sourceforge.owlapi:owlapi-distribution:4.5.17` | |
import $ivy.`org.semanticweb.elk:elk-owlapi:0.4.3` | |
import $ivy.`com.outr::scribe-slf4j:2.7.12` | |
import org.semanticweb.owlapi.apibinding.OWLManager | |
import org.semanticweb.elk.owlapi.ElkReasonerFactory | |
import org.semanticweb.owlapi.model.IRI | |
import org.semanticweb.owlapi.model.OWLClassExpression | |
import org.semanticweb.owlapi.reasoner.OWLReasoner | |
@main | |
def main(ontFile: os.Path) = { | |
val factory = OWLManager.getOWLDataFactory() | |
val PartOf = factory.getOWLObjectProperty(IRI.create("http://purl.obolibrary.org/obo/BFO_0000050")) | |
val AnatomicalEntity = factory.getOWLClass(IRI.create("http://purl.obolibrary.org/obo/UBERON_0001062")) | |
val SkeletalSystem = factory.getOWLClass(IRI.create("http://purl.obolibrary.org/obo/UBERON_0001434")) | |
val ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(ontFile.toIO) | |
println("Done loading") | |
val reasoner = new ElkReasonerFactory().createReasoner(ontology) | |
println("Done classifying") | |
query(factory.getOWLObjectSomeValuesFrom(PartOf, AnatomicalEntity), reasoner) | |
query(factory.getOWLObjectSomeValuesFrom(PartOf, SkeletalSystem), reasoner) | |
} | |
def query(cls: OWLClassExpression, reasoner: OWLReasoner): Unit = { | |
val start = System.currentTimeMillis() | |
val size = reasoner.getSubClasses(cls, false).getFlattened().size() | |
val stop = System.currentTimeMillis() | |
println(s"Query time: ${stop - start}ms") | |
println(size) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment