Skip to content

Commit 5994940

Browse files
authored
Merge pull request #36 from dice-group/develop
Release
2 parents ea48dc9 + 3910f04 commit 5994940

File tree

11 files changed

+35
-20
lines changed

11 files changed

+35
-20
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [ "3.10.11" ]
16+
python-version: [ "3.10.13" ]
1717
max-parallel: 5
1818

1919
steps:

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ OWL Ontologies.
66
Have a look at the [Documentation](https://dice-group.github.io/owlapy/).
77

88
## Installation
9-
<details><summary> Click me! </summary>
10-
119
### Installation from Source
1210
``` bash
1311
git clone https://github.com/dice-group/owlapy
@@ -17,10 +15,9 @@ or
1715
```bash
1816
pip3 install owlapy
1917
```
20-
</details>
18+
2119

2220
## Usage
23-
<details><summary> Click me! </summary>
2421

2522
In this example we start with a simple atomic class expression and move to some more complex
2623
ones and finally render and print the last of them in description logics syntax.
@@ -46,7 +43,7 @@ teacher_that_hasChild_male = OWLObjectIntersectionOf([hasChild_male, teacher])
4643
# You can render and print owl class expressions in description logics syntax (and vice-versa)
4744
print(owl_expression_to_dl(teacher_that_hasChild_male))
4845
# (∃ hasChild.male) ⊓ teacher
49-
print(owl_expression_to_sparql("?x", teacher_that_hasChild_male))
46+
print(owl_expression_to_sparql(teacher_that_hasChild_male))
5047
# SELECT DISTINCT ?x WHERE { ?x <http://example.com/society#hasChild> ?s_1 . ?s_1 a <http://example.com/society#male> . ?x a <http://example.com/society#teacher> . } }
5148
```
5249

@@ -59,7 +56,6 @@ class. In the above examples we have introduced 3 types of class expressions:
5956

6057
Like we showed in this example, you can create all kinds of class expressions using the
6158
OWL objects in [owlapy api](https://dice-group.github.io/owlapy/autoapi/owlapy/index.html).
62-
</details>
6359

6460
## How to cite
6561
Currently, we are working on our manuscript describing our framework.

docs/usage/main.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# About owlapy
22

3-
**Version:** owlapy 1.0.0
3+
**Version:** owlapy 1.0.1
44

55
**GitHub repository:** [https://github.com/dice-group/owlapy](https://github.com/dice-group/owlapy)
66

docs/usage/usage_examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ from owlapy import owl_expression_to_sparql, owl_expression_to_dl, owl_expressio
101101
print(owl_expression_to_dl(ce))
102102
# Result: male ⊓ (≥ 1 hasChild.person)
103103

104-
print(owl_expression_to_sparql(expression=ce))
104+
print(owl_expression_to_sparql(ce))
105105
# Result: SELECT DISTINCT ?x WHERE { ?x a <http://example.com/family#male> . { SELECT ?x WHERE { ?x <http://example.com/family#hasChild> ?s_1 . ?s_1 a <http://example.com/family#person> . } GROUP BY ?x HAVING ( COUNT ( ?s_1 ) >= 1 ) } }
106106

107107
print(owl_expression_to_manchester(ce))

owlapy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .render import owl_expression_to_dl, owl_expression_to_manchester
22
from .parser import dl_to_owl_expression, manchester_to_owl_expression
33
from .converter import owl_expression_to_sparql
4-
__version__ = '1.0.0'
4+
__version__ = '1.0.2'

owlapy/class_expression/restriction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from abc import ABCMeta, abstractmethod
33
from ..meta_classes import HasFiller, HasCardinality, HasOperands
44
from typing import TypeVar, Generic, Final, Sequence, Union, Iterable
5-
from .nary_boolean_expression import OWLObjectIntersectionOf
5+
from .nary_boolean_expression import OWLObjectIntersectionOf, OWLObjectUnionOf
66
from .class_expression import OWLAnonymousClassExpression, OWLClassExpression
77
from ..owl_property import OWLPropertyExpression, OWLObjectPropertyExpression, OWLDataPropertyExpression
88
from ..owl_data_ranges import OWLPropertyRange, OWLDataRange
@@ -461,6 +461,7 @@ class OWLQuantifiedDataRestriction(OWLQuantifiedRestriction[OWLDataRange],
461461
_filler: OWLDataRange
462462

463463
def __init__(self, filler: OWLDataRange):
464+
assert isinstance(filler, OWLDataRange), "filler must be an OWLDataRange"
464465
self._filler = filler
465466

466467
def get_filler(self) -> OWLDataRange:
@@ -478,6 +479,7 @@ class OWLDataCardinalityRestriction(OWLCardinalityRestriction[OWLDataRange],
478479

479480
@abstractmethod
480481
def __init__(self, cardinality: int, property: OWLDataPropertyExpression, filler: OWLDataRange):
482+
assert isinstance(filler, OWLDataRange), "filler must be an OWLDataRange"
481483
super().__init__(cardinality, filler)
482484
self._property = property
483485

owlapy/converter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def _(self, ce: OWLDataAllValuesFrom):
498498
def _(self, ce: OWLDataHasValue):
499499
property_expression = ce.get_property()
500500
value = ce.get_filler()
501-
assert isinstance(value, OWLDataProperty)
501+
assert isinstance(value, OWLLiteral)
502502
self.append_triple(self.current_variable, property_expression, value)
503503

504504
@process.register
@@ -587,10 +587,10 @@ def as_query(self,
587587
converter = Owl2SparqlConverter()
588588

589589

590-
def owl_expression_to_sparql(root_variable: str = "?x",
591-
expression: OWLClassExpression = None,
590+
def owl_expression_to_sparql(expression: OWLClassExpression = None,
591+
root_variable: str = "?x",
592592
values: Optional[Iterable[OWLNamedIndividual]] = None,
593-
named_individuals: bool = False)->str:
593+
named_individuals: bool = False) -> str:
594594
"""Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query
595595
root variable: the variable that will be projected
596596
expression: the class expression to be transformed to a SPARQL query

owlapy/owl_axiom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""OWL Axioms"""
22
from abc import ABCMeta, abstractmethod
3+
from itertools import combinations
34

45
from typing import TypeVar, List, Optional, Iterable, Generic, Final, Union
56
from .owl_property import OWLDataPropertyExpression, OWLObjectPropertyExpression
67
from .owl_object import OWLObject, OWLEntity
78
from .owl_datatype import OWLDatatype, OWLDataRange
89
from .meta_classes import HasOperands
910
from .owl_property import OWLPropertyExpression, OWLProperty
10-
from .class_expression import OWLClassExpression, OWLClass
11+
from .class_expression import OWLClassExpression, OWLClass, OWLNothing, OWLThing, OWLObjectUnionOf
1112
from .owl_individual import OWLIndividual
1213
from .iri import IRI
1314
from owlapy.owl_annotation import OWLAnnotationSubject, OWLAnnotationValue

owlapy/owl_literal.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def get_datatype(self) -> OWLDatatype:
183183
The OWLDatatype that types this literal.
184184
"""
185185
pass
186+
187+
186188
@total_ordering
187189
class _OWLLiteralImplDouble(OWLLiteral):
188190
__slots__ = '_v'
@@ -222,6 +224,8 @@ def parse_double(self) -> float:
222224
def get_datatype(self) -> OWLDatatype:
223225
# documented in parent
224226
return DoubleOWLDatatype
227+
228+
225229
@total_ordering
226230
class _OWLLiteralImplInteger(OWLLiteral):
227231
__slots__ = '_v'
@@ -275,6 +279,14 @@ def __init__(self, value, type_=None):
275279
value = bool(strtobool(value))
276280
self._v = value
277281

282+
def get_literal(self) -> str:
283+
"""Gets the lexical value of this literal. Note that the language tag is not included.
284+
boolean True/False should be true/false in string
285+
Returns:
286+
The lexical value of this literal.
287+
"""
288+
return str(self._v).lower()
289+
278290
def __eq__(self, other):
279291
if type(other) is type(self):
280292
return self._v == other._v
@@ -297,6 +309,8 @@ def parse_boolean(self) -> bool:
297309
def get_datatype(self) -> OWLDatatype:
298310
# documented in parent
299311
return BooleanOWLDatatype
312+
313+
300314
@total_ordering
301315
class _OWLLiteralImplString(OWLLiteral):
302316
__slots__ = '_v'
@@ -339,6 +353,8 @@ def parse_string(self) -> str:
339353
def get_datatype(self) -> OWLDatatype:
340354
# documented in parent
341355
return StringOWLDatatype
356+
357+
342358
@total_ordering
343359
class _OWLLiteralImplDate(OWLLiteral):
344360
__slots__ = '_v'

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
setup(
66
name="owlapy",
77
description="OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.",
8-
version="1.0.0",
8+
version="1.0.2",
99
packages=find_packages(),
1010
install_requires=[
1111
"pandas>=1.5.0",
@@ -16,10 +16,10 @@
1616
author_email='caglardemir8@gmail.com',
1717
url='https://github.com/dice-group/owlapy',
1818
classifiers=[
19-
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.10.13",
2020
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
2121
"Topic :: Scientific/Engineering"],
22-
python_requires='>=3.10',
22+
python_requires='>=3.10.13',
2323
long_description=long_description,
2424
long_description_content_type="text/markdown",
2525
)

0 commit comments

Comments
 (0)