Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into owl2sparql-converter
Browse files Browse the repository at this point in the history
  • Loading branch information
alkidbaci committed Apr 1, 2024
2 parents 06b48d1 + 512e489 commit 2385f3e
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 50 deletions.
53 changes: 24 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
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
2 changes: 1 addition & 1 deletion owlapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.2'
__version__ = '0.1.3'
22 changes: 13 additions & 9 deletions owlapy/model/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions owlapy/model/_iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions owlapy/owl2sparql/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
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",
)

0 comments on commit 2385f3e

Please sign in to comment.