pyowl2.class_expression.data_min_cardinality
Defines an OWL class expression that restricts individuals to possess a minimum number of values for a specific data property, optionally constrained by a data range.
Description
The implementation models a restriction where an individual must have at least a specific number of data property assertions to be considered a member of the defined class. A non-negative integer cardinality is stored alongside a data property expression to define this constraint, ensuring that the threshold is valid upon initialization. Support for qualified restrictions is provided through an optional data range, which limits the count to only those values that match a specific datatype or set of literals. Properties expose the internal state for modification, and a string representation adhering to OWL functional syntax is generated to describe the restriction structure.
Classes
This class represents a restriction within an ontology that defines a minimum threshold for the number of data values an individual must possess for a specific data property. It functions by combining a non-negative integer cardinality with a data property expression to specify that a valid individual must have at least that many associated values. Users can optionally provide a data range to create a qualified restriction, which constrains the count to only those values that match a specific datatype or set of literals, thereby enabling precise definitions of class characteristics. |
Module Contents
UML Class Diagram for OWLDataMinCardinality
- class OWLDataMinCardinality(
- value: int,
- expression: pyowl2.abstracts.data_property_expression.OWLDataPropertyExpression,
- data_range: pyowl2.abstracts.data_range.OWLDataRange | None = None,
Bases:
pyowl2.abstracts.class_expression.OWLClassExpression
This class represents a restriction within an ontology that defines a minimum threshold for the number of data values an individual must possess for a specific data property. It functions by combining a non-negative integer cardinality with a data property expression to specify that a valid individual must have at least that many associated values. Users can optionally provide a data range to create a qualified restriction, which constrains the count to only those values that match a specific datatype or set of literals, thereby enabling precise definitions of class characteristics.
- Parameters:
cardinality (int) – The minimum number of values an individual must possess for the specified data property, represented as a non-negative integer.
data_property_expression (OWLDataPropertyExpression) – Defines the relationship between the subject individual and the data values subject to the minimum cardinality restriction.
data_range (Optional[OWLDataRange]) – An optional data range that restricts the specific values counted towards the minimum cardinality. If provided, the restriction is qualified, requiring the minimum number of values to belong to this range; otherwise, it applies to any values of the data property.
- __str__() str[source]
Returns a human-readable string representation of the OWL data minimum cardinality restriction, formatted using a functional syntax. The output includes the cardinality value and the associated data property expression, enclosed within parentheses and prefixed by ‘DataMinCardinality’. If a specific data range is defined for the restriction, it is appended to the string; otherwise, the representation consists solely of the cardinality and the property expression.
- Returns:
A string representation of the data minimum cardinality restriction, comprising the cardinality, data property expression, and optionally the data range.
- Return type:
str
- _cardinality: int
- _data_property_expression: pyowl2.abstracts.data_property_expression.OWLDataPropertyExpression
- _data_range: pyowl2.abstracts.data_range.OWLDataRange | None = None
- property cardinality: int
Assigns the provided integer value to the internal _cardinality attribute, thereby updating the minimum cardinality constraint for this OWL data restriction. This operation modifies the object’s state in place. Although the method accepts any integer, standard OWL semantics imply that the value should be non-negative, though this specific implementation does not enforce validation.
- Parameters:
value (int) – The new value for the cardinality.
- property data_property_expression: pyowl2.abstracts.data_property_expression.OWLDataPropertyExpression
Updates the specific data property expression to which this minimum cardinality restriction applies. This setter assigns the provided OWLDataPropertyExpression instance to the internal state, overwriting any existing value. As a side effect, the object’s state is mutated to reflect the new property definition.
- Parameters:
value (OWLDataPropertyExpression) – The OWL data property expression to assign to the object.
- property data_range: pyowl2.abstracts.data_range.OWLDataRange | None
Sets the data range for this OWL minimum cardinality restriction. This method updates the internal state by assigning the provided OWLDataRange instance (or None) to the underlying private attribute, effectively replacing the existing data type constraint that property values must satisfy.
- Parameters:
value (Optional[OWLDataRange]) – The OWL data range to assign, or None to clear the value.
- property is_qualified: bool
Indicates whether this minimum cardinality restriction is qualified by a specific data range. In the context of OWL, a restriction is considered qualified if it limits the count of values to those belonging to a particular data type, rather than applying to all values of the associated data property. This property returns True if a data range is explicitly defined for the restriction, and False otherwise.
- Returns:
True if the data range is not None, indicating the instance is qualified.
- Return type:
bool