-
Notifications
You must be signed in to change notification settings - Fork 159
Description
As mentioned in #404, JSON-LD IRI compaction to Compact IRI representations can generate non-desirable results.
Take, for example, the following JSON-LD context (abbreviated from the actual schema.org context):
{
"@context": {
"schema": "http://schema.org/",
"sport": { "@id": "http://schema.org/sport", "@type": "@id" }
}
}
Then, compact the following:
[{
"http://schema.org/sportsEvent": {"@id": "http://example.com/event"}
}]
What you get is the following:
{
"@context": {
"schema": "http://schema.org/",
"sport": {
"@id": "http://schema.org/sport",
"@type": "@id"
}
},
"sport:sEvent": {
"@id": "http://example.com/event"
}
}
when, what is expected is:
{
"@context": {
"schema": "http://schema.org/",
"sport": {
"@id": "http://schema.org/sport",
"@type": "@id"
}
},
"schema:sportsEvent": {
"@id": "http://example.com/event"
}
}
The reason for this is that the compactIri algorithm looks for the shortest Compact IRI.
This was addressed in the Ruby JSON-LD gem in ruby-rdf/json-ld@c8760e2 by adding a simple_compact_iris
option. This uses the concept of a simple term definition (i.e., a term definition which is not an expanded term definition) and favors a simple term definition over an expanded term definition when creating a Compact IRI. With this option, step 5 of the IRI Compaction Algorithm is modified:
For each key term and value term definition which is a simple term definition in the active context:
An alternative would be to make two passes, one using simple term definition and the next, if no compact IRI is generated, using expanded term definitions.