-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
defer-future-versionDefer this issue until a future version of JSON-LDDefer this issue until a future version of JSON-LD
Description
I have the following data structure:
{
"@context": {
"ex": "http://example.org/",
"exv": "http://example.org/vocab#",
"exv:source": {"@type": "@id"},
"exv:target": {"@type": "@id"}
},
"@graph": [
{ "@id": "ex:relationship-12345",
"@type": "exv:Relationship",
"exv:relationshipType": {"@id": "exv:created"},
"exv:source": {
"@id": "ex:actor-23456",
"@type": "exv:Actor",
"exv:description": "Some odd actor."
},
"exv:target": {
"@id": "ex:event-34567",
"@type": "exv:Event",
"exv:description": "Some odd event."
}
}]
}
I would like to restructure it as:
{
"@context": {
"ex": "http://example.org/",
"exv": "http://example.org/vocab#",
"exv:source": {"@type": "@id"},
"exv:target": {"@type": "@id"}
},
"@graph": [
{ "@id": "ex:actor-23456",
"@type": "exv:Actor",
"exv:description": "Some odd actor.",
"exv:created": {
"@id": "ex:event-34567",
"@type": "exv:Event",
"exv:description": "Some odd event."
}
},
{ "@id": "ex:relationship-12345",
"@type": "exv:Relationship",
"exv:source": "ex:actor-23456",
"exv:relationshipType": {"@id": "exv:created"},
"exv:target": "ex:event-34567"
}]
}
In other words, the structure can be viewed as reifed data where:
exv:Relationship subclass of rdf:Statement
exv:source subproperty of rdf:subject
exv:relationshipType subproperty of rdf:predicate
exv:target subproperty of rdf:object
and I need to instantiate its triple:
ex:actor-23456 -- exv:created --> ex:event-34567
Some framing issues are:
- Referencing the value of a property for later use, like the "exv:relationshipType" value.
- Using a referenced value as a property, like the value of "exv:relationshipType" used as the property of the "exv:source" value.
- Matching node patterns like "ex:relationship-" + variable info
It seems wildcard matching is an all or nothing affair: match specific IRIs, everything {}, or nothing [], but not generic string matching. It would be useful for the frame matching to use regex patterns like "ex:relationship-.+". This is helpful when I don't have @type, but can create type based on the @id match.
Then, I can validate some pattern while framing. The framing could be:
{
"@context": {
"ex": "http://example.org/",
"exv": "http://example.org/vocab#",
"exv:source": {"@type": "@id"},
"exv:target": {"@type": "@id"}
},
"@graph": [
{ "@requireAll": true,
"@id": {"@regex": "ex:relationship-.+"}, <-- verifies a proper string match for a Relationship
"@type": {"@default": "exv:Relationship"}, <-- new type if it doesn't exist
"exv:relationshipType": {"@id": ?prop}, <-- reference for property
"exv:source": {
?prop: {"@default": {"@id": ?obj}} <-- new key-value pair
},
"exv:target": {"@id": ?obj}, <-- reference for value, will order matter (target before source)?
}]
}
to produce:
{
"@context": {
"ex": "http://example.org/",
"exv": "http://example.org/vocab#",
"exv:source": {"@type": "@id"},
"exv:target": {"@type": "@id"}
},
"@graph": [
{ "@id": "ex:relationship-12345",
"@type": "exv:Relationship",
"exv:relationshipType": {"@id": "exv:created"},
"exv:source": {
"@id": "ex:actor-23456",
"@type": "exv:Actor",
"exv:description": "Some odd actor.",
"exv:created": "ex:event-34567" <------ new key-value pair
},
"exv:target": {
"@id": "ex:event-34567",
"@type": "exv:Event",
"exv:description": "Some odd event."
}
}]
}
Yeah, I hate it too. It looks ugly, but I currently don't see a way around it.
Metadata
Metadata
Assignees
Labels
defer-future-versionDefer this issue until a future version of JSON-LDDefer this issue until a future version of JSON-LD
Type
Projects
Status
Future Work