diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ada6ba..ccd89d0 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/__init__.py b/owlapy/__init__.py index 10939f0..8ce9b36 100644 --- a/owlapy/__init__.py +++ b/owlapy/__init__.py @@ -1 +1 @@ -__version__ = '0.1.2' +__version__ = '0.1.3' diff --git a/owlapy/model/__init__.py b/owlapy/model/__init__.py index e8ea7b7..707d624 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 @@ -245,6 +237,14 @@ def get_nnf(self) -> 'OWLClass': # documented in parent return self + @property + 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.""" @@ -408,6 +408,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 5e34844..9fe9874 100644 --- a/owlapy/model/_iri.py +++ b/owlapy/model/_iri.py @@ -147,11 +147,30 @@ 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() + + @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. diff --git a/owlapy/owl2sparql/converter.py b/owlapy/owl2sparql/converter.py index 9b6ef4c..3229fdf 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) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e8c9818..0000000 --- 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 diff --git a/setup.py b/setup.py index 690a4b7..4c138d6 100644 --- a/setup.py +++ b/setup.py @@ -6,20 +6,21 @@ 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", "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", )