Re: Checking equality of graphs serialized in JSON-LD and Turtle

> On 19 Oct 2014, at 12:20, henry.story@bblfish.net wrote:
> 
>> 
>> On 17 Oct 2014, at 15:35, ☮ elf Pavlik ☮ <perpetual-tripper@wwelves.org> wrote:
>> 
>> Howdy,
>> 
>> I work on automated tests for examples in draft of ActivityStreams 2.0
>> spec[1]
>> 
>> So far I use jsonld.js to get N-Quads from JSON-LD examples in spec +
>> latest context document. For now I modified those N-Quads by hand to
>> make it more human readable Turtle so we can review and define expected
>> RDF as fixtures.
>> 
>> I still don't have clear strategy how to compare graphs serialized in
>> both JSON-LD and Turtle. I plan to use N3.js to parse turtle, also in
>> LevelGraph extensions[2][3] we already have code which converts both
>> serializations to array of plain triples for persisting them. It may
>> require some carefulness with blank nodes...
> 
> This is called graph isomorphism verification and is defined in the RDF
> spec. I wrote an implementation in Scala here:
> 
> https://github.com/w3c/banana-rdf/blob/988ae4705131f130ef004df7efc5db8fa8773cb2/rdf/common/src/main/scala/org/w3/banana/iso/GraphIsomorphism.scala
> 
> It can be compiled to JavaScript.
> Beware that graph isomorphism calculations can be complex. This one can still 
> be improved a lot, but is not too bad.

Come to think of it, this algorithm is only applicable to pure RDF graphs, not to 
graphs that contain graphs ( eg to things producible by n3 ).... To do that one does
need a way of ordering ( canonicalising ) the subgraphs. 

> 
>> 
>> I remember us having conversation about common js format which we could
>> use as common base for converting all the other serializations. I think
>> we considered expanded JSON-LD as main candidate.
>> 
>> Any recommendations for quick way of comparing, for now just equality,
>> graphs serialized in JSON-LD and Turtle?
>> 
>> Thanks!
>> 
>> 
>> [1] https://github.com/jasnell/w3c-socialwg-activitystreams/pull/32
>> [2] https://github.com/mcollina/levelgraph-jsonld
>> [3] https://github.com/mcollina/levelgraph-n3
>> 
> 
> Social Web Architect
> http://bblfish.net/

Social Web Architect
http://bblfish.net/

Received on Monday, 20 October 2014 08:34:05 UTC