These are chat archives for rdfjs/public

6th
Feb 2016
elf Pavlik
@elf-pavlik
Feb 06 2016 18:01
@dlongley howdy :wave: could we discuss at some point possibility of publishing JSON-LD, RDF Normalization and Linked Data Signatures algorithms implementation in javascript in more reusable way?
as well as rdf-ext/discussions#20
possibly also relevant for JSON-LD support in rdflib.js https://gitter.im/linkeddata/rdflib.js?at=56b607362bb6eb8230a1d0b4
Dave Longley
@dlongley
Feb 06 2016 19:16
hi @elf-pavlik ... what did you want to know?
Dave Longley
@dlongley
Feb 06 2016 19:28
@elf-pavlik - note that the algorithm was rewritten so the code flow and formatting is a bit cleaner and better matches the way it's laid out in the spec a couple months ago: https://github.com/digitalbazaar/jsonld.js/blob/master/js/jsonld.js#L3846-L4556
it's still async -- if you want to see a sync version there's one in python here: https://github.com/digitalbazaar/pyld/blob/master/lib/pyld/jsonld.py#L4289-L4708
Thomas Bergwinkl
@bergos
Feb 06 2016 19:36
@dlongley @elf-pavlik pointed you already to a comment i wrote. i need a sync version of normalize, so i forked the code. but it would be nice if i could use the jsonld.js code. splitting the code (8000 lines is one of the biggest js source files i know) would help to contribute to the project. at least different files, but also packages would be nice.
Dave Longley
@dlongley
Feb 06 2016 19:44
@bergos -- yeah, it's been a long time goal to add a build system into jsonld.js so it can be split out into different parts and recombined as needed
just never had the time.
why do you need it to be synchronous?
i think, ideally, we'd put the normalization stuff in its own repo -- (with both sync and async versions, if the former is necessary) -- and then pull that into jsonld.js as part of a build process
Thomas Bergwinkl
@bergos
Feb 06 2016 19:47
i'm using it for a .equals method: graph.equals(otherGraph) and that's much easier to use with sync code. i feed it with the internal format. i'm sure there is no i/o call, so no drawback.
Dave Longley
@dlongley
Feb 06 2016 19:48
we (DB) can create a separate repo that just does the normalization stuff -- and then when we can we'll pull that into jsonld.js
Thomas Bergwinkl
@bergos
Feb 06 2016 19:48
yes, that would be cool
Dave Longley
@dlongley
Feb 06 2016 19:48
well, there's still a potential drawback
which is time to compute the normalized dataset (it depends on its size and complexity)
Thomas Bergwinkl
@bergos
Feb 06 2016 19:50
yes, but if i handle a graph that contains to many triples web workers is the way to go. not only normalization.
Dave Longley
@dlongley
Feb 06 2016 19:50
@bergos -- ok, that's an option -- we wrote it async so people didn't have to think about that stuff (and the rest of the API was async anyway) ... but you've got a different use case here ...
so we'll throw together a sync version
ok, when i've got some spare cycles we'll sync+async normalize calls in a repo for reuse
Thomas Bergwinkl
@bergos
Feb 06 2016 19:51
:+1:
Dave Longley
@dlongley
Feb 06 2016 19:52
will probably take a few iterations to get the inputs/outputs the way we want them to be given that you guys are defining a new in-memory representation
but that's fine.
first cut will just do whatever jsonld.js is doing today.
Thomas Bergwinkl
@bergos
Feb 06 2016 19:53
i have already an implementation that uses the jsonld representation, so that's fine: https://github.com/rdf-ext/rdf-normalize
but yes, when the spec is ready it would be nice to get the new representation.
elf Pavlik
@elf-pavlik
Feb 06 2016 21:38
@dlongley thank you for offering your help with separating rdf normalization algorithms! what do you think about doing the same for linked data signatures?
elf Pavlik
@elf-pavlik
Feb 06 2016 22:06
looking at https://github.com/digitalbazaar/jsonld-request which can parse JSON-LD and RDFa, rdf-ext could come useful to support other serializations https://github.com/rdf-ext/rdf-ext#parsers
i would also see it handy to have something to parse out of HTML <script type="application/ld+json"> and even <script type="text/turtle">
Google heavily recommends embedding JSON-LD in HTML script tags https://developers.google.com/structured-data/rich-snippets/products#examples