use of org.apache.jena.reasoner.Reasoner in project jena by apache.
the class TestBackchainer method testBaseRules3.
/**
* Test basic rule operations - simple AND rule check with tabling.
*/
public void testBaseRules3() {
List<Rule> rules = Rule.parseRules("[rule: (?a rdfs:subPropertyOf ?c) <- (?a rdfs:subPropertyOf ?b),(?b rdfs:subPropertyOf ?c)]");
Reasoner reasoner = createReasoner(rules);
Graph data = Factory.createGraphMem();
data.add(new Triple(p, sP, q));
data.add(new Triple(q, sP, r));
data.add(new Triple(p, sP, s));
data.add(new Triple(s, sP, t));
data.add(new Triple(a, p, b));
InfGraph infgraph = reasoner.bind(data);
TestUtil.assertIteratorValues(this, infgraph.find(null, RDFS.subPropertyOf.asNode(), null), new Object[] { new Triple(p, sP, q), new Triple(q, sP, r), new Triple(p, sP, s), new Triple(s, sP, t), new Triple(p, sP, t), new Triple(p, sP, r) });
}
use of org.apache.jena.reasoner.Reasoner in project jena by apache.
the class TestFBRules method temp.
/**
* Check cost of creating an empty OWL closure.
*/
public void temp() {
Graph data = Factory.createGraphMem();
Graph data2 = Factory.createGraphMem();
Reasoner reasoner = new OWLFBRuleReasoner(OWLFBRuleReasonerFactory.theInstance());
FBRuleInfGraph infgraph = (FBRuleInfGraph) reasoner.bind(data);
FBRuleInfGraph infgraph2 = (FBRuleInfGraph) reasoner.bind(data2);
long t1 = System.currentTimeMillis();
infgraph.prepare();
long t2 = System.currentTimeMillis();
System.out.println("Prepare on empty graph = " + (t2 - t1) + "ms");
t1 = System.currentTimeMillis();
infgraph2.prepare();
t2 = System.currentTimeMillis();
System.out.println("Prepare on empty graph = " + (t2 - t1) + "ms");
}
use of org.apache.jena.reasoner.Reasoner in project jena by apache.
the class TestFBRules method testSchemaBinding.
/**
* Test schmea partial binding machinery, forward subset.
*/
public void testSchemaBinding() {
String rules = "[testRule1: (n1 p ?a) -> (n2, p, ?a)]" + "[testRule2: (n1 q ?a) -> (n2, q, ?a)]" + "[testRule3: (n2 p ?a), (n2 q ?a) -> (res p ?a)]" + "[testBRule4: (n3 p ?a) <- (n1, p, ?a)]";
List<Rule> ruleList = Rule.parseRules(rules);
Graph schema = Factory.createGraphMem();
schema.add(new Triple(n1, p, n3));
Graph data = Factory.createGraphMem();
data.add(new Triple(n1, q, n4));
data.add(new Triple(n1, q, n3));
Reasoner reasoner = createReasoner(ruleList);
Reasoner boundReasoner = reasoner.bindSchema(schema);
InfGraph infgraph = boundReasoner.bind(data);
TestUtil.assertIteratorValues(this, infgraph.find(null, null, null), new Triple[] { new Triple(n1, p, n3), new Triple(n2, p, n3), new Triple(n3, p, n3), new Triple(n1, q, n4), new Triple(n2, q, n4), new Triple(n1, q, n3), new Triple(n2, q, n3), new Triple(res, p, n3) });
}
use of org.apache.jena.reasoner.Reasoner in project jena by apache.
the class TestOWLMisc method testRangeBug.
/**
* Test bug with leaking variables which results in an incorrect "range = Nothing" deduction.
*/
public void testRangeBug() {
Model model = FileManager.get().loadModel("file:testing/reasoners/bugs/rangeBug.owl");
// Model m = ModelFactory.createDefaultModel();
Reasoner r = ReasonerRegistry.getOWLReasoner();
InfModel omodel = ModelFactory.createInfModel(r, model);
String baseuri = "http://decsai.ugr.es/~ontoserver/bacarex2.owl#";
// Resource js = omodel.getResource(baseuri + "JS");
Resource surname = omodel.getResource(baseuri + "surname");
Statement s = omodel.createStatement(surname, RDFS.range, OWL.Nothing);
assertTrue(!omodel.contains(s));
}
use of org.apache.jena.reasoner.Reasoner in project jena by apache.
the class TestOWLMisc method testLiteralBug.
/**
* Test change of RDF specs to allow plain literals w/o lang and XSD string to be the same.
*/
public void testLiteralBug() {
Model model = FileManager.get().loadModel("file:testing/reasoners/bugs/dtValidation.owl");
// Model m = ModelFactory.createDefaultModel();
Reasoner r = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(r, model);
ValidityReport validity = infmodel.validate();
assertTrue(validity.isValid());
}
Aggregations