-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compacting graph container with multiple nodes broken #143
Comments
I think we should solve this by not selecting "input", as it can't express the result properly. Adding the use of |
Hmm, or is it the case that we have an expansion bug here? Shouldn't the above input actually be equivalent to this (note {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/"
},
"input": {
"@graph": [{
"@graph": [
{"value": "x"},
{"value": "y"}
]
}]
}
} When using [{
"http://example.org/input": [{
"@graph": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}, {
"http://example.org/value": [{"@value": "y"}]
}]
}]
}]
}] But, instead, it's dropping an [{
"http://example.org/input": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}, {
"http://example.org/value": [{"@value": "y"}]
}]
}]
}] |
This step of the Expansion Algorithm has a caveat that causes the above to happen:
That step is in there to prevent double expanding graphs -- but I think that might just be wrong. I'm going through the tests now to see what's going on there, and so far all of the expansion tests are just testing to make sure we don't do this double expansion whenever a |
Yes, that seems to be all that's tested for, to handle this special case. There are toRDF tests as well but those are just repeats of these special case expansion tests. It seems like they should either be changed or removed if we can agree that dropping an extra |
That's not what Your example would yield the following quads:
Without the extra
which is, what we want. Going back to JSON-LD, my distiller gives the following: {
"@graph": [{
"@id": "_:b0",
"http://example.org/input": {"@id": "_:b1"}
},
{
"@id": "_:b1",
"@graph": [{
"@id": "_:b3",
"http://example.org/value": "y"
}, {
"@id": "_:b2",
"http://example.org/value": "x"
}
]
}]
} Which could then be trivially framed back to: {
"http://example.org/input": {
"@graph": [{
"http://example.org/value": "y"
},{
"http://example.org/value": "x"
}]
}
} |
I don't think this is about it being necessary, rather what it means if someone does it. A term with Imagine a scenario where you wanted to make statements about another non-blank node named graph in a graph container. How would you do it? Imagine someone's attempt: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"@id": "ex:someIdentifier",
"ex:about": "this graph",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}
} If you converted to quads, you'd get:
But this is wrong! It's as if there was no
I'm asserting that this: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"@id": "ex:someIdentifier",
"ex:about": "this graph",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}
} And this: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/"
},
"input": {
"@id": "ex:someIdentifier",
"ex:about": "this graph",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}
} Are not the same thing. Why should we treat them as such? |
It is wrong, and that's not what I get on my distiller.
That is what I get. That's also what I get on the json-ld.org playground.
We don't. |
I was generating that output using the playground. I'm not sure what happened, but it was probably user (me) error. So here's where things get weird then: This: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"ex:about": "this graph",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}
} Yields these quads (if I'm not misusing the playground again somehow):
But this: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"@graph": [
{"value": "x"},
{"value": "y"}
]
}
} Yields these quads, eliminating the extra graph:
Why would we want this? What benefit is there? If someone puts that extra |
So I'm not sure what's going on with me or the playground, but I just tried this: {
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": [{
"@id": "ex:someIdentifier",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}]
} And that produced these quads:
There's no blank node named graph in there, which is wrong. Which means it's being treated the same as: ```js
{
"@context": {
"@version": 1.1,
"@vocab": "http://example.org/"
},
"input": [{
"@id": "ex:someIdentifier",
"@graph": [
{"value": "x"},
{"value": "y"}
]
}]
} It should instead produce:
Am I misusing the playground again? |
Looks like some bug in generating the node map, as the |
Must be the same node map bug, as my implementation does just the same thing. |
I created #144 for these issues. |
@gkellogg, I believe that if the special case code I mentioned in #143 (comment) is removed this problem goes away. |
It seems to me that the purpose of this special case code may have been to allow If that's the case, it seems to me that trying to enable |
I made an error (which I've corrected), as I was trying to illustrate the compaction problem. |
I can't think of a use case for double graphs. In other cases, if we have a container setting where the value already. Consider the following: {
"@context": {"@vocab": "http://example/", "list": {"@container": "@list"}},
"list": {"@list": [1,2]}
} This does not create a double list. Also, |
Given the potential to mix simple graphs with more complicated ones, it probably is, indeed, best to remove that special case. |
Me either; I don't really think it's about supporting them vs. removing special case behavior we don't need and that seems like it's gumming up the works.
👍 |
…g `@included`, to make sure they are all contained in a single graph. Fixes #143.
…g `@included`, to make sure they are all contained in a single graph. Fixes #143.
This issue was discussed in a meeting.
View the transcriptFraming blank nodesRob Sanderson: last discussion we agreed that we couldn’t solve it on a call … so gkellog and dlongley went off to look at it Gregg Kellogg: we found a problem in a framing test where @container : @graph got mangled in re-expansion… a bug in the compaction algo … if the value is an array, it puts them in an @included block… i tried [s solution] but it turned out not to be defined well enough Rob Sanderson: all of that is solved and merged? Gregg Kellogg: yep Gregg Kellogg: See API PR #146 Gregg Kellogg: See API PR #145 Proposed resolution: Close framing #27 as not being the issue, and the real issues being addressed is api #143, solved by api PRs # 145 and #146 (Rob Sanderson) Rob Sanderson: +1 Benjamin Young: +1 Dave Longley: +1 Gregg Kellogg: +1 Ivan Herman: +1 Adam Soroka: +1 Pierre-Antoine Champin: +1 Ruben Taelman: +1 Rob Sanderson: RESOLVE: Close framing #27 as not being the issue, and the real issues being addressed is api #143, solved by api PRs # 145 and #146 Proposed resolution: Close api #143 as resolved by api PR #145 and #146 (Rob Sanderson) Rob Sanderson: +1 Ivan Herman: +1 Ruben Taelman: +1 Gregg Kellogg: +1 Adam Soroka: +1 Pierre-Antoine Champin: +1 Benjamin Young: +1 Dave Longley: +1 Resolution #2: Close api #143 as resolved by api PR #145 and #146 |
As described in w3c/json-ld-framing#27 (comment), there is an issue when compacting named graphs with multiple top-level nodes under a property with
@container: @graph
.Consider the following:
When compacted using:
Generates the following:
But this describes two different named graphs.
We should either not select the term for compaction if there is more than one top-level node, or use either
@graph
or@included
to wrap them all together, which pretty much undoes the affect of@container: @graph
.The text was updated successfully, but these errors were encountered: