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);
}
}
}
}
}
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());
}
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");
}
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();
}
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());
}
Aggregations