org.dllearner.reasoning
Class FastInstanceChecker

java.lang.Object
  extended by org.dllearner.core.AbstractComponent
      extended by org.dllearner.core.AbstractReasonerComponent
          extended by org.dllearner.reasoning.FastInstanceChecker
All Implemented Interfaces:
BaseReasoner, Component, FuzzyIndividualReasoner, IndividualReasoner, Reasoner, ReasonerComponent, SchemaReasoner

public class FastInstanceChecker
extends AbstractReasonerComponent

Reasoner for fast instance checks. It works by completely dematerialising the knowledge base to speed up later reasoning requests. It then continues by only considering one model of the knowledge base (TODO: more explanation), which is neither correct nor complete, but sufficient in many cases. A big advantage of the algorithm is that it does not need even need to perform any set modifications (union, intersection, difference), so it avoids any Java object creation, which makes it extremely fast compared to standard reasoners. Meanwhile, the algorithm has been extended to also perform fast retrieval operations. However, those need write access to memory and potentially have to deal with all individuals in a knowledge base. For many knowledge bases, they should still be reasonably fast.

Author:
Jens Lehmann

Constructor Summary
FastInstanceChecker(Set<AbstractKnowledgeSource> sources)
          Creates an instance of the fast instance checker.
 
Method Summary
<T> void
applyConfigEntry(ConfigEntry<T> entry)
          Applies a configuration option to this component.
static Collection<ConfigOption<?>> createConfigOptions()
           
 String getBaseURI()
          Returns the base URI of the knowledge base.
 SortedSet<DatatypeProperty> getBooleanDatatypePropertiesImpl()
           
 FastInstanceCheckerConfigurator getConfigurator()
          For each component, a configurator class is generated in package org.dllearner.core.configurators using the script { org.dllearner.scripts.ConfigJavaGenerator}.
 Map<Individual,SortedSet<Constant>> getDatatypeMembersImpl(DatatypeProperty datatypeProperty)
           
 SortedSet<DatatypeProperty> getDatatypePropertiesImpl()
           
 Description getDomainImpl(DatatypeProperty datatypeProperty)
           
 Description getDomainImpl(ObjectProperty objectProperty)
           
 Map<Individual,SortedSet<Double>> getDoubleDatatypeMembersImpl(DatatypeProperty datatypeProperty)
           
 SortedSet<DatatypeProperty> getDoubleDatatypePropertiesImpl()
           
 SortedSet<Individual> getFalseDatatypeMembersImpl(DatatypeProperty datatypeProperty)
           
 SortedSet<Individual> getIndividuals()
          Gets all individuals in the knowledge base, e.g.
 SortedSet<Individual> getIndividualsImpl(Description concept)
           
 SortedSet<Individual> getIndividualsImplFast(Description description)
           
 SortedSet<Individual> getIndividualsImplStandard(Description concept)
           
 Map<Individual,SortedSet<Integer>> getIntDatatypeMembersImpl(DatatypeProperty datatypeProperty)
           
 SortedSet<DatatypeProperty> getIntDatatypePropertiesImpl()
           
 Set<Constant> getLabelImpl(Entity entity)
           
static String getName()
           
 Set<NamedClass> getNamedClasses()
          Gets all named classes in the knowledge base, e.g.
 Set<ObjectProperty> getObjectProperties()
          Gets all object properties in the knowledge base, e.g. hasChild, isCapitalOf, hasEngine.
 Map<String,String> getPrefixes()
          Returns the prefixes used in the knowledge base, e.g. foaf for foaf: .
 Map<Individual,SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole)
           
 Description getRangeImpl(ObjectProperty objectProperty)
           
 ReasonerType getReasonerType()
          Gets the type of the underlying reasoner.
 Set<Individual> getRelatedIndividualsImpl(Individual individual, ObjectProperty objectProperty)
           
 Set<Constant> getRelatedValuesImpl(Individual individual, DatatypeProperty datatypeProperty)
           
 SortedSet<DatatypeProperty> getStringDatatypePropertiesImpl()
           
 SortedSet<Individual> getTrueDatatypeMembersImpl(DatatypeProperty datatypeProperty)
           
 boolean hasTypeImpl(Description description, Individual individual)
           
 void init()
          Method to be called after the component has been configured.
 boolean isSatisfiableImpl()
           
 boolean isSuperClassOfImpl(Description superConcept, Description subConcept)
           
static void main(String[] args)
          Test method for fast instance checker.
 void releaseKB()
          Call this method to release the knowledge base.
 boolean remainsSatisfiableImpl(Axiom axiom)
           
 
Methods inherited from class org.dllearner.core.AbstractReasonerComponent
changeSources, doubleRetrieval, getAssertedDefinitions, getAtomicConceptsList, getAtomicConceptsList, getAtomicRolesList, getBooleanDatatypeMembers, getBooleanDatatypeProperties, getClassHierarchy, getDatatypeMembers, getDatatypeProperties, getDatatypePropertyHierarchy, getDomain, getDomain, getDoubleDatatypeMembers, getDoubleDatatypeProperties, getFalseDatatypeMembers, getFuzzyIndividuals, getInconsistentClasses, getIndividuals, getInstanceCheckReasoningTimeNs, getIntDatatypeMembers, getIntDatatypeProperties, getLabel, getMostGeneralDatatypeProperties, getMostGeneralProperties, getMostSpecialDatatypeProperties, getMostSpecialProperties, getNrOfInstanceChecks, getNrOfMultiInstanceChecks, getNrOfMultiSubsumptionChecks, getNrOfRetrievals, getNrOfSubsumptionChecks, getNrOfSubsumptionHierarchyQueries, getObjectPropertyHierarchy, getObjectPropertyRelationships, getOverallReasoningTimeNs, getPropertyMembers, getRange, getRange, getRelatedIndividuals, getRelatedValues, getRetrievalReasoningTimeNs, getSources, getStringDatatypeMembers, getStringDatatypeProperties, getSubClasses, getSubProperties, getSubProperties, getSubsumptionReasoningTimeNs, getSuperClasses, getSuperProperties, getSuperProperties, getTimePerInstanceCheckNs, getTimePerRetrievalNs, getTimePerSubsumptionCheckNs, getTrueDatatypeMembers, getTypes, hasType, hasType, hasTypeFuzzyMembership, isEquivalentClass, isSatisfiable, isSuperClassOf, isSuperClassOf, prepareDatatypePropertyHierarchy, prepareRoleHierarchy, prepareSubsumptionHierarchy, remainsSatisfiable, resetStatistics, setUpdated, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastInstanceChecker

public FastInstanceChecker(Set<AbstractKnowledgeSource> sources)
Creates an instance of the fast instance checker.

Parameters:
sources - The knowledge sources used as input.
Method Detail

getConfigurator

public FastInstanceCheckerConfigurator getConfigurator()
Description copied from class: AbstractComponent
For each component, a configurator class is generated in package org.dllearner.core.configurators using the script { org.dllearner.scripts.ConfigJavaGenerator}. The configurator provides set and get methods for the configuration options of a component.

Specified by:
getConfigurator in class AbstractComponent
Returns:
An object allowing to configure this component.

createConfigOptions

public static Collection<ConfigOption<?>> createConfigOptions()
Returns:
The options of this component.

applyConfigEntry

public <T> void applyConfigEntry(ConfigEntry<T> entry)
                      throws InvalidConfigOptionValueException
Description copied from class: AbstractComponent
Applies a configuration option to this component. Implementations of components should use option and value of the config entry to perform an action (usually setting an internal variable to an appropriate value). Since the availability of configurators, it is optional for components to implement this method. Instead of using this method to take an action based on a configuration value, components can also use the getters defined in the components configurator. Important note: Never call this method directly. All calls are done via the ComponentManager.

Type Parameters:
T - Type of the config entry (Integer, String etc.).
Parameters:
entry - A configuration entry.
Throws:
InvalidConfigOptionValueException - This exception is thrown if the value of the config entry is not valid. For instance, a config option may only accept values, which are within intervals 0.1 to 0.3 or 0.5 to 0.8. If the value is outside of those intervals, an exception is thrown. Note that many of the common cases are already caught in the constructor of ConfigEntry (for instance for a DoubleConfigOption you can specify an interval for the value). This means that, as a component developer, you often do not need to implement further validity checks.
See Also:
AbstractComponent.getConfigurator()

getName

public static String getName()
Returns:
The name of this component.

init

public void init()
          throws ComponentInitException
Description copied from interface: Component
Method to be called after the component has been configured. Implementation of components can overwrite this method to perform setup and initialisation tasks for this component.

Throws:
ComponentInitException - This exception is thrown if any exceptions occur within the initialisation process of this component. As component developer, you are encouraged to rethrow occuring exception as ComponentInitException and giving an error message as well as the actualy exception by using the constructor ComponentInitException.ComponentInitException(String, Throwable).

hasTypeImpl

public boolean hasTypeImpl(Description description,
                           Individual individual)
                    throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

getIndividualsImpl

public SortedSet<Individual> getIndividualsImpl(Description concept)
                                         throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

getIndividualsImplStandard

public SortedSet<Individual> getIndividualsImplStandard(Description concept)
                                                 throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

getIndividualsImplFast

public SortedSet<Individual> getIndividualsImplFast(Description description)
                                             throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

getNamedClasses

public Set<NamedClass> getNamedClasses()
Description copied from interface: BaseReasoner
Gets all named classes in the knowledge base, e.g. Person, City, Car.

Returns:
All named classes in KB.

getObjectProperties

public Set<ObjectProperty> getObjectProperties()
Description copied from interface: BaseReasoner
Gets all object properties in the knowledge base, e.g. hasChild, isCapitalOf, hasEngine.

Returns:
All object properties in KB.

getDatatypePropertiesImpl

public SortedSet<DatatypeProperty> getDatatypePropertiesImpl()

getBooleanDatatypePropertiesImpl

public SortedSet<DatatypeProperty> getBooleanDatatypePropertiesImpl()

getDoubleDatatypePropertiesImpl

public SortedSet<DatatypeProperty> getDoubleDatatypePropertiesImpl()

getIntDatatypePropertiesImpl

public SortedSet<DatatypeProperty> getIntDatatypePropertiesImpl()

getStringDatatypePropertiesImpl

public SortedSet<DatatypeProperty> getStringDatatypePropertiesImpl()

getIndividuals

public SortedSet<Individual> getIndividuals()
Description copied from interface: BaseReasoner
Gets all individuals in the knowledge base, e.g. Eric, London, Car829.

Returns:
All individuals in KB.

getReasonerType

public ReasonerType getReasonerType()
Description copied from class: AbstractReasonerComponent
Gets the type of the underlying reasoner. Although rarely necessary, applications can use this to adapt their behaviour to the reasoner.

Specified by:
getReasonerType in class AbstractReasonerComponent
Returns:
The reasoner type.

isSuperClassOfImpl

public boolean isSuperClassOfImpl(Description superConcept,
                                  Description subConcept)

main

public static void main(String[] args)
                 throws ComponentInitException,
                        ParseException,
                        ReasoningMethodUnsupportedException
Test method for fast instance checker.

Parameters:
args - No arguments supported.
Throws:
ComponentInitException - Component cannot be initialised.
ParseException - File cannot be parsed.
ReasoningMethodUnsupportedException - Reasoning method not supported.

getBaseURI

public String getBaseURI()
Description copied from interface: BaseReasoner
Returns the base URI of the knowledge base. If several knowledge sources are used, we only pick one of their base URIs.

Returns:
The base URI, e.g. http://dbpedia.org/resource/.

getPrefixes

public Map<String,String> getPrefixes()
Description copied from interface: BaseReasoner
Returns the prefixes used in the knowledge base, e.g. foaf for foaf: . If several knowledge sources are used, their prefixes are merged. (In case a prefix is defined twice with different values, we pick one of those.)

Returns:
The prefix mapping.

getDomainImpl

public Description getDomainImpl(ObjectProperty objectProperty)

getDomainImpl

public Description getDomainImpl(DatatypeProperty datatypeProperty)

getRangeImpl

public Description getRangeImpl(ObjectProperty objectProperty)

getPropertyMembersImpl

public Map<Individual,SortedSet<Individual>> getPropertyMembersImpl(ObjectProperty atomicRole)

getTrueDatatypeMembersImpl

public final SortedSet<Individual> getTrueDatatypeMembersImpl(DatatypeProperty datatypeProperty)

getFalseDatatypeMembersImpl

public final SortedSet<Individual> getFalseDatatypeMembersImpl(DatatypeProperty datatypeProperty)

getIntDatatypeMembersImpl

public Map<Individual,SortedSet<Integer>> getIntDatatypeMembersImpl(DatatypeProperty datatypeProperty)

getDoubleDatatypeMembersImpl

public Map<Individual,SortedSet<Double>> getDoubleDatatypeMembersImpl(DatatypeProperty datatypeProperty)

getDatatypeMembersImpl

public Map<Individual,SortedSet<Constant>> getDatatypeMembersImpl(DatatypeProperty datatypeProperty)

getRelatedIndividualsImpl

public Set<Individual> getRelatedIndividualsImpl(Individual individual,
                                                 ObjectProperty objectProperty)
                                          throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

getRelatedValuesImpl

public Set<Constant> getRelatedValuesImpl(Individual individual,
                                          DatatypeProperty datatypeProperty)
                                   throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

isSatisfiableImpl

public boolean isSatisfiableImpl()

getLabelImpl

public Set<Constant> getLabelImpl(Entity entity)
                           throws ReasoningMethodUnsupportedException
Throws:
ReasoningMethodUnsupportedException

releaseKB

public void releaseKB()
Description copied from class: AbstractReasonerComponent
Call this method to release the knowledge base. Not calling the method may (depending on the underlying reasoner) result in resources for this knowledge base not being freed, which can cause memory leaks.

Specified by:
releaseKB in class AbstractReasonerComponent

remainsSatisfiableImpl

public boolean remainsSatisfiableImpl(Axiom axiom)


SourceForge.net Logo DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2011 Jens Lehmann