-
Notifications
You must be signed in to change notification settings - Fork 152
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
Scoping context based on the @type #415
Comments
👍 Yes, if nested contexts are to be supported, I think connecting them to The alternative (as I've seen it) – to tie nested contexts to specific properties (links) – would risk an increase in fragmentation (e.g. if a Person used title for foaf:title when linked to with dc:creator but not dc:contributor). |
I should probably balance my opinion by saying that I think both alternatives have merit. A possible solution is to support term-controlled contexts in both cases (i.e. apply it both for terms with local context used as predicates, and for those used as values of (I guess the harder question is whether the local context would extend the base or not (I'd wager for extension by default).) |
👍 to adding both There's also an interesting JSON transformation tool worth mentioning here that could be combined with some of these future JSON-LD features (potentially useful for framing as well): https://github.com/bazaarvoice/jolt |
A use case for this that would solve a significant pain point in the cultural heritage domain is the over-reliance on domain and range specific predicates, and using type based contexts to reduce them back to a smaller and more understandable set of JSON keys. For example, in CIDOC-CRM there are several pairs of hasPart/partOf predicates based on the domain. These could be collapsed down to
Thus it would be great to have a context that allowed
Which expands to this. And:
which expands to this (some triples elided here from the full example). If we could associated [Edit: And my life, as I got the wholes/parts around the wrong way in the list first time round!] |
I think there are a few potential issues to be addressed:
Towards the first, if there is a conflict, then it seems like there are two options:
Towards the second ... same as the first? Or use the predicate? This seems like a "don't do that then" moment, to me. And the last ... re-expressing the differences for every class seems like the only way to go. This has the (IMO) beneficial side effect that context designers will try harder to put everything at the 1.0 compatible top level and only express the differences in scopes. And as a syntactic proposal, the sub-context could live within the definition of the class's term in the context, and the processor then checks the mappings for both the predicate and the class (conflict resolution as discussed above). For example:
|
In addition to some kind of last resort automatic resolution, we should also have a way for context designers to specify which type they would prefer to be given preference. Ideally this would be done in a way that could be specified without having to rewrite all of the rules (useful when composing existing contexts together in an array to form a new one). |
My thought is that contexts found while traversing When Expanding:After step 5 (
When Compacting:Within step 8.1.2.2 (expanded value must be a The only potential for conflict is when going from RDF, where there is no guaranteed sequence of the values of |
👍 |
Pretty simple to implement, I've done it on the |
@gkellogg, thank you for your work! Could you maybe show how would the example I made in the initial comment in this issue be transformed using this current change to the spec? |
Hm, this is not yet available in the playground? I tried to play with it. |
I opened #484. |
AFAIK, the only processor with these updates is Ruby JSON-LD. I support this in my distiller at http://rdf.greggkellogg.net/distiller, but only for the purpose of deserializing to another RDF serialization, or serializing back from RDF. If you go so far as to install the Ruby Gem, it will install a "jsonld" executable, that provides full access to compession/expansion/framing and so forth, but from the command line. |
I just tried Ruby Gem and it does not work either. I used this input, expecting this output:
|
It seems that you probably don't have the version announcement added to the context, which is why it complains that |
Nice. So I converted the initial example I had to this and it looks that it works great: {
"@context": {
"@version": 1.1,
"@base": "http://127.0.0.1:8000/api/v2/node/",
"@vocab": "http://127.0.0.1:8000/api/v2/node/?format=vocab#",
"config/core.location/Location": {
"@context": {
"@base": "_:config/core.location/",
"@vocab": "http://127.0.0.1:8000/api/v2/node/?format=vocab#config/core.location/"
}
},
"config/core.project/Project": {
"@context": {
"@base": "_:config/core.project/",
"@vocab": "http://127.0.0.1:8000/api/v2/node/?format=vocab#config/core.project/"
}
}
},
"@type": "Node",
"@id": "000c3d9d-5d7c-492a-8d3b-bb8b922ae35f",
"config": {
"core.location": {
"@id": "123",
"@type": "config/core.location/Location",
"timezone": "Europe/Ljubljana",
"address": "San Juan, Puerto Rico",
"city": "Ljubljana",
"country": "SI",
"geolocation": {
"@context": "http://geojson.org/geojson-ld/geojson-context.jsonld",
"type": "Point",
"coordinates": [
-66.073756,
18.378287
]
},
"altitude": 0.0
},
"core.project": {
"@id": "444",
"@type": "config/core.project/Project",
"project": "http://127.0.0.1:8000/api/v2/project/2"
}
}
} |
Currently, for JSON data we have, I have to put
@context
s all around the JSON to scope properties:It would be great if I could somehow
@vocab
(or@context
) itself would be scoped based on the value of@type
, similarly to what I have to do currently manually. Ideally, JSON-LD would then be something like:And all definitions of properties would stay exactly the same as in the initial JSON at the top.
The text was updated successfully, but these errors were encountered: