ease-crc / soma

The Socio-physical Model of Activities (SOMA) is a formal activity model for embodied agents that need to operate their body to generate motions that cause intentional effects in the physical and social world.
GNU Lesser General Public License v3.0
16 stars 22 forks source link

Python's `owlready2` can't (properly) read the owl files #296

Closed JeremiasThun closed 1 year ago

JeremiasThun commented 1 year ago

The Python module for working with owl files, owlready2, doesn't seem to be able to read the uploaded OWL functional syntax. When loading the soma owl files (onto = get_ontology("/Users/***/soma/owl/SOMA-OBJ")), it returns the error

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/owlready2/driver.py", line 154, in parse
    s,p,o = splitter.split(line[:-3], 2)
ValueError: not enough values to unpack (expected 3, got 2)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/owlready2/namespace.py", line 1086, in load
    try:     new_base_iri = self.graph.parse(fileobj, default_base = self._orig_base_iri, **args)
  File "/usr/local/lib/python3.10/site-packages/owlready2/driver.py", line 188, in parse
    raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s, line %s." % (getattr(f, "name", getattr(f, "url", "???")), current_line)) from e
owlready2.base.OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in /Users/***/soma/owl/SOMA-OBJ.owl, line 9.

This can be avoided by exporting the same owl file to RDF XML Syntax (I used Protege to do that). But reading this file with owlready2 and then saving the unchanged ontology with onto.save("mynewfile.owl", format="rdfxml" returns an owl file, that can't be properly read by protege, as you can see in the resulting class hierarchy:

image
mrnolte commented 1 year ago

I do not believe that this is an Issue of our ontology, but of owlready2 and / or protege. Maybe open an issue there ;)