org.dllearner.reasoning
Class SPARQLReasoner

java.lang.Object
  extended by org.dllearner.reasoning.SPARQLReasoner
All Implemented Interfaces:
IndividualReasoner, SchemaReasoner

public class SPARQLReasoner
extends Object
implements SchemaReasoner, IndividualReasoner


Constructor Summary
SPARQLReasoner(SparqlEndpointKS ks)
           
 
Method Summary
 SortedSetTuple<Individual> doubleRetrieval(Description description)
          Performs a query for all instances of the given class description and its negation.
 Set<Description> getAssertedDefinitions(NamedClass namedClass)
          Returns all asserted owl:equivalence class axioms for the given class.
 Map<Individual,SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used if it is known that the property has values which can be parsed as boolean value.
 ClassHierarchy getClassHierarchy()
          Computes and returns the class hierarchy of the knowledge base.
 Map<Individual,SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty)
          Computes and returns all connections between individuals and values through the specified property, e.g.
 DatatypePropertyHierarchy getDatatypePropertyHierarchy()
          Computes and returns the data property hierarchy of the knowledge base.
 Description getDomain(DatatypeProperty datatypeProperty)
          Returns the domain of this data property.
 Description getDomain(ObjectProperty objectProperty)
          Returns the domain of this object property.
 Map<Individual,SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used if it is known that the property has values which can be parsed as double.
 SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used to get all individuals, which have value "false" for the given property.
 Set<NamedClass> getInconsistentClasses()
          Returns all named classes, which are not satisfiable, i.e. cannot have instances.
 SortedSet<Individual> getIndividuals(Description description)
          Gets all instances of a given class description in the knowledge base.
 SortedSet<Individual> getIndividuals(Description description, int limit)
           
 Map<Individual,SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used if it is known that the property has values which can be parsed as integer.
 TreeSet<DatatypeProperty> getMostGeneralDatatypeProperties()
           
 TreeSet<ObjectProperty> getMostGeneralProperties()
          TODO Outdated in OWL 2, because the universal role is the most general.
 TreeSet<DatatypeProperty> getMostSpecialDatatypeProperties()
           
 TreeSet<ObjectProperty> getMostSpecialProperties()
          TODO Outdated in OWL, because the bottom role is the most specific.
 ObjectPropertyHierarchy getObjectPropertyHierarchy()
          Computes and returns the object property hierarchy of the knowledge base.
 Map<ObjectProperty,Set<Individual>> getObjectPropertyRelationships(Individual individual)
          A map of properties related to an individual, e.g.
 Map<Individual,SortedSet<Individual>> getPropertyMembers(ObjectProperty objectProperty)
          Computes and returns all connections between individuals through the specified property, e.g.
 DataRange getRange(DatatypeProperty datatypeProperty)
          Returns the range of this data property.
 Description getRange(ObjectProperty objectProperty)
          Returns the range of this object property.
 Set<Individual> getRelatedIndividuals(Individual individual, ObjectProperty objectProperty)
          Returns the set of individuals, which are connect to the given individual with the specified object property.
 Set<Constant> getRelatedValues(Individual individual, DatatypeProperty datatypeProperty)
          Returns the set of individuals, which are connect to the given individual with the specified data property.
 Map<Individual,SortedSet<String>> getStringDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used which returns the property values as strings (note that any literal can be represented as string, even numbers).
 SortedSet<Description> getSubClasses(Description description)
          Returns direct sub classes in the class hierarchy.
 SortedSet<DatatypeProperty> getSubProperties(DatatypeProperty dataProperty)
          Returns more special concepts in the subsumption hierarchy.
 SortedSet<ObjectProperty> getSubProperties(ObjectProperty objectProperty)
          Returns more special concepts in the subsumption hierarchy.
 SortedSet<Description> getSuperClasses(Description description)
          Returns direct super classes in the class hierarchy.
 SortedSet<Description> getSuperClasses(Description description, boolean direct)
           
 SortedSet<DatatypeProperty> getSuperProperties(DatatypeProperty dataProperty)
          Returns more general concepts in the subsumption hierarchy.
 SortedSet<ObjectProperty> getSuperProperties(ObjectProperty objectProperty)
          Returns more general concepts in the subsumption hierarchy.
 SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty)
          Convenience method, which can be used to get all individuals, which have value "true" for the given property.
 Set<NamedClass> getTypes(Individual individual)
          Returns types of an individual, i.e. those classes where the individual is instance of.
 boolean hasType(Description description, Individual individual)
          Checks whether individual is instance of description.
 SortedSet<Individual> hasType(Description description, Set<Individual> individuals)
          Performs instance checks on a set of instances (reasoners might be more efficient than handling each check separately).
 boolean isEquivalentClass(Description class1, Description class2)
          Checks whether class1 is equivalent to class2.
 boolean isSuperClassOf(Description superClass, Description subClass)
          Checks whether superClass is a super class of subClass.
 Set<Description> isSuperClassOf(Set<Description> superClasses, Description subClasses)
          Checks which of superClasses are super classes of subClass
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPARQLReasoner

public SPARQLReasoner(SparqlEndpointKS ks)
Method Detail

getTypes

public Set<NamedClass> getTypes(Individual individual)
Description copied from interface: IndividualReasoner
Returns types of an individual, i.e. those classes where the individual is instance of. For instance, the individual eric could have type Person.

Specified by:
getTypes in interface IndividualReasoner
Parameters:
individual - An individual in the knowledge base.
Returns:
Types this individual is instance of.

hasType

public boolean hasType(Description description,
                       Individual individual)
Description copied from interface: IndividualReasoner
Checks whether individual is instance of description. For instance, "Leipzig" may be an instance of "City".

Specified by:
hasType in interface IndividualReasoner
Parameters:
description - An OWL class description.
individual - An individual.
Returns:
True if the instance has the description as type and false otherwise.

hasType

public SortedSet<Individual> hasType(Description description,
                                     Set<Individual> individuals)
Description copied from interface: IndividualReasoner
Performs instance checks on a set of instances (reasoners might be more efficient than handling each check separately).

Specified by:
hasType in interface IndividualReasoner
Parameters:
description - An OWL class description.
individuals - An individual.
Returns:
The subset of those instances, which have the given type.

getIndividuals

public SortedSet<Individual> getIndividuals(Description description)
Description copied from interface: IndividualReasoner
Gets all instances of a given class description in the knowledge base.

Specified by:
getIndividuals in interface IndividualReasoner
Parameters:
description - An OWL class description.
Returns:
All instances of the class description.

getIndividuals

public SortedSet<Individual> getIndividuals(Description description,
                                            int limit)

doubleRetrieval

public SortedSetTuple<Individual> doubleRetrieval(Description description)
Description copied from interface: IndividualReasoner
Performs a query for all instances of the given class description and its negation. (Note that in OWL it is possible that the reasoner can neither deduce that an individual is instance of a class nor its negation.) This method might be more efficient that performing a two retrievals.

Specified by:
doubleRetrieval in interface IndividualReasoner
Parameters:
description - An OWL class description.
Returns:
All instances of the class description and its negation.

getRelatedIndividuals

public Set<Individual> getRelatedIndividuals(Individual individual,
                                             ObjectProperty objectProperty)
Description copied from interface: IndividualReasoner
Returns the set of individuals, which are connect to the given individual with the specified object property.

Specified by:
getRelatedIndividuals in interface IndividualReasoner
Parameters:
individual - An individual, e.g. eric.
objectProperty - An object property, e.g. hasChild.
Returns:
A set of individuals, e.g. {anna, maria}.

getRelatedValues

public Set<Constant> getRelatedValues(Individual individual,
                                      DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Returns the set of individuals, which are connect to the given individual with the specified data property.

Specified by:
getRelatedValues in interface IndividualReasoner
Parameters:
individual - An individual, e.g. eric.
Returns:
A set of individuals, e.g. {48000^^xsd:int}.

getObjectPropertyRelationships

public Map<ObjectProperty,Set<Individual>> getObjectPropertyRelationships(Individual individual)
Description copied from interface: IndividualReasoner
A map of properties related to an individual, e.g. {hasChild => {eric,anna}, hasSibling => {sebastian}}.

Specified by:
getObjectPropertyRelationships in interface IndividualReasoner
Parameters:
individual - An individual.
Returns:
A map of of properties connected to the individual as keys and the individuals they point to as values.

getPropertyMembers

public Map<Individual,SortedSet<Individual>> getPropertyMembers(ObjectProperty objectProperty)
Description copied from interface: IndividualReasoner
Computes and returns all connections between individuals through the specified property, e.g. {eric => {maria, anna}, anna => {eric}}.

Specified by:
getPropertyMembers in interface IndividualReasoner
Parameters:
objectProperty - An object property.
Returns:
The mapping of individuals to other individuals through this object property.

getDatatypeMembers

public Map<Individual,SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Computes and returns all connections between individuals and values through the specified property, e.g. {eric => {48000^^xsd:int}, sarah => {56000^^xsd:int}}.

Specified by:
getDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The mapping between individuals and values through the given property.

getDoubleDatatypeMembers

public Map<Individual,SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used if it is known that the property has values which can be parsed as double.

Specified by:
getDoubleDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The mapping between individuals and double values through the given property.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty), Double.valueOf(String)

getIntDatatypeMembers

public Map<Individual,SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used if it is known that the property has values which can be parsed as integer.

Specified by:
getIntDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The mapping between individuals and integer values through the given property.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty), Integer.valueOf(String)

getBooleanDatatypeMembers

public Map<Individual,SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used if it is known that the property has values which can be parsed as boolean value. Only "true" or "false" are accepted. If other values occur, a warning will be issued.

Specified by:
getBooleanDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The mapping between individuals and boolean values through the given property.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty)

getTrueDatatypeMembers

public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used to get all individuals, which have value "true" for the given property. Usually, data properties can have several values for a given individual, but this method will throw a runtime exception if this is the case (i.e. the set of values is {"true", "false"}).

Specified by:
getTrueDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The set of individuals for which the boolean property holds.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty)

getFalseDatatypeMembers

public SortedSet<Individual> getFalseDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used to get all individuals, which have value "false" for the given property. Usually, data properties can have several values for a given individual, but this method will throw a runtime exception if this is the case (i.e. the set of values is {"true", "false"}).

Specified by:
getFalseDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The set of individuals for which the boolean property does not hold.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty)

getStringDatatypeMembers

public Map<Individual,SortedSet<String>> getStringDatatypeMembers(DatatypeProperty datatypeProperty)
Description copied from interface: IndividualReasoner
Convenience method, which can be used which returns the property values as strings (note that any literal can be represented as string, even numbers).

Specified by:
getStringDatatypeMembers in interface IndividualReasoner
Parameters:
datatypeProperty - A data property.
Returns:
The mapping between individuals and string values through the given property.
See Also:
IndividualReasoner.getDatatypeMembers(DatatypeProperty)

getInconsistentClasses

public Set<NamedClass> getInconsistentClasses()
Description copied from interface: SchemaReasoner
Returns all named classes, which are not satisfiable, i.e. cannot have instances.

Specified by:
getInconsistentClasses in interface SchemaReasoner
Returns:
The set of inconsistent classes.

getDomain

public Description getDomain(ObjectProperty objectProperty)
Description copied from interface: SchemaReasoner
Returns the domain of this object property. (Theoretically, there could be more than one domain axiom. However, this can be considered a modelling error.)

Specified by:
getDomain in interface SchemaReasoner
Parameters:
objectProperty - An object property in the knowledge base.
Returns:
The rdfs:domain of objectProperty

getDomain

public Description getDomain(DatatypeProperty datatypeProperty)
Description copied from interface: SchemaReasoner
Returns the domain of this data property.

Specified by:
getDomain in interface SchemaReasoner
Parameters:
datatypeProperty - An data property in the knowledge base.
Returns:
The rdfs:domain of datatypeProperty

getRange

public Description getRange(ObjectProperty objectProperty)
Description copied from interface: SchemaReasoner
Returns the range of this object property.

Specified by:
getRange in interface SchemaReasoner
Parameters:
objectProperty - An object property in the knowledge base.
Returns:
The rdfs:range of objectProperty

getRange

public DataRange getRange(DatatypeProperty datatypeProperty)
Description copied from interface: SchemaReasoner
Returns the range of this data property.

Specified by:
getRange in interface SchemaReasoner
Parameters:
datatypeProperty - An data property in the knowledge base.
Returns:
The rdfs:range of datatypeProperty

isSuperClassOf

public boolean isSuperClassOf(Description superClass,
                              Description subClass)
Description copied from interface: SchemaReasoner
Checks whether superClass is a super class of subClass.

Specified by:
isSuperClassOf in interface SchemaReasoner
Parameters:
superClass - The (supposed) super class.
subClass - The (supposed) sub class.
Returns:
Whether superClass is a super class of subClass.

isEquivalentClass

public boolean isEquivalentClass(Description class1,
                                 Description class2)
Description copied from interface: SchemaReasoner
Checks whether class1 is equivalent to class2.

Specified by:
isEquivalentClass in interface SchemaReasoner
Parameters:
class1 - The first class.
class2 - The second class2.
Returns:
Whether class1 is equivalent to class2.

getAssertedDefinitions

public Set<Description> getAssertedDefinitions(NamedClass namedClass)
Description copied from interface: SchemaReasoner
Returns all asserted owl:equivalence class axioms for the given class.

Specified by:
getAssertedDefinitions in interface SchemaReasoner
Parameters:
namedClass - A named class in the background knowledge.
Returns:
A set of descriptions asserted to be equal to the named class.

isSuperClassOf

public Set<Description> isSuperClassOf(Set<Description> superClasses,
                                       Description subClasses)
Description copied from interface: SchemaReasoner
Checks which of superClasses are super classes of subClass

Specified by:
isSuperClassOf in interface SchemaReasoner
Parameters:
superClasses - A set of (supposed) super classes.
subClasses - The (supposed) sub class.
Returns:
The subset of superClasses, which satisfy the superclass-subclass relationship.

getClassHierarchy

public ClassHierarchy getClassHierarchy()
Description copied from interface: SchemaReasoner
Computes and returns the class hierarchy of the knowledge base.

Specified by:
getClassHierarchy in interface SchemaReasoner
Returns:
The subsumption hierarchy of this knowledge base.

getSuperClasses

public SortedSet<Description> getSuperClasses(Description description)
Description copied from interface: SchemaReasoner
Returns direct super classes in the class hierarchy.

Specified by:
getSuperClasses in interface SchemaReasoner
Parameters:
description - Atomic concept, top, or bottom.
Returns:
A set of more general concepts.

getSuperClasses

public SortedSet<Description> getSuperClasses(Description description,
                                              boolean direct)

getSubClasses

public SortedSet<Description> getSubClasses(Description description)
Description copied from interface: SchemaReasoner
Returns direct sub classes in the class hierarchy.

Specified by:
getSubClasses in interface SchemaReasoner
Parameters:
description - Atomic concept, top, or bottom.
Returns:
A set of more special concepts.

getObjectPropertyHierarchy

public ObjectPropertyHierarchy getObjectPropertyHierarchy()
Description copied from interface: SchemaReasoner
Computes and returns the object property hierarchy of the knowledge base.

Specified by:
getObjectPropertyHierarchy in interface SchemaReasoner
Returns:
The object property hierarchy of the knowlege base.

getSuperProperties

public SortedSet<ObjectProperty> getSuperProperties(ObjectProperty objectProperty)
Description copied from interface: SchemaReasoner
Returns more general concepts in the subsumption hierarchy.

Specified by:
getSuperProperties in interface SchemaReasoner
Parameters:
objectProperty - Atomic concept, top, or bottom.
Returns:
A set of more general concepts.
See Also:
ObjectPropertyHierarchy.getMoreGeneralRoles(ObjectProperty)

getSubProperties

public SortedSet<ObjectProperty> getSubProperties(ObjectProperty objectProperty)
Description copied from interface: SchemaReasoner
Returns more special concepts in the subsumption hierarchy.

Specified by:
getSubProperties in interface SchemaReasoner
Parameters:
objectProperty - Atomic concept, top, or bottom.
Returns:
A set of more special concepts.
See Also:
ObjectPropertyHierarchy.getMoreSpecialRoles(ObjectProperty)

getMostGeneralProperties

public TreeSet<ObjectProperty> getMostGeneralProperties()
Description copied from interface: SchemaReasoner
TODO Outdated in OWL 2, because the universal role is the most general.

Specified by:
getMostGeneralProperties in interface SchemaReasoner
Returns:
The most general roles.
See Also:
ObjectPropertyHierarchy.getMostGeneralRoles()

getMostSpecialProperties

public TreeSet<ObjectProperty> getMostSpecialProperties()
Description copied from interface: SchemaReasoner
TODO Outdated in OWL, because the bottom role is the most specific.

Specified by:
getMostSpecialProperties in interface SchemaReasoner
Returns:
The most special roles.
See Also:
ObjectPropertyHierarchy.getMostSpecialRoles()

getDatatypePropertyHierarchy

public DatatypePropertyHierarchy getDatatypePropertyHierarchy()
Description copied from interface: SchemaReasoner
Computes and returns the data property hierarchy of the knowledge base.

Specified by:
getDatatypePropertyHierarchy in interface SchemaReasoner
Returns:
The data property hierarchy of the knowlege base.

getSuperProperties

public SortedSet<DatatypeProperty> getSuperProperties(DatatypeProperty dataProperty)
Description copied from interface: SchemaReasoner
Returns more general concepts in the subsumption hierarchy.

Specified by:
getSuperProperties in interface SchemaReasoner
Parameters:
dataProperty - Atomic concept, top, or bottom.
Returns:
A set of more general concepts.
See Also:
ObjectPropertyHierarchy.getMoreGeneralRoles(ObjectProperty)

getSubProperties

public SortedSet<DatatypeProperty> getSubProperties(DatatypeProperty dataProperty)
Description copied from interface: SchemaReasoner
Returns more special concepts in the subsumption hierarchy.

Specified by:
getSubProperties in interface SchemaReasoner
Parameters:
dataProperty - Atomic concept, top, or bottom.
Returns:
A set of more special concepts.
See Also:
ObjectPropertyHierarchy.getMoreSpecialRoles(ObjectProperty)

getMostGeneralDatatypeProperties

public TreeSet<DatatypeProperty> getMostGeneralDatatypeProperties()
Specified by:
getMostGeneralDatatypeProperties in interface SchemaReasoner
Returns:
The most general roles.
See Also:
ObjectPropertyHierarchy.getMostGeneralRoles()

getMostSpecialDatatypeProperties

public TreeSet<DatatypeProperty> getMostSpecialDatatypeProperties()
Specified by:
getMostSpecialDatatypeProperties in interface SchemaReasoner
Returns:
The most special roles.
See Also:
ObjectPropertyHierarchy.getMostSpecialRoles()

main

public static void main(String[] args)


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