Search in sources :

Example 6 with InfModel

use of org.apache.jena.rdf.model.InfModel in project jena by apache.

the class TestReasoners method doTestTransitiveReduction.

/**
     * Test that a transitive reduction is complete.
     * Assumes test graph has no cycles (other than the trivial
     * identity ones). 
     */
public void doTestTransitiveReduction(Model model, Property dp) {
    InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getTransitiveReasoner(), model);
    for (ResIterator i = im.listSubjects(); i.hasNext(); ) {
        Resource base = i.nextResource();
        List<RDFNode> directLinks = new ArrayList<>();
        for (NodeIterator j = im.listObjectsOfProperty(base, dp); j.hasNext(); ) {
            directLinks.add(j.next());
        }
        for (int n = 0; n < directLinks.size(); n++) {
            Resource d1 = (Resource) directLinks.get(n);
            for (int m = n + 1; m < directLinks.size(); m++) {
                Resource d2 = (Resource) directLinks.get(m);
                if (im.contains(d1, dp, d2) && !base.equals(d1) && !base.equals(d2)) {
                    assertTrue("Triangle discovered in transitive reduction", false);
                }
            }
        }
    }
}
Also used : NodeIterator(org.apache.jena.rdf.model.NodeIterator) ResIterator(org.apache.jena.rdf.model.ResIterator) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) InfModel(org.apache.jena.rdf.model.InfModel) RDFNode(org.apache.jena.rdf.model.RDFNode)

Example 7 with InfModel

use of org.apache.jena.rdf.model.InfModel in project jena by apache.

the class AllAccept method testUnadornedInferenceModel.

public void testUnadornedInferenceModel() {
    Resource root = resourceInModel("x ja:reasoner R; R rdf:type ja:ReasonerFactory");
    Model m = Assembler.general.openModel(root);
    assertInstanceOf(InfModel.class, m);
    InfModel inf = (InfModel) m;
    assertIsoModels(empty, inf.getRawModel());
    assertInstanceOf(GenericRuleReasoner.class, inf.getReasoner());
}
Also used : Resource(org.apache.jena.rdf.model.Resource) Model(org.apache.jena.rdf.model.Model) InfModel(org.apache.jena.rdf.model.InfModel) InfModel(org.apache.jena.rdf.model.InfModel)

Example 8 with InfModel

use of org.apache.jena.rdf.model.InfModel in project jena by apache.

the class TestAssemblerGroup method testMultipleAssemblerGroup.

public void testMultipleAssemblerGroup() {
    AssemblerGroup a = AssemblerGroup.create();
    assertSame(a, a.implementWith(JA.InfModel, Assembler.infModel));
    assertSame(a, a.implementWith(JA.MemoryModel, Assembler.memoryModel));
    assertInstanceOf(InfModel.class, a.openModel(resourceInModel("x rdf:type ja:InfModel")));
    assertFalse(a.openModel(resourceInModel("y rdf:type ja:MemoryModel")) instanceof InfModel);
    checkFailsType(a, "js:DefaultModel");
}
Also used : ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup) InfModel(org.apache.jena.rdf.model.InfModel)

Example 9 with InfModel

use of org.apache.jena.rdf.model.InfModel in project jena by apache.

the class OWLConsistencyTest method testResults.

/**
     * Run the consistency check, returning a ValidityReport.
     */
public ValidityReport testResults() {
    Model t = FileManager.get().loadModel(BASE_DIR + tbox);
    Model a = FileManager.get().loadModel(BASE_DIR + abox);
    // Work around non-deterministic bug in bindSchema
    //        Reasoner r = rf.create(null).bindSchema(t);
    Reasoner r = rf.create(null);
    a.add(t);
    InfModel im = ModelFactory.createInfModel(r, a);
    return im.validate();
}
Also used : Reasoner(org.apache.jena.reasoner.Reasoner) Model(org.apache.jena.rdf.model.Model) InfModel(org.apache.jena.rdf.model.InfModel) InfModel(org.apache.jena.rdf.model.InfModel)

Example 10 with InfModel

use of org.apache.jena.rdf.model.InfModel in project jena by apache.

the class TestModelFactory method testCreateInfModel.

public void testCreateInfModel() {
    final String rule = "-> (eg:r eg:p eg:v).";
    final Reasoner r = new GenericRuleReasoner(Rule.parseRules(rule));
    final InfGraph ig = r.bind(ModelFactory.createDefaultModel().getGraph());
    final InfModel im = ModelFactory.createInfModel(ig);
    JenaTestBase.assertInstanceOf(InfModel.class, im);
    Assert.assertEquals(1, im.size());
}
Also used : InfGraph(org.apache.jena.reasoner.InfGraph) GenericRuleReasoner(org.apache.jena.reasoner.rulesys.GenericRuleReasoner) Reasoner(org.apache.jena.reasoner.Reasoner) GenericRuleReasoner(org.apache.jena.reasoner.rulesys.GenericRuleReasoner) InfModel(org.apache.jena.rdf.model.InfModel)

Aggregations

InfModel (org.apache.jena.rdf.model.InfModel)10 Resource (org.apache.jena.rdf.model.Resource)5 Reasoner (org.apache.jena.reasoner.Reasoner)5 Model (org.apache.jena.rdf.model.Model)4 ArrayList (java.util.ArrayList)2 Property (org.apache.jena.rdf.model.Property)2 TransitiveReasoner (org.apache.jena.reasoner.transitiveReasoner.TransitiveReasoner)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup)1 ExpandingAssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup)1 Node (org.apache.jena.graph.Node)1 NodeIterator (org.apache.jena.rdf.model.NodeIterator)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1 ResIterator (org.apache.jena.rdf.model.ResIterator)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 InfGraph (org.apache.jena.reasoner.InfGraph)1 GenericRuleReasoner (org.apache.jena.reasoner.rulesys.GenericRuleReasoner)1 Rule.parseRule (org.apache.jena.reasoner.rulesys.Rule.parseRule)1 BaseBuiltin (org.apache.jena.reasoner.rulesys.builtins.BaseBuiltin)1