/** * Return the raw RDF model being processed (i.e. the argument * to the Reasonder.bind call that created this InfModel). */ @Override public Model getRawModel() { return new ModelCom(getInfGraph().getRawGraph()); }
/** * Perform any initial processing and caching. This call is optional. Most * engines either have negligable set up work or will perform an implicit * "prepare" if necessary. The call is provided for those occasions where * substantial preparation work is possible (e.g. running a forward chaining * rule system) and where an application might wish greater control over when * this prepration is done rather than just leaving to be done at first query time. */ @Override public void prepare() { getInfGraph().prepare(); }
/** * An extension of the Graph.find interface which allows the caller to * encode complex expressions in RDF and then refer to those expressions * within the query triple. For example, one might encode a class expression * and then ask if there are any instances of this class expression in the * InfGraph. * @param subject the subject Node of the query triple, may be a Node in * the graph or a node in the parameter micro-graph or null * @param property the property to be retrieved or null * @param object the object Node of the query triple, may be a Node in * the graph or a node in the parameter micro-graph. * @param param a small graph encoding an expression which the subject and/or * object nodes refer. */ @Override public ExtendedIterator<Triple> find(Node subject, Node property, Node object, Graph param) { return cloneWithPremises(param).find(subject, property, object); }
/** * <p>Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules.</p> * * @return The derivations model, if one is defined, or else null */ @Override public Model getDeductionsModel() { if (m_deductionsModel == null) { InfGraph infGraph = getInfGraph(); if (infGraph != null) { Graph deductionsGraph = infGraph.getDeductionsGraph(); if (deductionsGraph != null) { m_deductionsModel = ModelFactory.createModelForGraph( deductionsGraph ); } } } else { // ensure that the cached model sees the updated changes from the // underlying reasoner graph getInfGraph().prepare(); } return m_deductionsModel; }
boolean ok = false; InfGraph inf = context.getGraph(); Graph raw = inf.getRawGraph(); Graph deductions = inf.getDeductionsGraph(); for (int i = 0; i < length; i++) { Node clauseN = getArg(i, args, context);
Model model = old.getModel() ; Graph graph = model.getGraph() ; Graph rawGraph = graph instanceof InfGraph ? ((InfGraph) graph).getRawGraph() : graph ; Resource newRes = model.createResource(uri) ; Node newResAsNode = newRes.asNode() ; ((InfGraph) graph).rebind() ;
graph.setDerivationLogging(recordDerivations); graph.rebind(data); return graph;
/** * Check an argument graph to make sure it is not an OWL rule graph * already and if so log a warning message. */ private void checkArgGraph(Graph g) { if (JenaParameters.enableOWLRuleOverOWLRuleWarnings) { if (g instanceof InfGraph) { if (((InfGraph)g).getReasoner() instanceof OWLFBRuleReasoner) { logger.warn("Creating OWL rule reasoner working over another OWL rule reasoner"); } } } } }
/** * Return the derivation of the given statement (which should be the result of * some previous list operation). * Not all reasoneers will support derivations. * @return an iterator over Derivation records or null if there is no derivation information * available for this triple. */ @Override public Iterator<Derivation> getDerivation(Statement statement) { return getInfGraph().getDerivation(statement.asTriple()); }
/** * Reset any internal caches. Some systems, such as the tabled backchainer, * retain information after each query. A reset will wipe this information preventing * unbounded memory use at the expense of more expensive future queries. A reset * does not cause the raw data to be reconsulted and so is less expensive than a rebind. */ @Override public void reset() { getInfGraph().reset(); }
/** * Switch on/off drivation logging. If this is switched on then every time an inference * is a made that fact is recorded and the resulting record can be access through a later * getDerivation call. This may consume a lot of space! */ @Override public void setDerivationLogging(boolean logOn) { getInfGraph().setDerivationLogging(logOn); }
/** * Cause the inference model to reconsult the underlying data to take * into account changes. Normally changes are made through the InfModel's add and * remove calls are will be handled appropriately. However, in some cases changes * are made "behind the InfModels's back" and this forces a full reconsult of * the changed data. */ @Override public void rebind() { getInfGraph().rebind(); }
/** * Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules. * @return the deductions model, if relevant for this class of inference * engine or null if not. */ @Override public Model getDeductionsModel() { Graph deductionsGraph = getInfGraph().getDeductionsGraph(); if (deductionsGraph != null) { if (deductionsModel == null || (deductionsModel.getGraph() != deductionsGraph) ) { deductionsModel = new ModelCom(deductionsGraph); } } return deductionsModel; }
graph.setDerivationLogging(recordDerivations); graph.rebind(data); return graph;
/** * Return the Reasoner which is being used to answer queries to this graph. */ @Override public Reasoner getReasoner() { return getInfGraph().getReasoner(); }
/** * Return the derivation of the given statement (which should be the result of * some previous list operation). * Not all reasoneers will support derivations. * @return an iterator over Derivation records or null if there is no derivation information * available for this triple. */ @Override public Iterator<Derivation> getDerivation(Statement statement) { return (getGraph() instanceof InfGraph) ? ((InfGraph) getGraph()).getDerivation( statement.asTriple() ) : null; }
/** * Reset any internal caches. Some systems, such as the tabled backchainer, * retain information after each query. A reset will wipe this information preventing * unbounded memory use at the expense of more expensive future queries. A reset * does not cause the raw data to be reconsulted and so is less expensive than a rebind. */ @Override public void reset() { if (getGraph() instanceof InfGraph) { ((InfGraph) getGraph()).reset(); } }
/** * Switch on/off drivation logging. If this is switched on then every time an inference * is a made that fact is recorded and the resulting record can be access through a later * getDerivation call. This may consume a lot of space! */ @Override public void setDerivationLogging(boolean logOn) { if (getGraph() instanceof InfGraph) { ((InfGraph) getGraph()).setDerivationLogging( logOn ); } }
/** * Cause the inference model to reconsult the underlying data to take * into account changes. Normally changes are made through the InfModel's add and * remove calls are will be handled appropriately. However, in some cases changes * are made "behind the InfModels's back" and this forces a full reconsult of * the changed data. */ @Override public void rebind() { if (getGraph() instanceof InfGraph) { ((InfGraph) getGraph()).rebind(); } }
/** * Get the single static precomputed rule closure. */ protected synchronized InfGraph getPreload() { if (cachePreload && preload == null) { preload = (new FBRuleInfGraph(this, rules, null)); preload.prepare(); } return preload; }