Re: Bug with @reverse and blank nodes?

On Oct 20, 2013, at 2:21 AM, Pierre-Antoine Champin <pierre-antoine.champin@liris.cnrs.fr> wrote:

> Hi,
> 
> I add a surprise today using @reverse with  blank node:
> 
> {
>   "@context": {
>     "foo": "http://example.org/foo",
> 
>     "bar": { "@reverse": "http://example.org/", "@type": "@id" }
>   },
>   "foo": "Foo",
>   "bar": "http://example.org/origin"
> 
> }
> 
> produces the following graph:
> 
> <http://example.org/origin> <http://example.org/> _:b1 .
> 
> _:b0 <http://example.org/foo> "Foo" .
> 
> with *two different bnodes*!...
> 
> I have the same behaviour with PyLD and the online playground, so may be this is a deliberate feature of the JSON-LD algorithm (I didn't go and check the API document, I admit...). But if it is so there should be a big warning sign in the syntax document, because this is *very* counter-intuitive.

My Ruby parser also produces this result, which implies that it's a consequence of the way the algorithm is stated in JSON-LD-API. I agree that it's counter-intuitive and inconsistent with the use of an IRI subject. Even specifying a labeled blank node as the subject causes two different blank nodes to be generated. I think it's a spec bug.

If I add the subject _:foo, the node expands to the following:

{
  "@id": "_:foo",
  "@reverse": {
    "http://example.org/": [
      {"@id": "http://example.org/origin"}
    ]
  },
  "http://example.org/foo": [
    {"@value"=>"Foo"}
  ]
}

I think the problem comes when in the flattening algorithm, which results in the following node map:

{
  "@default": {
    "_:b0": {"@id": "_:b0"},
    "http://example.org/origin": {
      "@id": "http://example.org/origin",
      "http://example.org/": [{"@id": "_:b1"}]
    },
    "_:b1": {"@id": "_:b1"}
  }
}

I believe it comes down to step 6.1 of the Node Map Generation algorithm [1], which says to generate a new blanknode identifier. It was previously invoked from step 6.8.3.1.2 because of the @reverse keyword. Perhaps there is some flag that needs to be passed so that a new blanknode lebel is not generated? Markus or Dave might have some other opinions on this.

Gregg

[1] http://www.w3.org/TR/json-ld-api/#node-map-generation

>   pa

Received on Sunday, 20 October 2013 16:57:59 UTC