dice-group / owlapy

OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.
MIT License
16 stars 1 forks source link

AssertionError in Creating a SPARQL query of OWLDataProperty #31

Closed Demirrr closed 5 months ago

Demirrr commented 5 months ago

To reproduce AssertionError

Create a SPARQL containing OWLDataProperty

h=OWLObjectUnionOf((OWLDataHasValue(property=OWLDataProperty(IRI('http://dl-learner.org/carcinogenesis#','amesTestPositive')),value=OWLLiteral(0.0)), OWLDataHasValue(property=OWLDataProperty(IRI('http://dl-learner.org/carcinogenesis#','amesTestPositive')),value=OWLLiteral(1.0))))

DL representation

print(owl_expression_to_dl(h)) # (∃ amesTestPositive.{0.0}) ⊔ (∃ amesTestPositive.{1.0})

Following line throws the assert isinstance(value, OWLDataProperty) .


Traceback (most recent call last):
  File "/home/demir/Desktop/Softwares/Ontolearn/enexa_demo.py", line 25, in <module>
    print(owl_expression_to_sparql(expression=h))
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/site-packages/owlapy/converter.py", line 603, in owl_expression_to_sparql
    return converter.as_query(root_variable, expression, False, values, named_individuals)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/site-packages/owlapy/converter.py", line 567, in as_query
    tp = self.convert(root_variable, ce, named_individuals)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/site-packages/owlapy/converter.py", line 132, in convert
    self.process(ce)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/site-packages/owlapy/converter.py", line 249, in _
    self.process(op)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/home/demir/anaconda3/envs/venv/lib/python3.10/site-packages/owlapy/converter.py", line 501, in _
    assert isinstance(value, OWLDataProperty)
AssertionError
alkidbaci commented 5 months ago

That's definitely a bug. The assertion should be isinstance(value, OWLLiteral). I will be fixing that.