owlapy.utils
Owlapy utils.
Module Contents
Classes
Length calculation of OWLClassExpression |
|
Abstract base class for generic types. |
|
Interface for types with an index; this is used to group objects by type when sorting. |
|
Holder of OWL Objects that can be used for Python sorted. |
|
This class contains functions to transform a Class Expression into Negation Normal Form. |
|
This class contains functions to transform a class expression into Top-Level Conjunctive Normal Form. |
|
This class contains functions to transform a class expression into Top-Level Disjunctive Normal Form. |
|
Constants shares by all lru cache instances. |
Functions
|
|
Shortens an OWLClassExpression or OWLDataRange by combining all nested nary expressions of the same type. |
|
|
Count the number of elements in an iterable. |
|
Cast OWL Object to HasIndex. |
Attributes
- class owlapy.utils.OWLClassExpressionLengthMetric(*, class_length: int, object_intersection_length: int, object_union_length: int, object_complement_length: int, object_some_values_length: int, object_all_values_length: int, object_has_value_length: int, object_cardinality_length: int, object_has_self_length: int, object_one_of_length: int, data_some_values_length: int, data_all_values_length: int, data_has_value_length: int, data_cardinality_length: int, object_property_length: int, object_inverse_length: int, data_property_length: int, datatype_length: int, data_one_of_length: int, data_complement_length: int, data_intersection_length: int, data_union_length: int)[source]
Length calculation of OWLClassExpression
- Parameters:
class_length – Class: “C”
object_intersection_length – Intersection: A ⨅ B
object_union_length – Union: A ⨆ B
object_complement_length – Complement: ¬ C
object_some_values_length – Obj. Some Values: ∃ r.C
object_all_values_length – Obj. All Values: ∀ r.C
object_has_value_length – Obj. Has Value: ∃ r.{I}
object_cardinality_length – Obj. Cardinality restriction: ≤n r.C
object_has_self_length – Obj. Self restriction: ∃ r.Self
object_one_of_length – Obj. One of: ∃ r.{X,Y,Z}
data_some_values_length – Data Some Values: ∃ p.t
data_all_values_length – Data All Values: ∀ p.t
data_has_value_length – Data Has Value: ∃ p.{V}
data_cardinality_length – Data Cardinality restriction: ≤n r.t
object_property_length – Obj. Property: ∃ r.C
object_inverse_length – Inverse property: ∃ r⁻.C
data_property_length – Data Property: ∃ p.t
datatype_length – Datatype: ^^datatype
data_one_of_length – Data One of: ∃ p.{U,V,W}
data_complement_length – Data Complement: ¬datatype
data_intersection_length – Data Intersection: datatype ⨅ datatype
data_union_length – Data Union: datatype ⨆ datatype
- __slots__ = ('class_length', 'object_intersection_length', 'object_union_length',...
- class_length: int
- object_intersection_length: int
- object_union_length: int
- object_complement_length: int
- object_some_values_length: int
- object_all_values_length: int
- object_has_value_length: int
- object_cardinality_length: int
- object_has_self_length: int
- object_one_of_length: int
- data_some_values_length: int
- data_all_values_length: int
- data_has_value_length: int
- data_cardinality_length: int
- object_property_length: int
- object_inverse_length: int
- data_property_length: int
- datatype_length: int
- data_one_of_length: int
- data_complement_length: int
- data_intersection_length: int
- data_union_length: int
- static get_default() OWLClassExpressionLengthMetric [source]
- abstract length(o: owlapy.owl_object.OWLObject) int [source]
- owlapy.utils.measurer
- owlapy.utils.get_expression_length(ce: owlapy.class_expression.OWLClassExpression) int [source]
- class owlapy.utils.EvaluatedDescriptionSet(ordering: Callable[[_N], _O], max_size: int = 10)[source]
Bases:
Generic
[_N
,_O
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- __slots__ = ('items', '_max_size', '_Ordering')
- items: SortedSet[_N]
- class owlapy.utils.HasIndex[source]
Bases:
Protocol
Interface for types with an index; this is used to group objects by type when sorting.
- type_index: ClassVar[int]
- class owlapy.utils.OrderedOWLObject(o: _HasIndex)[source]
Holder of OWL Objects that can be used for Python sorted.
The Ordering is dependent on the type_index of the impl. classes recursively followed by all components of the OWL Object.
- o
OWL object.
- __slots__ = ('o', '_chain')
- o: _HasIndex
- class owlapy.utils.NNF[source]
This class contains functions to transform a Class Expression into Negation Normal Form.
- abstract get_class_nnf(ce: owlapy.class_expression.OWLClassExpression, negated: bool = False) owlapy.class_expression.OWLClassExpression [source]
Convert a Class Expression to Negation Normal Form. Operands will be sorted.
- Parameters:
ce – Class Expression.
negated – Whether the result should be negated.
- Returns:
Class Expression in Negation Normal Form.
- class owlapy.utils.TopLevelCNF[source]
This class contains functions to transform a class expression into Top-Level Conjunctive Normal Form.
- get_top_level_cnf(ce: owlapy.class_expression.OWLClassExpression) owlapy.class_expression.OWLClassExpression [source]
Convert a class expression into Top-Level Conjunctive Normal Form. Operands will be sorted.
- Parameters:
ce – Class Expression.
- Returns:
Class Expression in Top-Level Conjunctive Normal Form.
- class owlapy.utils.TopLevelDNF[source]
This class contains functions to transform a class expression into Top-Level Disjunctive Normal Form.
- get_top_level_dnf(ce: owlapy.class_expression.OWLClassExpression) owlapy.class_expression.OWLClassExpression [source]
Convert a class expression into Top-Level Disjunctive Normal Form. Operands will be sorted.
- Parameters:
ce – Class Expression.
- Returns:
Class Expression in Top-Level Disjunctive Normal Form.
- owlapy.utils.combine_nary_expressions(ce: owlapy.class_expression.OWLClassExpression) owlapy.class_expression.OWLClassExpression [source]
- owlapy.utils.combine_nary_expressions(ce: owlapy.owl_data_ranges.OWLDataRange) owlapy.owl_data_ranges.OWLDataRange
Shortens an OWLClassExpression or OWLDataRange by combining all nested nary expressions of the same type. Operands will be sorted.
E.g. OWLObjectUnionOf(A, OWLObjectUnionOf(C, B)) -> OWLObjectUnionOf(A, B, C).
- owlapy.utils.as_index(o: owlapy.owl_object.OWLObject) HasIndex [source]
Cast OWL Object to HasIndex.
- class owlapy.utils.LRUCache(maxsize: int | None = None)[source]
Bases:
Generic
[_K
,_V
]Constants shares by all lru cache instances.
Adapted from functools.lru_cache.
- sentinel
Unique object used to signal cache misses.
- PREV
Name for the link field 0.
- NEXT
Name for the link field 1.
- KEY
Name for the link field 2.
- RESULT
Name for the link field 3.
- sentinel