JSON-LD : use @embed : @never while keeping entities without the property

34 Views Asked by At

I need to combine the "@embed": "@never" feature of JSON-LD framing with an "@reverse" link, and I can't manage to do that.

Consider the following JSON-LD initial file, containing a simple list of 4 SKOS Concepts, 2 of which have a broader indication, and 2 don't:

{
  "@graph" : [ {
    "@id" : "https://data.europarl.europa.eu/def/ep-document-types",
    "@type" : "skos:ConceptScheme",
    "title" : {
      "@language" : "en",
      "@value" : "EP taxonomy on document types."
    }
  }, {
    "@id" : "https://data.europarl.europa.eu/def/ep-document-types/ACT_FOLLOWUP",
    "type": "skos:Concept",
    "inScheme" : "https://data.europarl.europa.eu/def/ep-document-types",
    "prefLabel" : [ {
      "@language" : "en",
      "@value" : "Follow-up of acts"
    }],
    "topConceptOf" : "https://data.europarl.europa.eu/def/ep-document-types"
  }, {
    "@id" : "https://data.europarl.europa.eu/def/ep-document-types/AGENDA",
    "type": "skos:Concept",
    "inScheme" : "https://data.europarl.europa.eu/def/ep-document-types",
    "prefLabel" : [ {
      "@language" : "en",
      "@value" : "Agenda"
    }],
    "topConceptOf" : "https://data.europarl.europa.eu/def/ep-document-types"
  }, {
    "@id" : "https://data.europarl.europa.eu/def/ep-document-types/AGENDA_CALENDAR_PART_SESSION",
    "type": "skos:Concept",
    "broader" : "https://data.europarl.europa.eu/def/ep-document-types/AGENDA",
    "inScheme" : "https://data.europarl.europa.eu/def/ep-document-types",
    "prefLabel" : {
      "@language" : "en",
      "@value" : "EP calendar of part-sessions"
    }
  }, {
    "@id" : "https://data.europarl.europa.eu/def/ep-document-types/AGENDA_PARLIAMENTARY_COMMITTEE",
    "type": "skos:Concept",
    "broader" : "https://data.europarl.europa.eu/def/ep-document-types/AGENDA",
    "inScheme" : "https://data.europarl.europa.eu/def/ep-document-types",
    "prefLabel" : [ {
      "@language" : "en",
      "@value" : "Parliamentary committee agenda"
    }]
  } ],
  "@context" : {
    "inScheme" : {
      "@id" : "http://www.w3.org/2004/02/skos/core#inScheme",
      "@type" : "@id"
    },
    "prefLabel" : {
      "@id" : "http://www.w3.org/2004/02/skos/core#prefLabel"
    },
    "broader" : {
      "@id" : "http://www.w3.org/2004/02/skos/core#broader",
      "@type" : "@id"
    },
    "topConceptOf" : {
      "@id" : "http://www.w3.org/2004/02/skos/core#topConceptOf",
      "@type" : "@id"
    },
    "title" : {
      "@id" : "http://purl.org/dc/terms/title"
    },
    "skos": "http://www.w3.org/2004/02/skos/core#",
    "type": "@type"
  }
}

I would like to apply a JSON-LD framing on this, to get the ConceptScheme at the first level, then inside its list of skos:Concept, with their broader information not embedded. I tried the following framing specification (note the use of @reverse and "@embed": "@never")

{
  "@context": [
    {
      "id": "@id",
      "type": "@type",
      "inScheme": {
        "@id": "skos:inScheme",
        "@type": "@id"
      },
      "inverse_inScheme": {
        "@reverse": "skos:inScheme",
        "@type": "@id"
      },
      "broader": {
        "@id": "skos:broader",
        "@type": "@id"
      },
      "skos": "http://www.w3.org/2004/02/skos/core#",
      "@base": "https://data.europarl.europa.eu/"
    },
    {
      "data": "@graph"
    }
  ],
  "@type": "skos:ConceptScheme",
  "inverse_inScheme": {
    "@omitDefault": true,
    "broader": {
      "@embed": "@never",
      "@omitDefault": true
    }
  }
}

And when applied to the input JSON-LD in the playground, gives the following output where only the 2 concepts with a broader are present, the ones without are exlucded:

{
  "@context": [
    {
      "id": "@id",
      "type": "@type",
      "inScheme": {
        "@id": "skos:inScheme",
        "@type": "@id"
      },
      "inverse_inScheme": {
        "@reverse": "skos:inScheme",
        "@type": "@id"
      },
      "broader": {
        "@id": "skos:broader",
        "@type": "@id"
      },
      "skos": "http://www.w3.org/2004/02/skos/core#",
      "@base": "https://data.europarl.europa.eu/"
    },
    {
      "data": "@graph"
    }
  ],
  "id": "def/ep-document-types",
  "inverse_inScheme": [
    {
      "id": "def/ep-document-types/AGENDA_CALENDAR_PART_SESSION",
      "broader": "def/ep-document-types/AGENDA",
      "inScheme": "def/ep-document-types",
      "skos:prefLabel": {
        "@language": "en",
        "@value": "EP calendar of part-sessions"
      }
    },
    {
      "id": "def/ep-document-types/AGENDA_PARLIAMENTARY_COMMITTEE",
      "broader": "def/ep-document-types/AGENDA",
      "inScheme": "def/ep-document-types",
      "skos:prefLabel": {
        "@language": "en",
        "@value": "Parliamentary committee agenda"
      }
    }
  ],
  "type": "skos:ConceptScheme",
  "http://purl.org/dc/terms/title": {
    "@language": "en",
    "@value": "EP taxonomy on document types."
  }
}

This surprises me as it looks really similar to example 40 of the spec. How can I achieve having the 4 concepts included in the ConceptScheme, even when they have not broaders ?

Thanks !

EDIT

I am now positive that this is an interaction between @reverse and "@embed": "@never". If I try the following that does not use @reverse, I have the expected output of the 4 concepts:

  "@type": "skos:Concept",
    "@omitDefault": true,
    "broader": {
      "@embed": "@never",
      "@omitDefault": true
    }

isn't "@embed": "@never" supposed to work inside @reverse-ed blocks ?

0

There are 0 best solutions below