pyowl2.base.annotation
Implements a data structure for representing OWL annotations, which associate specific properties with values to attach metadata to ontology entities without affecting logical semantics.
Description
The implementation models the concept of an annotation within the Web Ontology Language, serving as a container for metadata that enriches ontology elements without altering their logical meaning. It establishes a relationship between an annotation property, which defines the type of metadata, and an annotation value, which holds the actual content such as a literal or IRI. To support complex metadata scenarios, the structure allows for recursive annotations, meaning an annotation can itself be annotated with additional context or provenance information. The design provides mutable access to these core components through properties, enabling dynamic modification of the metadata payload, while also offering string representations for debugging and logging purposes.
Classes
This construct represents a piece of metadata attached to an ontology, axiom, or entity that does not alter the logical semantics of the underlying model. It is defined by a specific property that characterizes the type of metadata, such as a label or comment, and a corresponding value, which may be a literal, an IRI, or an anonymous individual. Users can instantiate this class to enrich ontology elements with human-readable descriptions or provenance data, and it supports recursive annotation to provide context about the annotation itself. By separating non-logical information from the axiomatic structure, it allows for the documentation of entities without impacting automated reasoning tasks. |
Module Contents
UML Class Diagram for OWLAnnotation
- class OWLAnnotation(
- property: pyowl2.base.annotation_property.OWLAnnotationProperty,
- value: pyowl2.abstracts.annotation_value.OWLAnnotationValue,
- annotations: list[Self] = None,
Bases:
pyowl2.abstracts.object.OWLObject
This construct represents a piece of metadata attached to an ontology, axiom, or entity that does not alter the logical semantics of the underlying model. It is defined by a specific property that characterizes the type of metadata, such as a label or comment, and a corresponding value, which may be a literal, an IRI, or an anonymous individual. Users can instantiate this class to enrich ontology elements with human-readable descriptions or provenance data, and it supports recursive annotation to provide context about the annotation itself. By separating non-logical information from the axiomatic structure, it allows for the documentation of entities without impacting automated reasoning tasks.
- Parameters:
annotation_annotations (Optional[list[OWLAnnotation]]) – A list of annotations associated with this annotation, providing additional metadata or context about the annotation itself.
annotation_property (OWLAnnotationProperty) – The property that defines the relationship between the subject and the value, characterizing the specific type of metadata being asserted.
annotation_value (OWLAnnotationValue) – The specific data or content of the annotation, which can be a literal, an IRI, or an anonymous individual, serving as the value associated with the annotation property.
- __str__() str[source]
Returns a string representation of the annotation formatted in a functional style. The output includes the list of meta-annotations, the annotation property, and the annotation value. If no meta-annotations are present, the representation explicitly displays an empty list in their place. This method is useful for debugging or logging to provide a concise summary of the annotation’s structure.
- Returns:
A string representation of the annotation, displaying its annotations, property, and value.
- Return type:
str
- _annotation_annotations: list[OWLAnnotation] | None = None
- _annotation_property: pyowl2.base.annotation_property.OWLAnnotationProperty
- _annotation_value: pyowl2.abstracts.annotation_value.OWLAnnotationValue
- property annotation_annotations: list[Self]
Replaces the current list of annotations associated with this annotation instance with the provided list. The input value must be a list of instances of the same class, representing nested annotations. This method performs a direct assignment, meaning subsequent modifications to the input list will affect the internal state of the object.
- Parameters:
value (list[Self]) – A list of annotation instances of the same type to assign.
- property annotation_property: pyowl2.base.annotation_property.OWLAnnotationProperty
Sets the annotation property for this OWLAnnotation instance to the specified value. This method accepts an object of type OWLAnnotationProperty and updates the internal state of the annotation, overwriting any previously assigned property. As a setter, it modifies the object in place and does not return a value.
- Parameters:
value (OWLAnnotationProperty) – The OWL annotation property instance to assign.
- property annotation_value: pyowl2.abstracts.annotation_value.OWLAnnotationValue
Assigns a new value to the annotation, replacing the current content. The method accepts an instance of OWLAnnotationValue and updates the internal state of the object accordingly. This operation effectively changes the semantic payload of the annotation without altering its property.
- Parameters:
value (OWLAnnotationValue) – The OWL annotation value to set, which can be a literal, IRI, or anonymous individual.