gbv / jskos

JSKOS data format for Knowledge Organization Systems
https://gbv.github.io/jskos/
38 stars 5 forks source link

Mappings set not represented in the @context file #119

Open richardofsussex opened 8 months ago

richardofsussex commented 8 months ago

Looking to include a simple mapping to another concept (a skos:exactMatch), I found that I couldn't include the set of mappings in my primary block, because my mappings are an anonymous array and items within a block have to have a key. The documentation suggests that the mappings set should have the key "mappings", but this is not reflected in the context document.

The examples of mappings show the mapping block, but not the context (i.e. the array) within which each one sits.

nichtich commented 8 months ago

Do you refer to this example?:

{
    "@context": "https://gbv.github.io/jskos/context.json",
    "type": [
      "http://www.w3.org/2004/02/skos/core#exactMatch"
    ],
    "from": {
      "memberSet": [
        {
          "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000"
        }
      ]
    },
    "to": {
      "memberSet": [
        {
          "uri": "http://vocab.getty.edu/tgn/7004264"
        },
        {
          "uri": "https://sws.geonames.org/3177090"
        },
        {
          "uri": "https://www.wikidata.org/entity/Q13362"
        }
      ]
    }
  }
}

The purpose of @context is to define a mapping from JSKOS/JSON-LD to RDF triples but JSKOS Mappings goes beyond the simple SKOS model of mappings as plain triples. There is no common way to express one-to-many mappings in SKOS nor metadata about mappings (could be done by blank nodes or RDF*) so the JSKOS context file does not specify what to do with mapping data. Just converting all mappings to RDF statements is also problematic because mappings are not necessarily "true" in the same sense as other information (labels, relations...) but they may have author, date, annotation...

If you describe your use case, I might give hints how to best process JSKOS Mapping data to get RDF and this guidelines should make it into JSKOS specification.

tl;dr: JSKOS mappings are not supposed to automatically transformed to RDF triples without additional configuration.

richardofsussex commented 8 months ago

We would be happy with a set of simple SKOS-like mappings. I can understand your wanting to improve on SKOS with regard to the metadata/contextual data associated with mappings, but we are aiming for an API where the concept's URI resolves to a single block of JSON. Therefore we would like to have a mappings array containing one or more SKOS-style mappings which can fit within this single block. Is this possible in JSKOS as it stands? - it's entirely possible that I have just missed the relevant piece of documentation.

nichtich commented 8 months ago

If your example is meant to encodes three 1-to-1 mappings (instead of one 1-to-n mappings, not expressible in core SKOS anyway) the format should better be:

{
  "@context": "https://gbv.github.io/jskos/context.json",
  "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000",
  "prefLabel": { "en": "Ferrara" },
  "mappings": [ {
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "http://vocab.getty.edu/tgn/7004264" } ] }
   },{
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "https://sws.geonames.org/3177090" } ] }
  },{
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "https://www.wikidata.org/entity/Q13362" } ] }
 } ]
}

This allows to further process the mappings by applications aware of JSKOS format. Applications not aware of JSKOS, however won't make sense of the mapping data because the JSKOS context document does not tell how to convert these to plain RDF statements (in contrast to other fields such as prefLabel). To also serve these applications (that want to read your data as RDF without knowing about JSKOS) it is possible to extend JSKOS with custom fields like this:

{
  "@context": {
    "@import": "https://gbv.github.io/jskos/context.json",
    "_exactMatch": "http://www.w3.org/2004/02/skos/core#exactMatch"
   },
  "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000",
  "prefLabel": { "en": "Ferrara" },
  "mappings": [ {
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "http://vocab.getty.edu/tgn/7004264" } ] }
   },{
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "https://sws.geonames.org/3177090" } ] }
  },{
    "type": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ],  
    "from": { "memberSet": [ { "uri": "https://data.ng.ac.uk/0G0S-0008-0000-0000" } ]  },  
    "to": { "memberSet": [ { "uri": "https://www.wikidata.org/entity/Q13362" } ] }
 } ],
  "_exactMatch": [
    "http://vocab.getty.edu/tgn/7004264",
    "https://sws.geonames.org/3177090",
    "https://www.wikidata.org/entity/Q13362"
  ]
}

This use of @context is not allowed by current version of JSKOS specification but I'll add it!

richardofsussex commented 8 months ago

Thank you, that gives me a clear idea of what our options are.