Parsing error in Turtle/N3 ontology
rpgoldman opened this issue · 2 comments
The ontology file here https://github.com/rpgoldman/container-ontology/blob/80a1a88d056bcdeac0eda77698348ff9f41acb82/owl/strateos-catalog-individuals.ttl causes a parsing error in Owlready 2. When I look at the source line in question, it's near the bottom:
#################################################################
# General axioms
#################################################################
[ rdf:type owl:AllDisjointClasses ;
owl:members ( cont:CatalogEntry
cont:CoatingMaterial
cont:Color
cont:LabEquipment
cont:VendorFirm
cont:WellShape
)
] .
The error message and backtrace is as follows:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/.virtualenvs/container-ontology/lib/python3.9/site-packages/owlready2/driver.py in parse(self, f, format, delete_existing_triples, default_base)
153 if not line.endswith("\n"): line = "%s\n" % line
--> 154 s,p,o = splitter.split(line[:-3], 2)
155
ValueError: not enough values to unpack (expected 3, got 1)
The above exception was the direct cause of the following exception:
OwlReadyOntologyParsingError Traceback (most recent call last)
/var/folders/5s/cx04gv9j1mq4gvcv2lw70s400000gn/T/ipykernel_79391/2588599199.py in <module>
----> 1 container_onto: owl.Ontology = owl.get_ontology("https://www.dropbox.com/s/s1e2dzw64m01f9n/container-ontology.ttl").load()
~/.virtualenvs/container-ontology/lib/python3.9/site-packages/owlready2/namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, url, **args)
909 if _LOG_LEVEL: print("* Owlready2 * ...loading ontology %s from %s..." % (self.name, f), file = sys.stderr)
910 fileobj = open(f, "rb")
--> 911 try: new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
912 finally: fileobj.close()
913 else:
~/.virtualenvs/container-ontology/lib/python3.9/site-packages/owlready2/driver.py in parse(self, f, format, delete_existing_triples, default_base)
186 self._add_obj_triple_raw_spo(self.onto.storid, rdf_type, owl_ontology)
187 if current_line:
--> 188 raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s, line %s." % (getattr(f, "name", getattr(f, "url", "???")), current_line)) from e
189 else:
190 raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s." % getattr(f, "name", getattr(f, "url", "???"))) from e
OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in ../owl/container-ontology.ttl, line 1209.
It looks like it is trying to break the line up into three components and is not finding three, perhaps because there is a top level block that (IIUC) corresponds to a blank node?
I had a cursory look at driver.py
and I don't see anything in there that checks for the possibility of a line starting with a [
, so maybe that is the problem?
Both Protege and RDFLib read this file successfully.
Hi,
I had a similar issue. I read the file into a graph using rdflib and serialized it into a format accepted by owlready.
In my case, the NTriples format worked for me.
Good luck
Hi,
I had a similar issue. I read the file into a graph using rdflib and serialized it into a format accepted by owlready. In my case, the NTriples format worked for me.
Good luck
In which format you have converted the file after serialization , and what was your file format before and after serialization, could you please tell me?