org.semanticweb.owlapi.reasoner.OWLReasonerFactory Java Examples
The following examples show how to use
org.semanticweb.owlapi.reasoner.OWLReasonerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test inferring into new ontology. * * @throws Exception on any problem */ @Test public void testInferIntoNewOntologyNonTrivial() throws Exception { OWLOntology reasoned = loadOntology("/relax_equivalence_axioms_test.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); // see https://github.com/ontodev/robot/issues/80 opts.put("create-new-ontology", "true"); opts.put("annotate-inferred-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); // note that some of the inferred axioms are trivial // involving owl:Thing assertEquals(15, reasoned.getAxiomCount()); // assertIdentical("/simple_hermit.owl", reasoned); }
Example #2
Source File: QuerySubsetGenerator.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Create a new sub ontology from a given DL query and source ontology. The * subset will be created in the target ontology. * * @param namedQuery * @param sourceGraph * @param targetGraph * @param reasonerFactory * @param toMerge */ public void createSubOntologyFromDLQuery(OWLClass namedQuery, OWLGraphWrapper sourceGraph, OWLGraphWrapper targetGraph, OWLReasonerFactory reasonerFactory, Set<OWLOntology> toMerge) { try { Set<OWLClass> subset = DLQueryTool.executeQuery(namedQuery, sourceGraph.getSourceOntology(), reasonerFactory); if (subset.isEmpty()) { return; } createSubSet(targetGraph, subset, toMerge); } catch (OWLOntologyCreationException e) { LOG.error("Could not create ontology.", e); // TODO throw Exception? return; } }
Example #3
Source File: ReasonerHelperTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test checking for incoherent classes. * * @throws IOException if file error * @throws InconsistentOntologyException if has inconsistencies * @throws IncoherentRBoxException if has unsatisfiable properties */ @Test public void testIncoherentTBox() throws IOException, InconsistentOntologyException, IncoherentRBoxException { OWLOntology ontology = loadOntology("/incoherent-tbox.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); boolean isCaughtException = false; try { ReasonerHelper.validate(reasoner); } catch (IncoherentTBoxException e) { isCaughtException = true; } assertTrue(isCaughtException); }
Example #4
Source File: ReasonerHelperTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test checking for inconsistencies. * * @throws IOException if file error * @throws IncoherentTBoxException if has unsatisfiable classes * @throws IncoherentRBoxException if has unsatisfiable properties */ @Test public void testInconsistentOntology() throws IOException, IncoherentTBoxException, IncoherentRBoxException { OWLOntology ontology = loadOntology("/inconsistent.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); boolean isCaughtException = false; try { ReasonerHelper.validate(reasoner); } catch (InconsistentOntologyException e) { isCaughtException = true; } assertTrue(isCaughtException); }
Example #5
Source File: SpeciesMergeUtilTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testMergeSpecies() throws Exception { ParserWrapper p = new ParserWrapper(); OWLOntology owlOntology = p.parse(getResourceIRIString("speciesMergeTest.obo")); OWLGraphWrapper graph = new OWLGraphWrapper(owlOntology); OWLReasonerFactory rf = new ElkReasonerFactory(); OWLReasoner reasoner = rf.createReasoner(graph.getSourceOntology()); SpeciesMergeUtil smu = new SpeciesMergeUtil(graph); smu.viewProperty = graph.getOWLObjectPropertyByIdentifier("BFO:0000050"); smu.taxClass = graph.getOWLClassByIdentifier("T:1"); smu.reasoner = reasoner; smu.suffix = "coelocanth"; smu.merge(); p.saveOWL(smu.ont, new OBODocumentFormat(), "target/speciesMergeOut.obo"); }
Example #6
Source File: EcoToolsTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@BeforeClass public static void beforeClass() throws Exception { // Setup environment. ParserWrapper pw = new ParserWrapper(); //NOTE: Yes, the GO here is unnecessary, but we're trying to also catch a certain behavior // where auxilery ontologies are not caught. The best wat to do that here is to load ECO // second and then do the merge. OWLOntology ont_main = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo")); OWLOntology ont_scnd = pw.parse(getResourceIRIString("eco.obo")); g = new OWLGraphWrapper(ont_main); g.addSupportOntology(ont_scnd); // NOTE: This step is necessary or things will get ignored! // (This cropped-up in the loader at one point.) for (OWLOntology ont : g.getSupportOntologySet()) g.mergeOntology(ont); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); r = reasonerFactory.createReasoner(g.getSourceOntology()); g.setReasoner(r); }
Example #7
Source File: ReasonerHelperTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test checking for incoherent OPs. * * <p>See https://github.com/ontodev/robot/issues/104 * * @throws IOException if file error * @throws IncoherentTBoxException if has unsatisfiable classes * @throws InconsistentOntologyException if has inconsistencies */ @Test public void testIncoherentRBox() throws IOException, IncoherentTBoxException, InconsistentOntologyException { OWLOntology ontology = loadOntology("/incoherent-rbox.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); boolean isCaughtException = false; try { ReasonerHelper.validate(reasoner); } catch (IncoherentRBoxException e) { isCaughtException = true; } assertTrue(isCaughtException); }
Example #8
Source File: MaterializeOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test reasoning with imports. * * <p>For motivation, see https://github.com/ontodev/robot/issues/119 * * @throws IOException on file problem * @throws OWLOntologyCreationException on ontology problem * @throws URISyntaxException if URI incorrectly formatted * @throws OntologyLogicException on logic problem */ @Test public void testMaterializeWithImports() throws IOException, OWLOntologyCreationException, OntologyLogicException, URISyntaxException { // TODO: minor, simplify this once // https://github.com/ontodev/robot/issues/121 implemeted File f = new File(getClass().getResource("/import-non-reasoned.owl").toURI()); IOHelper ioh = new IOHelper(); OWLOntology reasoned = ioh.loadOntology(f, true); OWLOntology original = ioh.loadOntology(f, true); OWLReasonerFactory coreReasonerFactory = new ElkReasonerFactory(); Map<String, String> opts = ReasonOperation.getDefaultOptions(); MaterializeOperation.materialize(reasoned, coreReasonerFactory, null, opts); assertIdentical(original, reasoned); }
Example #9
Source File: TaxonToolsTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@BeforeClass public static void beforeClass() throws Exception { // Setup environment. ParserWrapper pw = new ParserWrapper(); //NOTE: Yes, the GO here is unnecessary, but we're trying to also catch a certain behavior // where auxiliary ontologies are not caught. The best way to do that here is to load taxslim // second and then do the merge. OWLOntology ont_main = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo")); OWLOntology ont_scnd = pw.parse(getResourceIRIString("taxslim.obo")); g = new OWLGraphWrapper(ont_main); g.addSupportOntology(ont_scnd); // NOTE: This step is necessary or things will get ignored! // (This cropped-up in the loader at one point.) for (OWLOntology ont : g.getSupportOntologySet()) g.mergeOntology(ont); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); r = reasonerFactory.createReasoner(g.getSourceOntology()); g.setReasoner(r); }
Example #10
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test individual axiom generators. * * @throws Exception on any problem */ @Test public void testIndividualAxiomGenerators() throws Exception { OWLOntology ontology = loadOntology("/simple_logic.owl"); Map<String, String> options = ReasonOperation.getDefaultOptions(); OWLReasonerFactory reasonerFactory = new JFactFactory(); options.put("axiom-generators", "ClassAssertion"); ReasonOperation.reason(ontology, reasonerFactory, options); // class assertion assertTrue( checkContains( ontology, "ClassAssertion(<http://purl.obolibrary.org/obo/CLS_02> <http://purl.obolibrary.org/obo/IND_03>)")); // property assertion assertTrue( checkContains( ontology, "ObjectPropertyAssertion(<http://purl.obolibrary.org/obo/OP_08> <http://purl.obolibrary.org/obo/IND_02> <http://purl.obolibrary.org/obo/IND_03>)")); }
Example #11
Source File: CommandLineHelper.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Given a string of a reasoner name from user input, return the reasoner factory. If the user * input is not valid, throw IllegalArgumentExcepiton. * * @param line the command line to use * @param allowEMR boolean specifying if EMR can be returned * @return OWLReasonerFactory if successful */ public static OWLReasonerFactory getReasonerFactory(CommandLine line, boolean allowEMR) { // ELK is the default reasoner String reasonerName = getDefaultValue(line, "reasoner", "ELK").trim().toLowerCase(); logger.info("Reasoner: " + reasonerName); if (reasonerName.equals("structural")) { return new org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory(); } else if (reasonerName.equals("hermit")) { return new org.semanticweb.HermiT.ReasonerFactory(); } else if (reasonerName.equals("jfact")) { return new JFactFactory(); // Reason must change behavior with EMR, so not all commands can use it } else if (reasonerName.equals("emr") && allowEMR) { ElkReasonerFactory innerReasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); return new ExpressionMaterializingReasonerFactory(innerReasonerFactory); } else if (reasonerName.equals("elk")) { return new org.semanticweb.elk.owlapi.ElkReasonerFactory(); } else { throw new IllegalArgumentException(String.format(invalidReasonerError, reasonerName)); } }
Example #12
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test data property axiom generators. * * @throws Exception on any problem */ @Test public void testDataPropertyAxiomGenerators() throws Exception { OWLOntology ontology = loadOntology("/simple_logic.owl"); Map<String, String> options = ReasonOperation.getDefaultOptions(); OWLReasonerFactory reasonerFactory = new JFactFactory(); options.put("axiom-generators", "EquivalentDataProperties SubDataProperty"); ReasonOperation.reason(ontology, reasonerFactory, options); // subproperty assertTrue( checkContains( ontology, "SubDataPropertyOf(<http://purl.obolibrary.org/obo/DP_03> <http://purl.obolibrary.org/obo/DP_01>)")); // equivalent properties assertTrue( checkContains( ontology, "EquivalentDataProperties(<http://purl.obolibrary.org/obo/DP_01> <http://purl.obolibrary.org/obo/DP_04> )")); }
Example #13
Source File: ReasonOperation.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Given an ontology, a reasoner factory, and a map of options, return the ontology with inferred * axioms added after reasoning. * * @param ontology the ontology to reason over * @param reasonerFactory the factory to create a reasoner instance from * @param options a map of option strings, or null * @throws OntologyLogicException if the ontology contains unsatisfiable classes, properties or * inconsistencies * @throws OWLOntologyCreationException if ontology cannot be created * @throws InvalidReferenceException if the reference checker fails */ public static void reason( OWLOntology ontology, OWLReasonerFactory reasonerFactory, Map<String, String> options) throws OntologyLogicException, OWLOntologyCreationException, InvalidReferenceException { logger.info("Ontology has {} axioms.", ontology.getAxioms().size()); // Check the ontology for reference violations // Maybe fail if prevent-invalid-references checkReferenceViolations(ontology, options); // Get the reasoner and run initial reasoning // No axioms are asserted in this step OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); reason(ontology, reasoner, options); // Get the axiom generators // If none are provided, just default to subclass= List<InferredAxiomGenerator<? extends OWLAxiom>> gens = getInferredAxiomGenerators(options); // Assert inferred axioms in the ontology assertInferred(ontology, reasoner, gens, options); }
Example #14
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test indirect axiom generators. * * @throws Exception on any problem */ @Test public void testIndirectAxiomGenerators() throws Exception { OWLOntology ontology = loadOntology("/reason-direct-indirect.ofn"); Map<String, String> options = ReasonOperation.getDefaultOptions(); options.put("axiom-generators", "Subclass SubObjectProperty ClassAssertion"); options.put("include-indirect", "true"); options.put("remove-redundant-subclass-axioms", "false"); OWLReasonerFactory reasonerFactory = new ReasonerFactory(); ReasonOperation.reason(ontology, reasonerFactory, options); assertTrue( checkContains(ontology, "ClassAssertion(<http://example.org/C> <http://example.org/c>)")); assertTrue( checkContains(ontology, "ClassAssertion(<http://example.org/B> <http://example.org/c>)")); assertTrue( checkContains(ontology, "ClassAssertion(<http://example.org/A> <http://example.org/c>)")); assertTrue( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/B>)")); assertTrue( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/A>)")); assertTrue( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/D>)")); assertTrue( checkContains( ontology, "SubObjectPropertyOf(<http://example.org/t> <http://example.org/s>)")); assertTrue( checkContains( ontology, "SubObjectPropertyOf(<http://example.org/t> <http://example.org/r>)")); }
Example #15
Source File: ReasonerHelperTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test for no false positives in validation. * * @throws IOException if file error * @throws IncoherentTBoxException if has unsatisfiable classes * @throws InconsistentOntologyException if has inconsistencies * @throws IncoherentRBoxException if has unsatisfiable properties */ @Test public void testNoFalsePositives() throws IOException, IncoherentTBoxException, InconsistentOntologyException, IncoherentRBoxException { OWLOntology ontology = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); ReasonerHelper.validate(reasoner); // trivially true, if no exceptions are caught assertTrue(true); }
Example #16
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test direct axiom generators. * * @throws Exception on any problem */ @Test public void testDirectAxiomGenerators() throws Exception { OWLOntology ontology = loadOntology("/reason-direct-indirect.ofn"); Map<String, String> options = ReasonOperation.getDefaultOptions(); options.put("axiom-generators", "Subclass SubObjectProperty ClassAssertion"); options.put("include-indirect", "false"); options.put("remove-redundant-subclass-axioms", "false"); OWLReasonerFactory reasonerFactory = new ReasonerFactory(); ReasonOperation.reason(ontology, reasonerFactory, options); assertTrue( checkContains(ontology, "ClassAssertion(<http://example.org/C> <http://example.org/c>)")); assertFalse( checkContains(ontology, "ClassAssertion(<http://example.org/B> <http://example.org/c>)")); assertFalse( checkContains(ontology, "ClassAssertion(<http://example.org/A> <http://example.org/c>)")); assertTrue( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/B>)")); assertFalse( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/A>)")); assertFalse( checkContains(ontology, "SubClassOf(<http://example.org/C> <http://example.org/D>)")); assertTrue( checkContains( ontology, "SubObjectPropertyOf(<http://example.org/t> <http://example.org/s>)")); assertFalse( checkContains( ontology, "SubObjectPropertyOf(<http://example.org/t> <http://example.org/r>)")); }
Example #17
Source File: MaterializeOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test reasoning with Expression Materializing Reasoner. * * @throws IOException on file problem * @throws OWLOntologyCreationException on ontology problem * @throws OntologyLogicException on logic problem */ @Test public void testMaterialize() throws IOException, OWLOntologyCreationException, OntologyLogicException { OWLOntology reasoned = loadOntology("/relax_equivalence_axioms_test.obo"); OWLReasonerFactory coreReasonerFactory = new ElkReasonerFactory(); Map<String, String> opts = ReasonOperation.getDefaultOptions(); // opts.put("exclude-owl-thing", "true"); MaterializeOperation.materialize(reasoned, coreReasonerFactory, null, opts); assertIdentical("/relax_equivalence_axioms_expressions_materialized.obo", reasoned); }
Example #18
Source File: EcoTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create a new instance using the ECO graph wrapper. * * @param eco */ public EcoTools(OWLGraphWrapper eco) { this.eco = eco; OWLReasonerFactory factory = new ElkReasonerFactory(); final OWLOntology sourceOntology = eco.getSourceOntology(); reasoner = factory.createReasoner(sourceOntology); disposeReasonerP = true; }
Example #19
Source File: GoIEPRestrictionsRule.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GoIEPRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) { this.message = MESSAGE; this.violationType = ViolationType.Warning; evidences = eco.getAllValidEvidenceIds("IEP", true); classSubSet = new HashSet<String>(); OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0008150"); OWLReasonerFactory factory = new ElkReasonerFactory(); OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology()); try { NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false); for(OWLClass cls : nodeSet.getFlattened()) { if (cls.isBottomEntity() || cls.isTopEntity()) { continue; } String oboId = graph.getIdentifier(cls); if (oboId != null) { classSubSet.add(oboId); } } } finally { reasoner.dispose(); } }
Example #20
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test removing redundant subclass axioms. * * @throws Exception on any problem */ @Test public void testRemoveRedundantSubClassAxioms() throws Exception { OWLOntology reasoned = loadOntology("/redundant_subclasses.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory, Collections.emptyMap()); assertIdentical("/redundant_subclasses.owl", reasoned); Map<String, String> options = new HashMap<>(); options.put("remove-redundant-subclass-axioms", "true"); reasoned = loadOntology("/redundant_subclasses.owl"); ReasonOperation.reason(reasoned, reasonerFactory, options); assertIdentical("/without_redundant_subclasses.owl", reasoned); }
Example #21
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test inferring into new ontology, excluding duplicates. * * @throws Exception on any problem */ @Test public void testInferIntoNewOntologyNoDupes() throws Exception { OWLOntology reasoned = loadOntology("/relax_equivalence_axioms_test.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); opts.put("create-new-ontology", "true"); opts.put("annotate-inferred-axioms", "true"); opts.put("exclude-duplicate-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); assertEquals(5, reasoned.getAxiomCount()); // assertIdentical("/simple_hermit.owl", reasoned); }
Example #22
Source File: JustifyAssertionsTool.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Justify the given set of subClass axioms from the given ontology. Assumes that * the axioms are already removed and the reasoner is up-to-date. <br> * Does not modify the ontology. * * @param ontology * @param reasoner * @param axioms * @return result */ public static JustifyResult justifySubClasses(OWLOntology ontology, OWLReasoner reasoner, Set<OWLSubClassOfAxiom> axioms) { InferenceBuilder infBuilder = new InferenceBuilder(null, (OWLReasonerFactory) null, false); try { Inferences inferences = infBuilder.buildInferences(ontology, reasoner, true); List<OWLAxiom> inferredAxioms = inferences.axiomsToAdd; return justifySubClasses(ontology, reasoner, axioms, inferredAxioms); } finally { infBuilder.dispose(); } }
Example #23
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test inferring into new ontology. * * @throws Exception on any problem */ @Test public void testInferIntoNewOntology() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); Map<String, String> opts = new HashMap<>(); // see https://github.com/ontodev/robot/issues/80 opts.put("create-new-ontology", "true"); // see https://github.com/ontodev/robot/issues/80 opts.put("annotate-inferred-axioms", "true"); ReasonOperation.reason(reasoned, reasonerFactory, opts); assertEquals(2, reasoned.getAxiomCount()); // assertIdentical("/simple_hermit.owl", reasoned); }
Example #24
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test reasoning with JFact. * * @throws Exception on any problem */ @Test public void testJFact() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new JFactFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertEquals(6, reasoned.getAxiomCount()); assertIdentical("/simple_jfact.owl", reasoned); }
Example #25
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test reasoning with HermiT. * * @throws Exception on any problem */ @Test public void testHermit() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.HermiT.ReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertEquals(6, reasoned.getAxiomCount()); assertIdentical("/simple_hermit.owl", reasoned); }
Example #26
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test reasoning with ELK. * * @throws Exception on any problem */ @Test public void testELK() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new ElkReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_elk.owl", reasoned); }
Example #27
Source File: ReasonOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test reasoning with StructuralReasoner. * * @throws Exception on any problem */ @Test public void testStructural() throws Exception { OWLOntology reasoned = loadOntology("/simple.owl"); OWLReasonerFactory reasonerFactory = new org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory(); ReasonOperation.reason(reasoned, reasonerFactory); assertIdentical("/simple_structural.owl", reasoned); }
Example #28
Source File: InferenceBuilder.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static OWLReasonerFactory getFactory(String reasonerName) { if (REASONER_HERMIT.equals(reasonerName)) { return new org.semanticweb.HermiT.ReasonerFactory(); } else if (REASONER_ELK.equals(reasonerName)) { return new ElkReasonerFactory(); } throw new IllegalArgumentException("Unknown reasoner: "+reasonerName); }
Example #29
Source File: ReduceOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Edge case, taken from GO * * <p>See: 'central nervous system development' in the test file * * @throws IOException on file problem * @throws OWLOntologyCreationException if ontology cannot be created */ @Test public void testReduceEdgeCase() throws IOException, OWLOntologyCreationException { OWLOntology reasoned = loadOntology("/reduce-edgecase-cnd.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); Map<String, String> options = new HashMap<String, String>(); options.put("remove-redundant-subclass-axioms", "true"); ReduceOperation.reduce(reasoned, reasonerFactory, options); assertIdentical("/reduce-edgecase-cnd-reduced.obo", reasoned); }
Example #30
Source File: ReduceOperationTest.java From robot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * This test ensures that subClassOf axioms are never removed if they lead to loss of information * in the subClassOf graph * * @throws IOException on file problem * @throws OWLOntologyCreationException if ontology cannot be created */ @Test public void testReduceWithEquiv() throws IOException, OWLOntologyCreationException { OWLOntology reasoned = loadOntology("/equiv_reduce_test.obo"); OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory(); Map<String, String> options = new HashMap<String, String>(); options.put("remove-redundant-subclass-axioms", "true"); ReduceOperation.reduce(reasoned, reasonerFactory, options); assertIdentical("/equiv_reduce_test_reduced.obo", reasoned); }