w3c / dxwg

Data Catalog Vocabulary (DCAT)
https://w3c.github.io/dxwg/dcat/
Other
139 stars 55 forks source link

owlready2 not playing well with DCAT #1575

Closed digitalrager closed 1 year ago

digitalrager commented 1 year ago

I'm receiving errors from DCAT when trying to pull it into owlready2. This is the most important rdf we would like to leverage but the only rdf that seems to fail. Are there any known issues/fixes for leveraging DCAT with owlready2?

A rough example - happy to answer questions.

from owlready2 import *

dcat_onto = get_ontology("http://www.w3.org/ns/dcat#").load()
onto = get_ontology("https://example/")

onto.imported_ontologies.extend([dcat_onto])

with onto:  
    class Dataset(dcat_onto.Dataset):
        pass

Once that output is save the following code with throw errors when trying to add named entities:

from owlready2 import *

world = World()
onto = world.get_ontology("saved_rdf_file_from_previous.rdf").load()

dataset = onto.Dataset(title="asdf")

This results in an error with the owlready2 parser:

line 755, in _load_by_storid
    return entity
UnboundLocalError: local variable 'entity' referenced before assignment

I have also run across this error when trying to use the rdf:

RDF/XML parsing error in file https://www.w3.org/ns/dcat, line 11, column 2.
digitalrager commented 1 year ago

I think owlready2 is working around the parsing error. Closing this issue.