public InfModel bind(final Model model) throws ReasonerException { _logger.fine("In bind!"); return ModelFactory.createInfModel(bind(model.getGraph())); }
@Override protected Model openEmptyModel( Assembler a, Resource root, Mode mode ) { checkType( root, JA.InfModel ); Model base = getBase( a, root, mode ); Reasoner reasoner = getReasoner( a, root ); InfModel result = ModelFactory.createInfModel( reasoner, base ); return result; }
@Override protected Model openEmptyModel( Assembler a, Resource root, Mode mode ) { checkType( root, JA.InfModel ); Model base = getBase( a, root, mode ); Reasoner reasoner = getReasoner( a, root ); InfModel result = ModelFactory.createInfModel( reasoner, base ); return result; }
private Set<String> getObjectsOfProperty(final Model model, final String subject, final String property) { final InfModel infModel = createInfModel(getOWLMicroReasoner(), createDefaultModel()); infModel.add(model.listStatements()); infModel.add(pcdmModel.listStatements()); return asStream(infModel.listObjectsOfProperty(createResource(subject), createProperty(property))) .filter(RDFNode::isURIResource).map(RDFNode::asResource).map(Resource::getURI).collect(toSet()); } }
/** * Bug that exposed prototypes of owl:Thing despite hiding being switched on. */ public void testHideOnOWLThing() { Reasoner r = ReasonerRegistry.getOWLReasoner(); Model data = ModelFactory.createDefaultModel(); InfModel inf = ModelFactory.createInfModel(r, data); StmtIterator things = inf.listStatements(null, RDF.type, OWL.Thing); TestUtil.assertIteratorLength(things, 0); }
/** * Bug that exposed prototypes of owl:Thing despite hiding being switched on. */ public void testHideOnOWLThing() { Reasoner r = ReasonerRegistry.getOWLReasoner(); Model data = ModelFactory.createDefaultModel(); InfModel inf = ModelFactory.createInfModel(r, data); StmtIterator things = inf.listStatements(null, RDF.type, OWL.Thing); TestUtil.assertIteratorLength(things, 0); }
private Model createForwardChainingModel() { Model baseModel = ModelFactory.createDefaultModel(); Model schemaModel = ModelFactory.createDefaultModel(); Model configurationRuleReasoner = ModelFactory.createDefaultModel(); org.apache.jena.rdf.model.Resource configuration = configurationRuleReasoner.createResource(); configuration.addProperty(ReasonerVocabulary.PROPruleMode, "forward"); configuration.addProperty(ReasonerVocabulary.PROPsetRDFSLevel, ReasonerVocabulary.RDFS_SIMPLE); Reasoner ruleReasoner = RDFSRuleReasonerFactory.theInstance().create(configuration); InfModel inf = ModelFactory.createInfModel(ruleReasoner, schemaModel, baseModel); inf.read(new ByteArrayInputStream(TURTLE_RDF.getBytes()), "", "TURTLE"); return inf; }
/** Problem with bindSchema and validation rules */ public void test_der_validation() { Model abox = FileManager.get().loadModel("file:testing/reasoners/owl/nondetbug.rdf"); List<Rule> rules = FBRuleReasoner.loadRules("testing/reasoners/owl/nondetbug.rules"); GenericRuleReasoner r = new GenericRuleReasoner(rules); // r.setTraceOn(true); for (int i = 0; i < 10; i++) { InfModel im = ModelFactory.createInfModel(r, abox); assertTrue("failed on count " + i, im.contains(null, ReasonerVocabulary.RB_VALIDATION_REPORT, (RDFNode)null)); } }
/** * 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()); }
/** * 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()); }
/** Problem with bindSchema and validation rules */ public void test_der_validation() { Model abox = FileManager.get().loadModel("file:testing/reasoners/owl/nondetbug.rdf"); List<Rule> rules = FBRuleReasoner.loadRules("testing/reasoners/owl/nondetbug.rules"); GenericRuleReasoner r = new GenericRuleReasoner(rules); // r.setTraceOn(true); for (int i = 0; i < 10; i++) { InfModel im = ModelFactory.createInfModel(r, abox); assertTrue("failed on count " + i, im.contains(null, ReasonerVocabulary.RB_VALIDATION_REPORT, (RDFNode)null)); } }
/** * Layering one reasoner on another leads to exposed functors which * used to trip up validation */ public void testLayeredValidation() { Model ont = FileManager.get().loadModel("testing/reasoners/bugs/layeredValidation.owl"); InfModel infModel = ModelFactory.createInfModel(ReasonerRegistry.getOWLReasoner(), ont); OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF, infModel); ValidityReport validity = model.validate(); assertTrue(validity.isClean()); }
private RDFNode doTestLiteralsInErrorReports(String rules) { GenericRuleReasoner reasoner = new GenericRuleReasoner( Rule.parseRules(rules) ); InfModel im = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel()); ValidityReport validity = im.validate(); assertTrue (! validity.isValid()); ValidityReport.Report report = (validity.getReports().next()); assertTrue( report.getExtension() instanceof RDFNode); return (RDFNode)report.getExtension(); }
private RDFNode doTestLiteralsInErrorReports(String rules) { GenericRuleReasoner reasoner = new GenericRuleReasoner( Rule.parseRules(rules) ); InfModel im = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel()); ValidityReport validity = im.validate(); assertTrue (! validity.isValid()); ValidityReport.Report report = (validity.getReports().next()); assertTrue( report.getExtension() instanceof RDFNode); return (RDFNode)report.getExtension(); }
/** * 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(); }
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()); }
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()); }
private void doTestRDFSSimple(String level) { Model model = ModelFactory.createDefaultModel(); String NS = "http://jena.hpl.hp.com/example#"; Property prop = model.createProperty(NS + "prop"); model.add(prop, RDF.type, RDF.Property); Reasoner reasoner = RDFSRuleReasonerFactory.theInstance().create(null); reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, level); InfModel im = ModelFactory.createInfModel(reasoner, model); assertTrue( im.contains(prop, RDFS.subPropertyOf, prop) ); }
private void doTestRDFSSimple(String level) { Model model = ModelFactory.createDefaultModel(); String NS = "http://jena.hpl.hp.com/example#"; Property prop = model.createProperty(NS + "prop"); model.add(prop, RDF.type, RDF.Property); Reasoner reasoner = RDFSRuleReasonerFactory.theInstance().create(null); reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, level); InfModel im = ModelFactory.createInfModel(reasoner, model); assertTrue( im.contains(prop, RDFS.subPropertyOf, prop) ); }
private static void testInfModel(Dataset ds0) { Txn.executeWrite(ds0, ()->{}); Model baseModel = ds0.getDefaultModel(); Model model = ModelFactory.createInfModel(RDFSRuleReasonerFactory.theInstance().create(null), baseModel); if ( model.getGraph().getTransactionHandler().transactionsSupported() ) { // InfModels do not support transactions per se - they particpate if includes in a suitabel dataset. model.begin(); long x = Iter.count(model.listStatements()); model.commit(); assertTrue(x > 10); } }