linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
564 stars 143 forks source link

Refactor the json-ld parser to not use a whole N3 library #349

Open timbl opened 5 years ago

timbl commented 5 years ago

Currently the way JSON-LD parser has been ported into rdflib is a horrible kludge. It parses it, puts it into a store in a separate N3.js library which is imports, then re-serializes it into something which rdflib.js could parse anyway, and then parse that into the rdflib store.

This involves a huge amount of code and a huge amount of time.

Solution is to change the code of the jsonld parser to write directly to the rdflib store.

(This may be a dup of an earlier issue but I could not find that)

jamsden commented 5 years ago

Should include the serializer too.

elf-pavlik commented 5 years ago

Maybe parser could just implement RDF/JS Sink. Big part of RDF/JS goals relates to ease of using various implementations of parsers with various implementations of stores. Actually I see existing JSON-LD parser implementing RDF/JS Sink listed on http://rdf.js.org/

josephguillaume commented 4 years ago

Looks like this change has been merged already in Oct 2019 https://github.com/linkeddata/rdflib.js/commit/16daad7d68d805aa29e8e01bb4a16d77b28b6afe, with some issues still remaining #408 #435 #430

I'm not sure whether the serialiser has been changed or needs to be, and it looks like an RDF/JS Sink approach has not been used, but it seems like this issue can be closed?

josephguillaume commented 4 years ago

It appears the serialisation works by converting to ntriples (https://github.com/linkeddata/rdflib.js/blob/master/src/serialize.ts#L72), then to quads, and finally using jsonld.fromRDF (https://github.com/linkeddata/rdflib.js/blob/master/src/convert.js#L25), but given the title here mentions the parser, perhaps optimising that process should be a new issue?