pyhornedowl.PyIndexedOntology
- class pyhornedowl.PyIndexedOntology(index_strategy=Ellipsis)
 Represents a loaded ontology.
- add_axiom(self, ax: model.Component, annotations: List[model.Annotation] | Set[model.Annotation] | None = None) None
 Synonym for
add_component
- add_component(self, component: model.Component, annotations: List[model.Annotation] | Set[model.Annotation] | None = None) None
 Adds an axiom to the ontology with optional annotations.
- add_prefix_mapping(self, iriprefix: str, mappedid: str) None
 Adds the prefix
iriprefix.
- annotation_property(self, iri: str, *, absolute: bool | None = None) model.AnnotationProperty
 Convenience method to create an annotationProperty from an IRI.
Uses the
irimethod to cache native IRI instances.
- anonymous_individual(self, iri: str) model.AnonymousIndividual
 Convenience method to create an AnonymousIndividual from a string.
- build_component_index()
 component_index(self) -> None
Builds an index by component kind (ComponentMappedIndex).
- build_indexes(self) None
 Builds indexes to allow (a quicker) access to axioms and entities.
- build_iri_index(self) None
 Builds an index by iri (IRIMappedIndex).
- clazz(self, iri: str, *, absolute: bool | None = None) model.Class
 Convenience method to create a Class from an IRI.
Uses the
irimethod to cache native IRI instances.
- curie(self, iri: str) model.IRI
 Creates a new IRI from CURIE string.
Use this method instead of
model.IRI.parseif possible as it is more optimized using caches.
- data_property(self, iri: str, *, absolute: bool | None = None) model.DataProperty
 Convenience method to create a DataProperty from an IRI.
Uses the
irimethod to cache native IRI instances.
- declare_annotation_property(self, iri: str, *, absolute: bool | None = None) bool
 Convenience method to add a Declare(annotationProperty(iri)) axiom.
- declare_class(self, iri: str, *, absolute: bool | None = None) bool
 Convenience method to add a Declare(Class(iri)) axiom.
- declare_data_property(self, iri: str, *, absolute: bool | None = None) bool
 Convenience method to add a Declare(DataProperty(iri)) axiom.
- declare_individual(self, iri: str, *, absolute: bool | None = None) bool
 Convenience method to add a Declare(NamedIndividual(iri)) axiom.
- declare_object_property(self, iri: str, *, absolute: bool | None = None) bool
 Convenience method to add a Declare(ObjectProperty(iri)) axiom.
- get_ancestors(self, child: str, iri_is_absolute: bool | None = None) Set[str]
 Gets all direct and indirect super classes of a class.
- get_annotation(self, class_iri: str, ann_iri: str, *, class_iri_is_absolute: bool | None = None, ann_iri_is_absolute: bool | None = None) str | None
 Gets the first annotated value for an entity and annotation property.
Note: If there are multiple annotation axioms for the queried entity and annotation property, the order is neither necessarily the same as in the ontology neither is it stable. Get all annotation values with
PyIndexedOntology.get_annotations.
- get_annotations(self, class_iri: str, ann_iri: str, *, class_iri_is_absolute: bool | None = None, ann_iri_is_absolute: bool | None = None) List[str]
 Gets all annotated value for an entity and annotation property.
Note: The order is neither necessarily the same as in the ontology neither is it stable. Get all annotation values with
PyIndexedOntology.get_annotations.
- get_axioms(self) List[model.AnnotatedComponent]
 Returns all axioms of the ontology.
- get_axioms_for_iri(self, iri: str, iri_is_absolute: bool | None = None) List[model.AnnotatedComponent]
 Gets all axioms for an entity.
- get_classes(self) Set[str]
 Returns the IRIs of all declared classes in the ontology.
- get_components(self) List[model.AnnotatedComponent]
 Returns all axioms of the ontology.
- get_components_for_iri(self, iri: str, iri_is_absolute: bool | None = None) List[model.AnnotatedComponent]
 Gets all components (axiom, swrl, and meta component) for an entity.
- get_descendants(self, parent: str, iri_is_absolute: bool | None = None) Set[str]
 Gets all direct and indirect subclasses of a class.
- get_id_for_iri(self, iri: str, iri_is_absolute: bool | None = None) str | None
 Gets the ID of term by it IRI.
If the term does not have an ID,
Noneis returned.
- get_iri(self) str | None
 Returns the ontology iri, if it exists.
- get_iri_for_id(self, id: str) str | None
 Gets the IRI of a term by its ID.
If the term does not have an IRI,
Noneis returned.
- get_iri_for_label(self, label: str) str | None
 Returns the IRI of a term by its label if it exists.
If the term does not have a label,
Noneis returned.
- get_object_properties(self) Set[str]
 Returns the IRIs of all declared object properties in the ontology.
- get_subclasses(self, iri: str, iri_is_absolute: bool | None = None) Set[str]
 Gets all subclasses of an entity.
- get_superclasses(self, iri: str, iri_is_absolute: bool | None = None) Set[str]
 Gets all superclasses of an entity.
- get_version_iri(self) str | None
 Returns the ontologys version iri, if it exists.
- iri(self, iri: str, *, absolute: bool | None = True) model.IRI
 Creates a new IRI from string.
Use this method instead of
model.IRI.parseif possible as it is more optimized using caches. Ifabsoluteis None it is guessed by the occurrence of"://"in the IRI whether the iri is absolute or not.
- named_individual(self, iri: str, *, absolute: bool | None = None) model.NamedIndividual
 Convenience method to create a NamedIndividual from an IRI.
Uses the
irimethod to cache native IRI instances.
- object_property(self, iri: str, *, absolute: bool | None = None) model.ObjectProperty
 Convenience method to create an ObjectProperty from an IRI.
Uses the
irimethod to cache native IRI instances.
- prefix_mapping
 prefix_mapping: PrefixMapping
The prefix mapping
- remove_axiom(self, ax: model.Component) bool
 Synonym for
remove_component
- remove_component(self, component: model.Component) bool
 Removes a component from the ontology.
- save_to_file(self, file_name: str, serialization: Literal['owl', 'rdf', 'ofn', 'owx'] | None = None) None
 Saves the ontology to disk. If no serialization is given it is guessed by the file extension. Defaults to OWL/XML
- save_to_string(self, serialization: Literal['owl', 'rdf', 'ofn', 'owx']) str
 Saves the ontology to a UTF8 string.
- set_label(self, iri: str, label: str, *, absolute: bool | None = None) None
 Sets the label of a term by iri.
Adds an or updates the
AnnotationAssertionaxiom forrdfs:label.