/** * 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 ); }
/** * 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); }
/** * 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 ); }
/** * 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 model are accessible. Some work is done * when the inferenced model is created but each query will also trigger some * additional inference work. * * @param model the Model containing both instance data and schema assertions to be inferenced over */ public static InfModel createRDFSModel(Model model) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bind( model.getGraph() ); return new InfModelImpl( graph ); }
protected MultiValueMap<ATermAppl, ATermAppl> run(Collection<ATermAppl> classes) { addClasses( classes ); addClasses( m_Names.getAllAnons() ); Reasoner reasoner = new GenericRuleReasoner(new ArrayList<Rule>(m_Rules)); InfGraph inf = reasoner.bind( m_Facts ); inf.prepare(); MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for( ATermAppl c : classes ) { subsumers.add( ATermUtils.BOTTOM, c ); } return subsumers; }
protected MultiValueMap<ATermAppl, ATermAppl> run(Collection<ATermAppl> classes) { addClasses( classes ); addClasses( m_Names.getAllAnons() ); Reasoner reasoner = new GenericRuleReasoner(new ArrayList<Rule>(m_Rules)); InfGraph inf = reasoner.bind( m_Facts ); inf.prepare(); MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for( ATermAppl c : classes ) { subsumers.add( ATermUtils.BOTTOM, c ); } return subsumers; }
/** * <p>Helper method to the constructor, which interprets the spec and generates an appropriate * graph for this model</p> * @param spec The model spec to interpret * @param base The base model, or null */ private static Graph generateGraph( OntModelSpec spec, Graph base ) { // create a empty union graph MultiUnion u = new MultiUnion(); u.addGraph( base ); u.setBaseGraph( base ); Reasoner r = spec.getReasoner(); // if we have a reasoner in the spec, bind to the union graph and return return r == null ? (Graph) u : r.bind( u ); }
/** * Return a new inference graph which is a clone of the current graph * together with an additional set of data premises. The default * implementation loses ALL partial deductions so far. Some subclasses * may be able to a more efficient job. */ public InfGraph cloneWithPremises(Graph premises) { MultiUnion union = new MultiUnion(); Graph raw = getRawGraph(); union.addGraph( raw ); union.setBaseGraph( raw ); union.addGraph( premises ); Graph schema = getSchemaGraph(); if (schema != null) { if (schema instanceof BaseInfGraph) { BaseInfGraph ischema = (BaseInfGraph)schema; Graph sschema = ischema.getSchemaGraph(); if (sschema != null) union.addGraph( sschema ); Graph rschema = ischema.getRawGraph(); if (rschema != null) union.addGraph( rschema ); } } return getReasoner().bind(union); }