Last active
December 8, 2016 18:25
-
-
Save benozol/d7aeff5f181350f9298cb59b07df2bf7 to your computer and use it in GitHub Desktop.
Test case for OWLKnowledgeExplorerReasoner.getObjectLabel
This file contains 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
import org.semanticweb.owlapi.apibinding.OWLManager; | |
import org.semanticweb.owlapi.model.IRI; | |
import org.semanticweb.owlapi.model.OWLClass; | |
import org.semanticweb.owlapi.model.OWLDataFactory; | |
import org.semanticweb.owlapi.model.OWLObjectProperty; | |
import org.semanticweb.owlapi.model.OWLOntology; | |
import org.semanticweb.owlapi.model.OWLOntologyManager; | |
import org.semanticweb.owlapi.reasoner.ConsoleProgressMonitor; | |
import org.semanticweb.owlapi.reasoner.InferenceType; | |
import org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration; | |
import org.semanticweb.owlapi.reasoner.SimpleConfiguration; | |
import org.semanticweb.owlapi.reasoner.knowledgeexploration.OWLKnowledgeExplorerReasoner; | |
import org.semanticweb.owlapi.reasoner.knowledgeexploration.OWLKnowledgeExplorerReasoner.RootNode; | |
import uk.ac.manchester.cs.jfact.JFactFactory; | |
public class TestCase { | |
static final IRI VO_IRI = IRI.create("http://purl.obolibrary.org/obo/vo.owl"); | |
static final String OBO_PREFIX = "http://purl.obolibrary.org/obo/"; | |
public static void main(String[] args) throws Exception { | |
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | |
OWLDataFactory dataFactory = manager.getOWLDataFactory(); | |
OWLOntology ontology = manager.loadOntology(VO_IRI); | |
ConsoleProgressMonitor monitor = new ConsoleProgressMonitor(); | |
OWLReasonerConfiguration conf = new SimpleConfiguration(monitor); | |
JFactFactory reasonerFactory = new JFactFactory(); | |
OWLKnowledgeExplorerReasoner reasoner = (OWLKnowledgeExplorerReasoner) reasonerFactory.createReasoner(ontology, conf); | |
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY, InferenceType.OBJECT_PROPERTY_HIERARCHY); | |
OWLClass clazz = dataFactory.getOWLClass(OBO_PREFIX + "VO_0000004"); // ActHIB | |
OWLObjectProperty property = dataFactory.getOWLObjectProperty(OBO_PREFIX + "VO_0003355"); // vaccine immunization against microbe | |
for (RootNode filler: reasoner.getObjectNeighbours(reasoner.getRoot(clazz), property)) { | |
// uk.ac.manchester.cs.jfact.helpers.UnreachableSituationException: Unreachable situation! | |
reasoner.getObjectLabel(filler, true); | |
} | |
} | |
} | |
/* | |
Compiled and run in eclipse with maven, owlapi 5.0.4 and jfact 5.0.1 | |
Exception in thread "main" uk.ac.manchester.cs.jfact.helpers.UnreachableSituationException: Unreachable situation! | |
at uk.ac.manchester.cs.jfact.kernel.TDag2Interface.buildCExpr(TDag2Interface.java:97) | |
at uk.ac.manchester.cs.jfact.kernel.TDag2Interface.getCExpr(TDag2Interface.java:172) | |
at uk.ac.manchester.cs.jfact.KnowledgeExplorer.lambda$addC$174(KnowledgeExplorer.java:103) | |
at java.lang.Iterable.forEach(Iterable.java:75) | |
at uk.ac.manchester.cs.jfact.KnowledgeExplorer.addC(KnowledgeExplorer.java:103) | |
at uk.ac.manchester.cs.jfact.KnowledgeExplorer.lambda$getObjectLabel$185(KnowledgeExplorer.java:184) | |
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) | |
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) | |
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374) | |
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742) | |
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) | |
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) | |
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) | |
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) | |
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) | |
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) | |
at uk.ac.manchester.cs.jfact.KnowledgeExplorer.getObjectLabel(KnowledgeExplorer.java:184) | |
at uk.ac.manchester.cs.jfact.kernel.ReasoningKernel.getObjectLabel(ReasoningKernel.java:1607) | |
at uk.ac.manchester.cs.jfact.JFactReasoner.getObjectLabel(JFactReasoner.java:806) | |
at vacco.TestCase.main(TestCase.java:39) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment