RDFLib / pyLODE

An OWL ontology documentation tool using Python and templating, based on LODE
BSD 3-Clause "New" or "Revised" License
162 stars 70 forks source link

Should pyLODE be able to parse ontologies specified in JSON LD? #181

Closed FilippoVigani closed 1 year ago

FilippoVigani commented 1 year ago

I'm having some issue trying to process an internal ontology written in JSON LD. The error I get is File "C:\Users\filip\anaconda3\Lib\site-packages\pylode\cli.py", line 72, in <module> main() File "C:\Users\filip\anaconda3\Lib\site-packages\pylode\cli.py", line 47, in main od = OntDoc(args.input) File "C:\Users\filip\anaconda3\Lib\site-packages\pylode\ontdoc.py", line 111, in __init__ self.ns = get_ns(self.ont) File "C:\Users\filip\anaconda3\Lib\site-packages\pylode\utils.py", line 97, in get_ns prefix = ont.compute_qname(default_iri, True)[0] File "C:\Users\filip\anaconda3\Lib\site-packages\rdflib\graph.py", line 1048, in compute_qname return self.namespace_manager.compute_qname(uri, generate) File "C:\Users\filip\anaconda3\Lib\site-packages\rdflib\namespace\__init__.py", line 532, in compute_qname self.__cache[uri] = (prefix, namespace, name) UnboundLocalError: local variable 'name' referenced before assignment

I got the idea that it should be able to parse ontologies such as this (by adding a necessary label), from https://www.gs1.org/voc/, since it uses rdflib. Did I get something wrong or is something missing from the ontology that is necessary?

FilippoVigani commented 1 year ago

It turns out that when specifying the @id for the ontology, using a prefix to reference the IRI from the context doesn't get expanded. The solution for me was to include explicitly the full namespace IRI instead of using just the prefix from the context.