owlapy.converter
Format converter.
Attributes
Classes
Helper class for owl-to-sparql conversion. |
|
Convert owl (owlapy model class expressions) to SPARQL. |
Functions
|
Peek the last element of an array. |
|
Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query |
Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query |
Module Contents
- owlapy.converter.peek(x)[source]
Peek the last element of an array.
- Returns:
The last element arr[-1].
- class owlapy.converter.VariablesMapping[source]
Helper class for owl-to-sparql conversion.
- __slots__ = ('class_cnt', 'prop_cnt', 'ind_cnt', 'dict')
- class_cnt = 0
- prop_cnt = 0
- ind_cnt = 0
- dict
- get_variable(e: owlapy.owl_object.OWLEntity) str [source]
- __contains__(item: owlapy.owl_object.OWLEntity) bool [source]
- __getitem__(item: owlapy.owl_object.OWLEntity) str [source]
- class owlapy.converter.Owl2SparqlConverter[source]
Convert owl (owlapy model class expressions) to SPARQL.
- __slots__ = ('ce', 'sparql', 'variables', 'parent', 'parent_var', 'properties', 'variable_entities', 'cnt',...
- sparql: List[str]
- variables: List[str]
- parent: List[owlapy.class_expression.OWLClassExpression]
- parent_var: List[str]
- variable_entities: Set[owlapy.owl_object.OWLEntity]
- properties: Dict[int, List[owlapy.owl_object.OWLEntity]]
- mapping: VariablesMapping
- grouping_vars: Dict[owlapy.class_expression.OWLClassExpression, Set[str]]
- having_conditions: Dict[owlapy.class_expression.OWLClassExpression, Set[str]]
- cnt: int
- for_all_de_morgan: bool
- named_individuals: bool
- convert(root_variable: str, ce: owlapy.class_expression.OWLClassExpression, for_all_de_morgan: bool = True, named_individuals: bool = False)[source]
Used to convert owl class expression to SPARQL syntax.
- Parameters:
root_variable (str) – Root variable name that will be used in SPARQL query.
ce (OWLClassExpression) – The owl class expression to convert.
named_individuals (bool) – If ‘True’ return only entities that are instances of owl:NamedIndividual.
- Returns:
The SPARQL query.
- Return type:
list[str]
- property modal_depth
- stack_parent(parent: owlapy.class_expression.OWLClassExpression)[source]
- property current_variable
- abstract process(ce: owlapy.class_expression.OWLClassExpression)[source]
- forAllDeMorgan(ce: owlapy.class_expression.OWLObjectAllValuesFrom)[source]
- as_query(root_variable: str, ce: owlapy.class_expression.OWLClassExpression, for_all_de_morgan: bool = True, count: bool = False, values: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None = None, named_individuals: bool = False) str [source]
- as_confusion_matrix_query(root_variable: str, ce: owlapy.class_expression.OWLClassExpression, positive_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual], negative_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual], for_all_de_morgan: bool = True, named_individuals: bool = False) str [source]
- owlapy.converter.converter
- owlapy.converter.owl_expression_to_sparql(expression: owlapy.class_expression.OWLClassExpression = None, root_variable: str = '?x', values: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None = None, for_all_de_morgan: bool = True, named_individuals: bool = False) str [source]
Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query root variable: the variable that will be projected expression: the class expression to be transformed to a SPARQL query
values: positive or negative examples from a class expression problem. Unclear for_all_de_morgan: if set to True, the SPARQL mapping will use the mapping containing the nested FILTER NOT EXISTS patterns for the universal quantifier (¬(∃r.¬C)), instead of the counting query named_individuals: if set to True, the generated SPARQL query will return only entities that are instances of owl:NamedIndividual
- owlapy.converter.owl_expression_to_sparql_with_confusion_matrix(expression: owlapy.class_expression.OWLClassExpression, positive_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None, negative_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None, root_variable: str = '?x', for_all_de_morgan: bool = True, named_individuals: bool = False) str [source]
Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query root variable: the variable that will be projected expression: the class expression to be transformed to a SPARQL query positive_examples: positive examples from a class expression problem negative_examples: positive examples from a class expression problem for_all_de_morgan: if set to True, the SPARQL mapping will use the mapping containing the nested FILTER NOT EXISTS patterns for the universal quantifier (¬(∃r.¬C)), instead of the counting query named_individuals: if set to True, the generated SPARQL query will return only entities that are instances of owl:NamedIndividual