Class SubsetExtractor
-
Constructor Summary
ConstructorsConstructorDescriptionSubsetExtractor
(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
excludePrefix
(String prefix) Excludes classes within the given namespace when filling gaps.void
followProperty
(org.semanticweb.owlapi.model.IRI propertyIRI) Adds an object property to follow when filling gaps.Set<org.semanticweb.owlapi.model.OWLClass>
Gets the list of classes that are marked as belonging to a given subset, where the subset is identified by a simple name.Set<org.semanticweb.owlapi.model.OWLClass>
getSubset
(org.semanticweb.owlapi.model.IRI subsetIRI) Gets the list of classes that are marked as belonging to a given subset.Set<org.semanticweb.owlapi.model.OWLClass>
getSubset
(org.semanticweb.owlapi.model.IRI subsetIRI, org.semanticweb.owlapi.model.OWLAnnotationProperty subsetProperty) Gets the list of classes that are marked as belonging to a given subset.void
includeImports
(boolean enabled) Includes or excludes axioms from imported ontologies.void
includePrefix
(String prefix) Only include classes within the given namespace when filling gaps.org.semanticweb.owlapi.model.OWLOntology
makeSubset
(Set<org.semanticweb.owlapi.model.OWLClass> subset) Creates a subset of the ontology.void
setExcludeDangling
(boolean enabled) Enables or disables excluding dangling classes.void
setFillGaps
(boolean enabled) Enables or disables gap filling.
-
Constructor Details
-
SubsetExtractor
public SubsetExtractor(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner) Creates a new instance.- Parameters:
ontology
- The ontology to extract subsets from.reasoner
- The reasoner to use when attempting to fill gaps.
-
-
Method Details
-
setFillGaps
public void setFillGaps(boolean enabled) Enables or disables gap filling.“Gap filling” (the terminology comes from OWLTools) is the process of expanding the initial list of classes to extract to include all classes referred to, directly or not, by any class, object or annotation property within the subset. It is disabled by default.
- Parameters:
enabled
-true
to enable gap filling,false
to disable it.
-
setExcludeDangling
public void setExcludeDangling(boolean enabled) Enables or disables excluding dangling classes.In the context of subset extraction, we define a “dangling” class as a class that has no defining axiom (excluding disjointness axioms) and no annotation assertion axioms. When this option is enabled, dangling classes are excluded from the gap filling process (meaning that we never extend the initial subset to include a dangling class).
This option is only relevant when gap filling is enabled. A dangling class in the initial subset is always included regardless of the status of this option.
- Parameters:
enabled
-true
to exclude dangling classes,false
to include them.
-
includeImports
public void includeImports(boolean enabled) Includes or excludes axioms from imported ontologies. They are included by default.- Parameters:
enabled
-true
to enable the use of axioms from the imported, orfalse
to only use axioms from the main ontology.
-
followProperty
public void followProperty(org.semanticweb.owlapi.model.IRI propertyIRI) Adds an object property to follow when filling gaps.The default behaviour when filling gaps is to include any class referenced from one of the classes in the initial subset, regardless of the relation between the referrer and the referee. When this method is used, classes that are referred as part of a class expression involving an object property will only be included if the object property matches the property added here.
This method may be called several times to allow following several object properties.
Passing a
null
argument disables the following of all relations other than subsumption relations.- Parameters:
propertyIRI
- The IRI of an object property to follow when filling gaps.
-
includePrefix
Only include classes within the given namespace when filling gaps.When filling gaps, by default all referenced classes are included in the extended subset. If this method is used, then only classes whose IRI starts with the specified prefix will be included. This takes precedence over “excluded prefixes” as added by the
excludePrefix(String)
method.This method may be called several times to define several namespaces. A class will be included if its IRI matches any of the included prefixes.
This has no effect on the initial subset. A class from the initial subset will be included even if its IRI does not match any of the included prefixes.
- Parameters:
prefix
- The IRI prefix to include.
-
excludePrefix
Excludes classes within the given namespace when filling gaps.If this method is used, then classes whose IRI starts with the specified prefix will never be included when filling gaps. This method is incompatible with the use of
includePrefix(String)
, which takes precedence if both methods are used on the same instance.This method may be called several times to define several namespaces. A class will be included only if its IRI does not match any of the excluded prefixes.
This has no effect on the initial subset. A class from the initial subset will never be excluded even if its IRI does match one of the excluded prefixes.
- Parameters:
prefix
-
-
getSubset
public Set<org.semanticweb.owlapi.model.OWLClass> getSubset(org.semanticweb.owlapi.model.IRI subsetIRI) Gets the list of classes that are marked as belonging to a given subset.This method assumes that subsets are defined within the ontology using the
oboInOwl:inSubset
annotation property.- Parameters:
subsetIRI
- The IRI of the subset whose classes should be retrieved.- Returns:
- The set of classes that make up the desired subset.
-
getSubset
public Set<org.semanticweb.owlapi.model.OWLClass> getSubset(org.semanticweb.owlapi.model.IRI subsetIRI, org.semanticweb.owlapi.model.OWLAnnotationProperty subsetProperty) Gets the list of classes that are marked as belonging to a given subset.- Parameters:
subsetIRI
- The IRI of the subset whose classes should be retrieved.subsetProperty
- The annotation property used to mark classes as belonging to a subset.- Returns:
- The set of classes that make up the desired subset.
-
getSubset
Gets the list of classes that are marked as belonging to a given subset, where the subset is identified by a simple name.This method is for compatibility with OWLTools’
--subset
option. It assumes (1) that subsets are defined using theoboInOwl:inSubset
annotation property, and (2) that subset IRIs are of the formURIBASE#SUBSET_NAME
.- Parameters:
subsetName
- The name of the subset whose classes should be retrieved.- Returns:
- The set of classes that make up the desired subset.
-
makeSubset
public org.semanticweb.owlapi.model.OWLOntology makeSubset(Set<org.semanticweb.owlapi.model.OWLClass> subset) throws org.semanticweb.owlapi.model.OWLOntologyCreationException Creates a subset of the ontology.- Parameters:
subset
- The initial list of classes that make up the subset.- Returns:
- The created subset, as a new ontology.
- Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
- If an error occurs when creating the ontology object.
-