public class SimpleReasoner extends org.apache.jena.rdf.listeners.StatementListener implements org.apache.jena.rdf.model.ModelChangedListener, ChangeListener
| Constructor and Description |
|---|
SimpleReasoner(org.apache.jena.ontology.OntModel tboxModel,
org.apache.jena.ontology.OntModel aboxModel,
org.apache.jena.rdf.model.Model inferenceModel)
This constructor is used for the unit tests only
|
SimpleReasoner(org.apache.jena.ontology.OntModel tboxModel,
RDFService rdfService,
org.apache.jena.rdf.model.Model inferenceModel,
org.apache.jena.rdf.model.Model inferenceRebuildModel,
org.apache.jena.rdf.model.Model scratchpadModel,
SearchIndexer searchIndexer) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addedInverseProperty(org.apache.jena.ontology.OntProperty prop1,
org.apache.jena.ontology.OntProperty prop2,
org.apache.jena.rdf.model.Model inferenceModel)
If it is added that P is an inverse of Q, then:
1.
|
void |
addedStatement(org.apache.jena.rdf.model.Statement stmt) |
protected void |
addedSubClass(org.apache.jena.ontology.OntClass subClass,
org.apache.jena.ontology.OntClass superClass,
org.apache.jena.rdf.model.Model inferenceModel)
If it is added that B is a subClass of A, then for each
individual that is typed as B, either in the ABox or in the
inferred model, infer that it is of type A.
|
void |
addedTBoxStatement(org.apache.jena.rdf.model.Statement stmt)
Performs incremental ABox reasoning based
on changes to the class hierarchy.
|
void |
addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel)
Add an inference from the inference model
Adds the inference to the inference model if it is not already in
the inference model and not in the abox model.
|
protected void |
addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs) |
protected void |
addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs,
boolean checkRedundancy) |
protected void |
changedTBoxStatement(org.apache.jena.rdf.model.Statement stmt,
boolean add)
Performs incremental ABox reasoning based
on changes to the class hierarchy.
|
protected void |
doPlugins(ModelUpdate.Operation op,
org.apache.jena.rdf.model.Statement stmt) |
protected boolean |
entailedStatement(org.apache.jena.rdf.model.Statement stmt)
Returns true if the triple is entailed by inverse property
reasoning or sameAs reasoning; otherwise returns false.
|
protected boolean |
entailedType(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Resource cls)
Returns true if it is entailed by class subsumption that
subject is of type cls; otherwise returns false.
|
protected boolean |
entailedType(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Resource cls,
List<String> remainingTypeURIs)
Returns true if it is entailed by class subsumption that
subject is of type cls; otherwise returns false.
|
protected org.apache.jena.rdf.model.Model |
generateInverseInferences(org.apache.jena.ontology.OntProperty prop,
org.apache.jena.ontology.OntProperty inverseProp) |
protected List<org.apache.jena.ontology.OntProperty> |
getInverseProperties(org.apache.jena.rdf.model.Statement stmt)
Returns a list of properties that are inverses of the property
in the given statement.
|
protected List<org.apache.jena.rdf.model.Resource> |
getParents(org.apache.jena.rdf.model.Resource cls,
org.apache.jena.ontology.OntModel tboxModel) |
List<ReasonerPlugin> |
getPluginList() |
protected List<String> |
getRemainingAssertedTypeURIs(org.apache.jena.rdf.model.Resource resource) |
boolean |
getSameAsEnabled() |
protected List<org.apache.jena.rdf.model.Resource> |
getSameIndividuals(org.apache.jena.rdf.model.Resource ind,
org.apache.jena.rdf.model.Model inferenceModel)
Get a list of individuals the same as the given individual
|
protected List<org.apache.jena.rdf.model.Resource> |
getSubClasses(org.apache.jena.rdf.model.Resource cls) |
protected List<org.apache.jena.rdf.model.Resource> |
getSuperClasses(org.apache.jena.rdf.model.Resource cls) |
boolean |
isABoxReasoningAsynchronous()
Asynchronous reasoning mode (DeltaComputer) no longer used
in the case of batch removals.
|
protected boolean |
isInterestedInRemovedStatement(org.apache.jena.rdf.model.Statement stmt) |
boolean |
isRecomputing()
Returns true if the reasoner is in the process of recomputing all
inferences.
|
void |
notifyEvent(org.apache.jena.rdf.model.Model model,
Object event) |
void |
notifyEvent(String string,
Object event)
Override this to listen to events pertaining to the given graphURI.
|
void |
notifyModelChange(ModelChange modelChange)
Override this to listen to each model change
|
void |
recompute() |
protected void |
removedInverseProperty(org.apache.jena.ontology.OntProperty prop1,
org.apache.jena.ontology.OntProperty prop2,
org.apache.jena.rdf.model.Model inferenceModel)
If it is removed that P is an inverse of Q, then:
1.
|
void |
removedStatement(org.apache.jena.rdf.model.Statement stmt) |
protected void |
removedSubClass(org.apache.jena.ontology.OntClass subClass,
org.apache.jena.ontology.OntClass superClass,
org.apache.jena.rdf.model.Model inferenceModel)
If removed that B is a subclass of A, then for each individual
that is of type B, either inferred or in the ABox, remove the
assertion that it is of type A from the inferred model,
UNLESS the individual is of some type C that is a subClass
of A (including A itself)
|
void |
removedTBoxStatement(org.apache.jena.rdf.model.Statement stmt)
Performs incremental ABox reasoning based
on changes to the class hierarchy.
|
void |
removeInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel)
Remove an inference from the inference model
Removes the inference if it is not entailed by the abox model
and if the inference model contains it.
|
protected void |
removeInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs,
boolean checkEntailment) |
protected void |
setMostSpecificTypes(org.apache.jena.rdf.model.Resource individual,
HashSet<String> typeURIs,
org.apache.jena.rdf.model.Model inferenceModel) |
protected void |
setMostSpecificTypes(org.apache.jena.rdf.model.Resource individual,
org.apache.jena.rdf.model.Model inferenceModel,
HashSet<String> unknownTypes)
Find the most specific types (classes) of an individual and
infer them for the individual with the mostSpecificType
annotation.
|
void |
setPluginList(List<ReasonerPlugin> pluginList) |
void |
setSameAsEnabled(boolean tf) |
void |
setStopRequested()
This is called when the application shuts down.
|
static String |
stmtString(org.apache.jena.rdf.model.Statement statement)
Utility method for logging
|
addedStatements, addedStatements, addedStatements, addedStatements, removedStatements, removedStatements, removedStatements, removedStatementspublic SimpleReasoner(org.apache.jena.ontology.OntModel tboxModel,
RDFService rdfService,
org.apache.jena.rdf.model.Model inferenceModel,
org.apache.jena.rdf.model.Model inferenceRebuildModel,
org.apache.jena.rdf.model.Model scratchpadModel,
SearchIndexer searchIndexer)
tboxModel - - input. This model contains both asserted and inferred TBox axiomsrdfService - - input. An RDF ServiceinferenceModel - - output. This is the model in which inferred (materialized)
ABox statements are maintained (added or retracted).inferenceRebuildModel - - output. This the model is temporarily used when the
whole ABox inference model is rebuiltscratchpadModel - - output. This the model is temporarily used when
the whole ABox inference model is rebuiltsearchIndexer - - output. If not null, the indexer will be paused before the
ABox inference model is rebuilt and unpaused when the rebuild is complete.public SimpleReasoner(org.apache.jena.ontology.OntModel tboxModel,
org.apache.jena.ontology.OntModel aboxModel,
org.apache.jena.rdf.model.Model inferenceModel)
tboxModel - - input. This model contains both asserted and inferred TBox axiomsaboxModel - - input. This model contains asserted ABox statementsinferenceModel - - output. This is the model in which inferred (materialized)
ABox statements are maintained (added or retracted).public void setPluginList(List<ReasonerPlugin> pluginList)
public List<ReasonerPlugin> getPluginList()
public void setSameAsEnabled(boolean tf)
public boolean getSameAsEnabled()
public void notifyModelChange(ModelChange modelChange)
ChangeListenernotifyModelChange in interface ChangeListenermodelChange - - the object representing the model changepublic void addedStatement(org.apache.jena.rdf.model.Statement stmt)
addedStatement in interface org.apache.jena.rdf.model.ModelChangedListeneraddedStatement in class org.apache.jena.rdf.listeners.StatementListenerpublic void removedStatement(org.apache.jena.rdf.model.Statement stmt)
removedStatement in interface org.apache.jena.rdf.model.ModelChangedListenerremovedStatement in class org.apache.jena.rdf.listeners.StatementListenerprotected void changedTBoxStatement(org.apache.jena.rdf.model.Statement stmt,
boolean add)
public void addedTBoxStatement(org.apache.jena.rdf.model.Statement stmt)
public void removedTBoxStatement(org.apache.jena.rdf.model.Statement stmt)
protected void addedSubClass(org.apache.jena.ontology.OntClass subClass,
org.apache.jena.ontology.OntClass superClass,
org.apache.jena.rdf.model.Model inferenceModel)
protected void removedSubClass(org.apache.jena.ontology.OntClass subClass,
org.apache.jena.ontology.OntClass superClass,
org.apache.jena.rdf.model.Model inferenceModel)
protected void addedInverseProperty(org.apache.jena.ontology.OntProperty prop1,
org.apache.jena.ontology.OntProperty prop2,
org.apache.jena.rdf.model.Model inferenceModel)
protected void removedInverseProperty(org.apache.jena.ontology.OntProperty prop1,
org.apache.jena.ontology.OntProperty prop2,
org.apache.jena.rdf.model.Model inferenceModel)
protected List<org.apache.jena.rdf.model.Resource> getSameIndividuals(org.apache.jena.rdf.model.Resource ind, org.apache.jena.rdf.model.Model inferenceModel)
protected boolean entailedType(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Resource cls)
protected boolean entailedType(org.apache.jena.rdf.model.Resource subject,
org.apache.jena.rdf.model.Resource cls,
List<String> remainingTypeURIs)
protected List<String> getRemainingAssertedTypeURIs(org.apache.jena.rdf.model.Resource resource)
protected List<org.apache.jena.rdf.model.Resource> getSubClasses(org.apache.jena.rdf.model.Resource cls)
protected List<org.apache.jena.rdf.model.Resource> getSuperClasses(org.apache.jena.rdf.model.Resource cls)
protected boolean entailedStatement(org.apache.jena.rdf.model.Statement stmt)
protected List<org.apache.jena.ontology.OntProperty> getInverseProperties(org.apache.jena.rdf.model.Statement stmt)
protected org.apache.jena.rdf.model.Model generateInverseInferences(org.apache.jena.ontology.OntProperty prop,
org.apache.jena.ontology.OntProperty inverseProp)
public void addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel)
protected void addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs)
protected void addInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs,
boolean checkRedundancy)
public void removeInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel)
protected void removeInference(org.apache.jena.rdf.model.Statement infStmt,
org.apache.jena.rdf.model.Model inferenceModel,
boolean handleSameAs,
boolean checkEntailment)
protected void setMostSpecificTypes(org.apache.jena.rdf.model.Resource individual,
org.apache.jena.rdf.model.Model inferenceModel,
HashSet<String> unknownTypes)
protected void setMostSpecificTypes(org.apache.jena.rdf.model.Resource individual,
HashSet<String> typeURIs,
org.apache.jena.rdf.model.Model inferenceModel)
protected List<org.apache.jena.rdf.model.Resource> getParents(org.apache.jena.rdf.model.Resource cls, org.apache.jena.ontology.OntModel tboxModel)
protected boolean isInterestedInRemovedStatement(org.apache.jena.rdf.model.Statement stmt)
protected void doPlugins(ModelUpdate.Operation op, org.apache.jena.rdf.model.Statement stmt)
public boolean isRecomputing()
public void recompute()
public void setStopRequested()
public boolean isABoxReasoningAsynchronous()
public void notifyEvent(String string, Object event)
ChangeListenernotifyEvent in interface ChangeListenerstring - - the graph to which the event pertainsevent - - the event that occurred.public void notifyEvent(org.apache.jena.rdf.model.Model model,
Object event)
notifyEvent in interface org.apache.jena.rdf.model.ModelChangedListenernotifyEvent in class org.apache.jena.rdf.listeners.StatementListenerpublic static String stmtString(org.apache.jena.rdf.model.Statement statement)
Copyright © 2021. All rights reserved.