Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use id to return a named graph in rdflib-jsonld parser #76

Open
oohlaf opened this issue Mar 14, 2020 · 0 comments
Open

Use id to return a named graph in rdflib-jsonld parser #76

oohlaf opened this issue Mar 14, 2020 · 0 comments

Comments

@oohlaf
Copy link

oohlaf commented Mar 14, 2020

Hi,

Currently I use the following to manually retrieve the identifier from the source data to make sure I get a graph instance back that contains the context identifier set to whatever was in the ID field of the source json data.

But this requires loading the data twice (one time to just read the id and one time by rdflib-json to parse the data). I can see that there is some get_publicID methods, but passing a ConjunctiveGraph().parse does not return a Graph with the identifier from the source. It's a BNode with random number. So below is my workaround.

Is it possible for the parser to return a named graph based on incoming id value of data?

    json_data = json.loads(data)
    identifier = json_data.get("@id", json_data.get("id", None))
    return ConjunctiveGraph().parse(
        data=data, format=AS_JSONLD_MIMETYPE, publicID=identifier
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant