From f1e14dae3c8b1579d99f0bc9367e553be2b39cb5 Mon Sep 17 00:00:00 2001 From: Alkid Date: Tue, 23 Apr 2024 15:32:46 +0200 Subject: [PATCH 01/10] fixed bug with imports --- owlapy/class_expression/restriction.py | 2 +- owlapy/owl_axiom.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/owlapy/class_expression/restriction.py b/owlapy/class_expression/restriction.py index 60c4698e..6488181f 100644 --- a/owlapy/class_expression/restriction.py +++ b/owlapy/class_expression/restriction.py @@ -2,7 +2,7 @@ from abc import ABCMeta, abstractmethod from ..meta_classes import HasFiller, HasCardinality, HasOperands from typing import TypeVar, Generic, Final, Sequence, Union, Iterable -from .nary_boolean_expression import OWLObjectIntersectionOf +from .nary_boolean_expression import OWLObjectIntersectionOf, OWLObjectUnionOf from .class_expression import OWLAnonymousClassExpression, OWLClassExpression from ..owl_property import OWLPropertyExpression, OWLObjectPropertyExpression, OWLDataPropertyExpression from ..owl_data_ranges import OWLPropertyRange, OWLDataRange diff --git a/owlapy/owl_axiom.py b/owlapy/owl_axiom.py index 25f87d97..4fd4119f 100644 --- a/owlapy/owl_axiom.py +++ b/owlapy/owl_axiom.py @@ -1,5 +1,6 @@ """OWL Axioms""" from abc import ABCMeta, abstractmethod +from itertools import combinations from typing import TypeVar, List, Optional, Iterable, Generic, Final, Union from .owl_property import OWLDataPropertyExpression, OWLObjectPropertyExpression @@ -7,7 +8,7 @@ from .owl_datatype import OWLDatatype, OWLDataRange from .meta_classes import HasOperands from .owl_property import OWLPropertyExpression, OWLProperty -from .class_expression import OWLClassExpression, OWLClass +from .class_expression import OWLClassExpression, OWLClass, OWLNothing, OWLThing, OWLObjectUnionOf from .owl_individual import OWLIndividual from .iri import IRI from owlapy.owl_annotation import OWLAnnotationSubject, OWLAnnotationValue From daf8de6199f93883b6887bb84d52f114c776b867 Mon Sep 17 00:00:00 2001 From: Alkid Date: Tue, 23 Apr 2024 15:34:12 +0200 Subject: [PATCH 02/10] v1.0.1 -> bug fixing release --- docs/usage/main.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage/main.md b/docs/usage/main.md index ec7079e4..54935778 100644 --- a/docs/usage/main.md +++ b/docs/usage/main.md @@ -1,6 +1,6 @@ # About owlapy -**Version:** owlapy 1.0.0 +**Version:** owlapy 1.0.1 **GitHub repository:** [https://github.com/dice-group/owlapy](https://github.com/dice-group/owlapy) diff --git a/setup.py b/setup.py index bd31da52..36905a94 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="owlapy", description="OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.", - version="1.0.0", + version="1.0.1", packages=find_packages(), install_requires=[ "pandas>=1.5.0", From 9a01e89600f4b78ee23467a30c3aa5fcdccbb63d Mon Sep 17 00:00:00 2001 From: Alkid Date: Fri, 26 Apr 2024 15:32:33 +0200 Subject: [PATCH 03/10] changed order of input arguments #29 --- owlapy/converter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/owlapy/converter.py b/owlapy/converter.py index 3751db55..8ad93936 100644 --- a/owlapy/converter.py +++ b/owlapy/converter.py @@ -587,10 +587,10 @@ def as_query(self, converter = Owl2SparqlConverter() -def owl_expression_to_sparql(root_variable: str = "?x", - expression: OWLClassExpression = None, +def owl_expression_to_sparql(expression: OWLClassExpression = None, + root_variable: str = "?x", values: Optional[Iterable[OWLNamedIndividual]] = None, - named_individuals: bool = False)->str: + named_individuals: bool = False) -> str: """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 From 37f5c216c3a2aecf13a9c92762d955c82b6a0ebf Mon Sep 17 00:00:00 2001 From: Alkid Date: Fri, 26 Apr 2024 15:39:36 +0200 Subject: [PATCH 04/10] updated usage of owl_expression_to_sparql --- README.md | 2 +- docs/usage/usage_examples.md | 2 +- tests/test_examples.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e8b74015..89d2b227 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ teacher_that_hasChild_male = OWLObjectIntersectionOf([hasChild_male, teacher]) # You can render and print owl class expressions in description logics syntax (and vice-versa) print(owl_expression_to_dl(teacher_that_hasChild_male)) # (∃ hasChild.male) ⊓ teacher -print(owl_expression_to_sparql("?x", teacher_that_hasChild_male)) +print(owl_expression_to_sparql(teacher_that_hasChild_male)) # SELECT DISTINCT ?x WHERE { ?x ?s_1 . ?s_1 a . ?x a . } } ``` diff --git a/docs/usage/usage_examples.md b/docs/usage/usage_examples.md index 531b249c..41413dc8 100644 --- a/docs/usage/usage_examples.md +++ b/docs/usage/usage_examples.md @@ -101,7 +101,7 @@ from owlapy import owl_expression_to_sparql, owl_expression_to_dl, owl_expressio print(owl_expression_to_dl(ce)) # Result: male ⊓ (≥ 1 hasChild.person) -print(owl_expression_to_sparql(expression=ce)) +print(owl_expression_to_sparql(ce)) # Result: SELECT DISTINCT ?x WHERE { ?x a . { SELECT ?x WHERE { ?x ?s_1 . ?s_1 a . } GROUP BY ?x HAVING ( COUNT ( ?s_1 ) >= 1 ) } } print(owl_expression_to_manchester(ce)) diff --git a/tests/test_examples.py b/tests/test_examples.py index c7d3f297..926696c7 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -20,7 +20,7 @@ def test_readme(self): male_teachers_with_children = OWLObjectIntersectionOf([males_with_children, teacher]) assert owl_expression_to_dl(male_teachers_with_children)=="(∃ hasChild.male) ⊓ teacher" - assert owl_expression_to_sparql("?x", male_teachers_with_children)=="""SELECT + assert owl_expression_to_sparql(male_teachers_with_children)=="""SELECT DISTINCT ?x WHERE { ?x ?s_1 . ?s_1 a . From b5029826c3ec9025b02a010dfe584233d0bcadb9 Mon Sep 17 00:00:00 2001 From: Alkid Date: Fri, 26 Apr 2024 22:25:01 +0200 Subject: [PATCH 05/10] added type restriction for fillers of OWLQuantifiedDataRestriction and OWLDataCardinalityRestriction --- owlapy/class_expression/restriction.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/owlapy/class_expression/restriction.py b/owlapy/class_expression/restriction.py index 6488181f..04e7a4bc 100644 --- a/owlapy/class_expression/restriction.py +++ b/owlapy/class_expression/restriction.py @@ -461,6 +461,7 @@ class OWLQuantifiedDataRestriction(OWLQuantifiedRestriction[OWLDataRange], _filler: OWLDataRange def __init__(self, filler: OWLDataRange): + assert isinstance(filler, OWLDataRange), "filler must be an OWLDataRange" self._filler = filler def get_filler(self) -> OWLDataRange: @@ -478,6 +479,7 @@ class OWLDataCardinalityRestriction(OWLCardinalityRestriction[OWLDataRange], @abstractmethod def __init__(self, cardinality: int, property: OWLDataPropertyExpression, filler: OWLDataRange): + assert isinstance(filler, OWLDataRange), "filler must be an OWLDataRange" super().__init__(cardinality, filler) self._property = property From 8b7472fe17f623cb25ef10fb76bf36918aaafe85 Mon Sep 17 00:00:00 2001 From: Alkid Date: Fri, 26 Apr 2024 22:25:56 +0200 Subject: [PATCH 06/10] fixed bug for type assertion when converting OWLDataHasValue --- owlapy/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owlapy/converter.py b/owlapy/converter.py index 8ad93936..c83dbe50 100644 --- a/owlapy/converter.py +++ b/owlapy/converter.py @@ -498,7 +498,7 @@ def _(self, ce: OWLDataAllValuesFrom): def _(self, ce: OWLDataHasValue): property_expression = ce.get_property() value = ce.get_filler() - assert isinstance(value, OWLDataProperty) + assert isinstance(value, OWLLiteral) self.append_triple(self.current_variable, property_expression, value) @process.register From c98913b01c8b604a5f88b8dcc7eb2875a6ba7dc9 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 3 May 2024 20:25:19 +0200 Subject: [PATCH 07/10] _OWLLiteralImplBoolean.get_literal() implemented to return lower case string representation of True/False boolean values --- owlapy/owl_literal.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/owlapy/owl_literal.py b/owlapy/owl_literal.py index 0dff1362..d9b1487a 100644 --- a/owlapy/owl_literal.py +++ b/owlapy/owl_literal.py @@ -183,6 +183,8 @@ def get_datatype(self) -> OWLDatatype: The OWLDatatype that types this literal. """ pass + + @total_ordering class _OWLLiteralImplDouble(OWLLiteral): __slots__ = '_v' @@ -222,6 +224,8 @@ def parse_double(self) -> float: def get_datatype(self) -> OWLDatatype: # documented in parent return DoubleOWLDatatype + + @total_ordering class _OWLLiteralImplInteger(OWLLiteral): __slots__ = '_v' @@ -275,6 +279,14 @@ def __init__(self, value, type_=None): value = bool(strtobool(value)) self._v = value + def get_literal(self) -> str: + """Gets the lexical value of this literal. Note that the language tag is not included. + boolean True/False should be true/false in string + Returns: + The lexical value of this literal. + """ + return str(self._v).lower() + def __eq__(self, other): if type(other) is type(self): return self._v == other._v @@ -297,6 +309,8 @@ def parse_boolean(self) -> bool: def get_datatype(self) -> OWLDatatype: # documented in parent return BooleanOWLDatatype + + @total_ordering class _OWLLiteralImplString(OWLLiteral): __slots__ = '_v' @@ -339,6 +353,8 @@ def parse_string(self) -> str: def get_datatype(self) -> OWLDatatype: # documented in parent return StringOWLDatatype + + @total_ordering class _OWLLiteralImplDate(OWLLiteral): __slots__ = '_v' From 238e9ae8ccda0d33714f19b4d730a8a31c13c688 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 3 May 2024 20:29:20 +0200 Subject: [PATCH 08/10]
Click me! are removed --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 89d2b227..7b60b004 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ OWL Ontologies. Have a look at the [Documentation](https://dice-group.github.io/owlapy/). ## Installation -
Click me! - ### Installation from Source ``` bash git clone https://github.com/dice-group/owlapy @@ -17,11 +15,9 @@ or ```bash pip3 install owlapy ``` -
-## Usage -
Click me! +## Usage In this example we start with a simple atomic class expression and move to some more complex ones and finally render and print the last of them in description logics syntax. @@ -59,7 +55,6 @@ class. In the above examples we have introduced 3 types of class expressions: Like we showed in this example, you can create all kinds of class expressions using the OWL objects in [owlapy api](https://dice-group.github.io/owlapy/autoapi/owlapy/index.html). -
## How to cite Currently, we are working on our manuscript describing our framework. From 6b5ef879cb4ae926217f6adff7a9bbe2e4f83e26 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 3 May 2024 20:31:46 +0200 Subject: [PATCH 09/10] python version and owlapy version is increased --- README.md | 1 + owlapy/__init__.py | 2 +- setup.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7b60b004..7581ca0e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ pip3 install owlapy ## Usage + In this example we start with a simple atomic class expression and move to some more complex ones and finally render and print the last of them in description logics syntax. diff --git a/owlapy/__init__.py b/owlapy/__init__.py index 99a85cf0..124f7215 100644 --- a/owlapy/__init__.py +++ b/owlapy/__init__.py @@ -1,4 +1,4 @@ from .render import owl_expression_to_dl, owl_expression_to_manchester from .parser import dl_to_owl_expression, manchester_to_owl_expression from .converter import owl_expression_to_sparql -__version__ = '1.0.0' +__version__ = '1.0.2' diff --git a/setup.py b/setup.py index 36905a94..9c0918fc 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="owlapy", description="OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.", - version="1.0.1", + version="1.0.2", packages=find_packages(), install_requires=[ "pandas>=1.5.0", @@ -16,10 +16,10 @@ author_email='caglardemir8@gmail.com', url='https://github.com/dice-group/owlapy', classifiers=[ - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.10.13", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Topic :: Scientific/Engineering"], - python_requires='>=3.10', + python_requires='>=3.10.13', long_description=long_description, long_description_content_type="text/markdown", ) From 3910f04a464e3bfb96dc5f34141e5ac9f210e65d Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 3 May 2024 20:36:49 +0200 Subject: [PATCH 10/10] python version fixed --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 95a2e886..10bf2fc9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ "3.10.11" ] + python-version: [ "3.10.13" ] max-parallel: 5 steps: