From 9c170e0b723bef8fe4d1c0b5fec417decec73d10 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Wed, 27 Mar 2024 14:20:58 +0100 Subject: [PATCH 1/6] setup is updated. --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 690a4b7d..5f508633 100644 --- a/setup.py +++ b/setup.py @@ -11,15 +11,16 @@ install_requires=[ "pandas>=1.5.0", "rdflib>=6.0.2", - "parsimonious>=0.8.1"], - author='Ontolearn Team', + "parsimonious>=0.8.1", + "pytest>=8.1.1"], + author='Caglar Demir', author_email='caglardemir8@gmail.com', url='https://github.com/dice-group/owlapy', classifiers=[ - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Topic :: Scientific/Engineering"], - python_requires='>=3.8', + python_requires='>=3.10', long_description=long_description, long_description_content_type="text/markdown", ) From fdfc143d3e505a8150381d075e1f5cf2c490d736 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Thu, 28 Mar 2024 11:20:45 +0100 Subject: [PATCH 2/6] Test for github action is added. str property is added for Owlclass, IRI, and OwlObjectProb. --- .github/workflows/test.yml | 53 +++++++++++++++++--------------------- owlapy/model/__init__.py | 7 +++++ owlapy/model/_iri.py | 10 +++++++ 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ada6ba7..ccd89d03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,29 +1,24 @@ -#name: Python package -# -#on: [push,pull_request] -# -#jobs: -# build: -# runs-on: ubuntu-latest -# strategy: -# matrix: -# python-version: ["3.9"] -# max-parallel: 5 -# steps: -# - uses: actions/checkout@v3 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.python-version }} -# -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# pip install -r requirements.txt -# -# - name: Test with pytest -# run: | -# pip install pytest -# wget https://files.dice-research.org/projects/Ontolearn/KGs.zip -# unzip KGs.zip -# pytest -p no:warnings -x \ No newline at end of file +name: Python package + +on: [push,pull_request] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10.13"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + + - name: Test with pytest + run: | + python -m pytest -p no:warnings -x diff --git a/owlapy/model/__init__.py b/owlapy/model/__init__.py index e8ea7b72..734064e1 100644 --- a/owlapy/model/__init__.py +++ b/owlapy/model/__init__.py @@ -245,6 +245,9 @@ def get_nnf(self) -> 'OWLClass': # documented in parent return self + @property + def str(self): + return self.get_iri().as_str() class OWLPropertyExpression(OWLObject, metaclass=ABCMeta): """Represents a property or possibly the inverse of a property.""" @@ -408,6 +411,10 @@ def is_owl_top_object_property(self) -> bool: # documented in parent return self.get_iri() == OWLRDFVocabulary.OWL_TOP_OBJECT_PROPERTY.get_iri() + @property + def str(self)->str: + return self.get_iri().as_str() + class OWLObjectInverseOf(OWLObjectPropertyExpression): """Represents the inverse of a property expression (ObjectInverseOf). This can be used to refer to the inverse of diff --git a/owlapy/model/_iri.py b/owlapy/model/_iri.py index 5e348443..a18eb10b 100644 --- a/owlapy/model/_iri.py +++ b/owlapy/model/_iri.py @@ -147,11 +147,21 @@ def as_iri(self) -> 'IRI': def as_str(self) -> str: """ + CD: Should be deprecated. Returns: The string that specifies the IRI. """ return self._namespace + self._remainder + @property + def str(self) -> str: + """ + + Returns: + The string that specifies the IRI. + """ + return self.as_str() + def get_short_form(self) -> str: """Gets the short form. From abb2593efbe3b83b36f207d5f021b3f1fdef6001 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Thu, 28 Mar 2024 12:48:40 +0100 Subject: [PATCH 3/6] TODOs are added for the next release --- owlapy/model/__init__.py | 15 ++++++--------- owlapy/model/_iri.py | 9 +++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/owlapy/model/__init__.py b/owlapy/model/__init__.py index 734064e1..707d6247 100644 --- a/owlapy/model/__init__.py +++ b/owlapy/model/__init__.py @@ -1,12 +1,4 @@ -"""The OWL-APy Model classes and methods. - -Their names should match those of OWL API [1]. - -If OWL API has streaming and getter API, it is enough to provide the streaming API only. - -Many help texts copied from OWL API. - -[1] https://github.com/owlcs/owlapi""" +"""@TODO: CD: This is not a python code. We should refactor this model module.""" from abc import ABCMeta, abstractmethod from functools import total_ordering @@ -249,6 +241,11 @@ def get_nnf(self) -> 'OWLClass': def str(self): return self.get_iri().as_str() + @property + def reminder(self)->str: + """The reminder of the IRI """ + return self.get_iri().get_remainder() + class OWLPropertyExpression(OWLObject, metaclass=ABCMeta): """Represents a property or possibly the inverse of a property.""" __slots__ = () diff --git a/owlapy/model/_iri.py b/owlapy/model/_iri.py index a18eb10b..9fe98744 100644 --- a/owlapy/model/_iri.py +++ b/owlapy/model/_iri.py @@ -162,6 +162,15 @@ def str(self) -> str: """ return self.as_str() + @property + def reminder(self) -> str: + """ + + Returns: + The string corresponding to the reminder of the IRI. + """ + return self.reminder() + def get_short_form(self) -> str: """Gets the short form. From a28ce55f613cf7e4afae858ae3455fd220336a24 Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Thu, 28 Mar 2024 12:53:01 +0100 Subject: [PATCH 4/6] setup.py already installs dependencies --- requirements.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e8c98187..00000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pandas>=1.5.0 -rdflib>=6.0.2 -parsimonious>=0.8.1 \ No newline at end of file From c41d93c4c43ac12ec788797ca67b5a56691f315f Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 29 Mar 2024 11:26:25 +0100 Subject: [PATCH 5/6] version is increment for the next release --- owlapy/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/owlapy/__init__.py b/owlapy/__init__.py index 10939f01..8ce9b362 100644 --- a/owlapy/__init__.py +++ b/owlapy/__init__.py @@ -1 +1 @@ -__version__ = '0.1.2' +__version__ = '0.1.3' diff --git a/setup.py b/setup.py index 5f508633..4c138d64 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ name="owlapy", description="Owlapy is loosely based on owlapi - the java counterpart, " "successfully representing the main owl objects in python.", - version="0.1.2", + version="0.1.3", packages=find_packages(), install_requires=[ "pandas>=1.5.0", From 2901c305744d4f0bbe70bc340445c66d983e482e Mon Sep 17 00:00:00 2001 From: Caglar Demir Date: Fri, 29 Mar 2024 11:28:43 +0100 Subject: [PATCH 6/6] default params added in owl_expression_to_sparql --- owlapy/owl2sparql/converter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/owlapy/owl2sparql/converter.py b/owlapy/owl2sparql/converter.py index 9b6ef4cc..3229fdf6 100644 --- a/owlapy/owl2sparql/converter.py +++ b/owlapy/owl2sparql/converter.py @@ -631,9 +631,10 @@ def as_query(self, converter = Owl2SparqlConverter() -def owl_expression_to_sparql(root_variable: str, - ce: OWLClassExpression, +def owl_expression_to_sparql(root_variable: str = "?x", + ce: OWLClassExpression = None, count: bool = False, values: Optional[Iterable[OWLNamedIndividual]] = None, - named_individuals: bool = False): + named_individuals: bool = False)->str: + """Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query""" return converter.as_query(root_variable, ce, count, values, named_individuals)