Re: Convert also "partial" lists from RDF to JSON-LD

On Jul 5, 2013, at 11:49 AM, Gregg Kellogg wrote:

> 
> Gregg Kellogg
> gregg@greggkellogg.net
> 
> On Jul 5, 2013, at 4:02 AM, Markus Lanthaler <markus.lanthaler@gmx.net> wrote:
> 
>> CC'ing public-linked-json as this discussion might result in a change to the
>> algorithms and may help the OpenAnnotation people.
>> 
>> 
>> On Thursday, July 04, 2013 10:21 PM, Andy Seaborne wrote:
>>> The set of all heads of well-formed lists can be found quite easily.
>>> 
>>> All lists have a common tail (rdf:nil).  Just walk back up the list
>>> checking nodes have exactly one rdf:first and one rdf:next triple.
>>> This generates the list head.
>> 
>> You are of course right and the necessary changes to the algorithm should be
>> quite small.
>> 
>> Currently a @list can never be the value of a rdf:first/rdf:rest. This kind
>> of ensures that only "complete" lists are transformed to @list and that we
>> don't produce lists of lists in JSON-LD.
>> 
>> An example might clarify what I mean. Currently we would never produce
>> something like
>> 
>> {
>>   "@id": "http://example.com/",
>>   "rdf:first": "A",
>>   "rdf:rest": { "@list": [ "B", "C", "D" ] }
>> }
>> 
>> all the list bnodes would be preserved:
>> 
>> [
>>   {
>>     "@id": "http://example.com/",
>>     "rdf:first": "A",
>>     "rdf:rest": { "@list": [ "B", "C", "D" ] }
>>   },
>>   {
>>      "@id": "_:b0",
>>      "rdf:first": "B"
>>      "rdf:rest": { "@id": "_:b1" }
>>   },
>>   ...
>> ]
>> 
>> 
>> Arguably changing that would result in a nicer result. This might also be a
>> quite elegant solution for the OpenAnnotation people. I think we could
>> threat this change as an algorithmic bug fix (meaning, no need for another
>> LC).
>> 
>> I've created ISSUE-277 for this:
>> https://github.com/json-ld/json-ld.org/issues/277
>> 
>> 
>> Thoughts?
> 
> (From my comment on the issue:)
> 
> The @id of the first object can't be "http://example.com/", surely? To be a list, the subject must be a BNode.

That is true in Turtle but not in RDF, which imposes no restrictions on the use of the first/rest/LIst vocabulary. 

Just sayin'.

Pat

> 
> It also makes sense that @list can be the value of rdf:rest (and perhaps rdf:first, as well). The algorithm would find the list head at the first node having rdf:first/rest with only single well-formed values, as it does now; this should include those for which the subject is a non-well-formed value of an rdf:rest.
> 
> An example @afs and I were working on offline is more like the following:
> 
> Turtle:
> 
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix : <http://example/> .
> 
> :x :list _:a .
> 
> _:a rdf:first 1 .
> _:a :additional "foo" .
> _:a rdf:rest  _:b .
> 
> _:b rdf:first 2 .
> _:b rdf:rest  _:c .
> 
> _:c rdf:first 3 .
> _:c rdf:rest  rdf:nil .
> 
> JSON-LD:
> 
> {
>  "@context": {...},
>  "@id": "_:x",
>  "list": {
>    "additional": "foo",
>    "rdf:first": 1,
>    "rdf:rest: {"@list": [2, 3]}
>  }
> }
> 
> Gregg
> 
>> --
>> Markus Lanthaler
>> @markuslanthaler
>> 
>> 
> 
> 
> 

------------------------------------------------------------
IHMC                                     (850)434 8903 or (650)494 3973   
40 South Alcaniz St.           (850)202 4416   office
Pensacola                            (850)202 4440   fax
FL 32502                              (850)291 0667   mobile
phayesAT-SIGNihmc.us       http://www.ihmc.us/users/phayes

Received on Saturday, 6 July 2013 04:28:14 UTC