/** * Build an inferred model by attaching the given RDF model to the given reasoner. * * @param reasoner the reasoner to use to process the data * @param model the Model containing both instance data and schema assertions to be inferenced over, * any statements added to the InfModel will be added to this underlying data model. */ public static InfModel createInfModel( Reasoner reasoner, Model model ) { InfGraph graph = reasoner.bind(model.getGraph()); return new InfModelImpl(graph); }
/** * Build an inferred model by attaching the given RDF model to the given reasoner. * This form of the call allows two data sets to be merged and reasoned over - * conventionally one contains schema data and one instance data but this is not * a formal requirement. * * @param reasoner the reasoner to use to process the data * @param schema a Model containing RDFS schema data * @param model a Model containing instance data assertions, any statements added to the InfModel * will be added to this underlying data model. */ public static InfModel createInfModel(Reasoner reasoner, Model schema, Model model) { InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
/** Answer the InfCapabilities of this InfGraph. */ @Override public Capabilities getCapabilities() { if (capabilities == null) { return getReasoner().getGraphCapabilities(); } else { return capabilities; } }
@Override public Reasoner create( Resource configuration ) { return rf.create( configuration ).bindSchema( schema ); }
if (om.getReasoner() != null) { if (om.getReasoner() .getReasonerCapabilities().contains( null, ReasonerVocabulary.supportsP, RDFS.subClassOf ))
if (ig != null && ig.getReasoner().supportsProperty( ReasonerVocabulary.directSubClassOf )) {
Reasoner reasoner = new GenericRuleReasoner( customRules ); reasoner.setDerivationLogging(true); inf = ModelFactory.createInfModel(reasoner, model);
/** * Return a prebuilt simplified configuration for the default RDFS reasoner */ public static Reasoner getRDFSSimpleReasoner() { if (theRDFSSimpleReasoner == null) { theRDFSSimpleReasoner = RDFSRuleReasonerFactory.theInstance().create(null); theRDFSSimpleReasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, ReasonerVocabulary.RDFS_SIMPLE); } return theRDFSSimpleReasoner; }
/** Answer a Reasoner created according to the underlying factory, and then loaded with this Wrapper's rules (if the Reasoner is a RuleReasoner) and bound to this Wrapper's schemas (in an unspecified order). */ @Override public Reasoner create( Resource ignored ) { Reasoner result = factory.create( config ); return schemaUnion.isEmpty() ? result : result.bindSchema( schemaUnion ); }
if (getGraph() instanceof InfGraph) { supportsIndAsThing = ((InfGraph) getGraph()).getReasoner() .getReasonerCapabilities() .contains( null, ReasonerVocabulary.supportsP, ReasonerVocabulary.individualAsThingP );
if (!direct || ((ig != null) && ig.getReasoner().supportsProperty( sc ))) {
final Property p = ResourceFactory.createProperty("urn:eg:p"); final Model rawData = ModelFactory.createDefaultModel(); final Resource a = rawData.createResource("urn:a"); final Resource b = rawData.createResource("urn:b"); final Resource c = rawData.createResource("urn:c"); a.addProperty(p, b); b.addProperty(p, c); a.addProperty(p, c); final String rules = "[rule1: (?a urn:eg:p ?b) (?b urn:eg:p ?c) -> (?a urn:eg:p ?c)]"; final Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules)); reasoner.setDerivationLogging(true); final InfModel inf = ModelFactory.createInfModel(reasoner, rawData); assertTrue(inf.contains(a,p,c)); final Iterator<Derivation> d0 = inf.getDerivation(inf.asStatement(Triple.create(a.asNode(), p.asNode(), c.asNode()))); assertFalse(d0.hasNext()); inf.remove(a,p,c); assertTrue(inf.contains(a,p,c)); final Iterator<Derivation> d1 = inf.getDerivation(inf.asStatement(Triple.create(a.asNode(), p.asNode(), c.asNode()))); assertTrue(d1.hasNext());
/** * This method performs inferences creating a new specialized reasoner, which extends the capabilities of * the default one and adds the given rule set. * * @param data * @param rules * @return */ @Override public InfModel run(Model data, List<Rule> rules) { log.debug(" run(Model data, List<Rule> rules)"); InfGraph inferredGraph = customReasoner(rules).bind(data.getGraph()); return ModelFactory.createInfModel(inferredGraph); }
/** * Return a Model through which all the RDFS entailments * derivable from the given data and schema models are accessible. * There is no strict requirement to separate schema and instance data between the two * arguments. * * @param model a Model containing instance data assertions * @param schema a Model containing RDFS schema data */ public static InfModel createRDFSModel( Model schema, Model model ) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
Reasoner reasoner = ReasonerRegistry.getRDFSSimpleReasoner().bindSchema(schema); InfModel inf = ModelFactory.createInfModel(reasoner, config);
Model conf = getReasoner().getReasonerCapabilities(); if (conf != null && conf.contains( null, ReasonerVocabulary.supportsP, ReasonerVocabulary.directSubClassOf ) && getProfile().THING() != null)
useInf = m.getProfile().THING() != null && m.getReasoner() != null && m.getReasoner().supportsProperty( ReasonerVocabulary.individualAsThingP );
/** * This method performs inferences creating a new specialized reasoner, which extends the capabilities of * the default one and adds the given rule set. * * @param data * @param rules * @return */ @Override public InfModel run(Model data, List<Rule> rules) { log.debug(" run(Model data, List<Rule> rules)"); InfGraph inferredGraph = customReasoner(rules).bind(data.getGraph()); return ModelFactory.createInfModel(inferredGraph); }
Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); reasoner = reasoner.bindSchema(schema1); Reasoner reasonerAll = ReasonerRegistry.getOWLReasoner(); reasonerAll.bindSchema(allSchemas);
Model caps = mOnt.getReasoner().getReasonerCapabilities(); if (caps.contains( null, ReasonerVocabulary.supportsP, OWL.ObjectProperty) )