Closed azaroth42 closed 6 years ago
Python demonstration of the same behavior as the playground:
from pyld import jsonld
from pyld.jsonld import compact, expand, frame
import json
contextjs = {
"ex": "http://example.com/",
"label": "ex:label",
"classified_as": "ex:type",
"related": "ex:related",
"scheme": "ex:scheme",
"Foo": "ex:FooClass",
"Bar": "ex:BarClass"
}
framejs = {
"@type": "Foo",
"@requireAll": True,
"@omitDefault": True,
"scheme": "http://aat/",
"related": {
"classified_as": {
"@type": "Foo",
"@embed": "@always",
"@omitDefault": True
}
}
}
datajs = {
"@id": "http://example.com/1",
"@type": "Foo",
"scheme": "http://aat/",
"label": "Top level",
"related": {
"@type": "Bar",
"label": "Relationship",
"classified_as": {
"@type": "Foo",
"label": "Type of Relationship"
}
}
}
datajs['@context'] = contextjs
framejs['@context'] = contextjs
framed = frame(datajs, framejs)
out = compact(framed, contextjs)
print json.dumps(out, sort_keys=True, indent=2)
It's implemented on the development playground, otherwise, this duplicates #589.
Use Case: The data has the class structure of:
Where the top level Foo instance can be distinguished by its class plus a relationship (call it
scheme
) that is not present on the lower level Foo instance. We want to construct an output graph that has only this structure in@graph
.Actual Behavior:
If the frame has both
@type
andscheme
, then the output graph has both Foo instances at the top level. This is expected, as it matches by default on any of the predicates and it matches rdf:type. However, when we add therequireAll: true
flag, it still matches in the playground, Ruby and PyLD implementations.Either we're not understanding the usage of requireAll, or the current implementations don't support it?
Example: http://tinyurl.com/ychhnlve