Re: Adding a list-valued property

On Nov 25, 2013, at 2:26 PM, Judson Lester <nyarly@gmail.com> wrote:

> That would work, but of course, you’d also want to add the list to the graph for it to be included in the dump. I think Ian’s use case should probably work, and it indicates that there’s something missing both in the List implementation and the tests. It’s a natural thing to want to do.
> 
> Or you could create the RDF::List using your starting Repository as it's graph... but yes. 
> 
> Working with RDF::List recently, it has a couple of natural but surprising behaviors that arise from it being an interface on a rdf:List as well as manipulating a graph. 
> 
> From my recollection of a couple of weeks ago, adding an empty list to a graph and then manipulating it has surprising results because the root subject changes. 

This is not trivial; in particular, if you insert a list, and then modify it; it would require maintaining some callback so that the associated graph could be maintained. Imagine creating an empty list and inserting it, the list object IRI is going to be rdf:nil. Any change makes this a BNode. For non-empty lists, we might be able to do something, but it seems like it’s more complicated than it’s worth. We could freeze the list when adding it, which would prevent further modifications to it; this should probably be mentioned in the class documentation.

Anyway, too much detail for this list, I created issue 139 [1] to track this; we can move discussion there.

Gregg

[1] https://github.com/ruby-rdf/rdf/issues/139

> I also seem to remember an issue I had (but maybe only in my own fork...?) that had to do with where the rdf:List type was applied in terms of serializing to JSON-LD or RDFa... I think it had to do with type properties on the rdf:rest objects, but I'm not sure at the moment.
> 
> Judson
> 
> 
> 
> 
> On Mon, Nov 25, 2013 at 1:42 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote:
> 
> On Nov 25, 2013, at 1:24 PM, Judson Lester <nyarly@gmail.com> wrote:
> 
>> I think what you want is:
>> 
>> r << [s, p, l.subject]
>> 
>> That's just off the top of my head though.
> 
> That would work, but of course, you’d also want to add the list to the graph for it to be included in the dump. I think Ian’s use case should probably work, and it indicates that there’s something missing both in the List implementation and the tests. It’s a natural thing to want to do.
> 
> Note that in the 1.0.x versions, RDF::List extends RDF::Resource, which would make you believe that a list is a first-class item (Graph does to). This behavior is removed in the 1.1 versions they extend RDF::Value instead. I’m trying to push out all new versions of the RDF gems, but am stuck in some odd Sinatra/Rake behavior at the moment; I’ll make sure this is addressed then.
> 
> Similarly, you might think that doing g = RDF::Graph.load(“foo”), r << [s, p, g] would add the graph as an anonymous named graph to the repository; this would be worth implementing/validating too.
> 
> Ian, perhaps you’d raise an issue against RDF.rb.
> 
> Gregg
> 
>> On Mon, Nov 25, 2013 at 1:19 PM, Ian Dickinson <i.j.dickinson@gmail.com> wrote:
>> Hi Gregg,
>> I'm doing something wrong trying to add a triple whose object is a
>> list. Basically what I'm trying to create is:
>> 
>>     :s :p (1 2 3).
>> 
>> Here's what I tried:
>> 
>> 2.0.0-p247 :003 > r = RDF::Repository.new
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :004 > l = RDF::List[1,2,3]
>>  => #<RDF::List:0x16b6cf4(RDF::List[1, 2, 3])>
>> 2.0.0-p247 :005 > s = RDF::Resource.new("http://example.org/s")
>>  => #<RDF::URI:0x18d91f8(http://example.org/s)>
>> 2.0.0-p247 :006 > p = RDF::Resource.new("http://example.org/p")
>>  => #<RDF::URI:0x1abcd1c(http://example.org/p)>
>> 2.0.0-p247 :007 > r << [s,p,l]
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :008 > r.dump(:turtle)
>>  => "\n<http://example.org/s> <http://example.org/p> _:g24109960 .\n"
>> 2.0.0-p247 :009 > r << l
>>  => #<RDF::Repository:0x15b1ac0()>
>> 2.0.0-p247 :010 > r.dump(:turtle)
>>  => "\n<http://example.org/s> <http://example.org/p> _:g24109960
>> .\n\n(1 2 3) a <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .\n"
>> 
>> I'm sure I'm doing something dumb, but I'm not sure what to change. Suggestions?
>> 
>> Thanks,
>> Ian
>> 
>> 
> 
> 

Received on Monday, 25 November 2013 22:41:33 UTC