zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

Labels for instances of dimensions/attributes #4

Closed ktk closed 5 years ago

ktk commented 5 years ago

From what I can see in the documentation I'm able to get labels for DataSet & dimension/measure/attributes. What I can't seem to find is how I would get the label of an instance of a dimension/attribute.

This is necessary for all instances that are not a literal but point to a URI. In my document I wrote how do query this information. Note that in my example I fetch them separately, they could obviously also be fetched in the query that fetches the data itself by adding something like this:

  ?observation <https://ld.stadt-zuerich.ch/statistics/property/RAUM> ?raum.

    ?raum rdfs:label|skos:prefLabel ?raumLabel .

Now the only problem is that there might be datasets where we cannot resolve all URIs, or they use another predicate for the label. So we might have to make that optional and configurable.

I'm not sure what the best way is to handle this, ideally the result from query would contain the label as well. In the example I played around with I get this as a row of the result:

  {
    raum: NamedNode {
      value: 'https://ld.stadt-zuerich.ch/statistics/code/R30000'
    },
    zeit: Literal {
      value: '1934-12-31',
      datatype: NamedNode { value: 'http://www.w3.org/2001/XMLSchema#date' },
      language: ''
    },
    bew: Literal {
      value: '317367.0',
      datatype: NamedNode { value: 'http://www.w3.org/2001/XMLSchema#double' },
      language: ''
    }
  }

Ideally I at the same time get this:

    raum: NamedNode {
      value: 'https://ld.stadt-zuerich.ch/statistics/code/R30000'
      label: "Stadt Zürich (ab 1934)"
    },

Not sure if label is the right key but something like it.

vhf commented 5 years ago

Got it, fixed: https://github.com/zazuko/query-rdf-data-cube/commit/effc6aa3d0cd9aa823fafd619b9d3e114b486e4c#diff-b137aa644ff68c70fcf71bfa5222c0de