Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query): skos:broader support to fetch or fix a parent dimension #46

Merged
merged 4 commits into from
Dec 12, 2019

Conversation

vhf
Copy link
Contributor

@vhf vhf commented Nov 27, 2019

Dimensions have a .broader() method to select the skos:broader.

Examples based on data where you'd have things in a City with city skos:broader country country skos:broader continent.

const city: Dimension;
const country = city.broader();
const continent = country.broader();

// get cities, and the country and continent they are in
const query = dataCube.query().select({
  city,
  country,
  continent,
});
const sparql = await query.toSparql();
console.log(sparql);
const city: Dimension;
const country = city.broader();

// get cities, and the continent they are in
const query = dataCube.query().select({
  city,
  continent: city.broader().broader(),
});
const sparql = await query.toSparql();
console.log(sparql);
const city: Dimension;
const country = city.broader();

// get cities in Asia
const query = dataCube.query().select({
  city,
  continent: city.broader().broader("http://my.namespace.com/thing/continent/Asia"),
});
const sparql = await query.toSparql();
console.log(sparql);

@herrstucki I heard you once had a need for this? (We definitely do.)


TODO

  • documentation
  • cleanup related example
  • refactor toSparqlJS (extract things into private methods)

@jstcki
Copy link
Contributor

jstcki commented Nov 27, 2019

@vhf Yes, definitely! I haven't thought about this in detail, but it looks very useful. A few first comments:

  • I assume you can use the "broader dimensions" also with .filter()?
  • It would be useful is to somehow "know" in advance which dimensions have "broader" entities (and on how many levels?). I.e. the result of cube.dimensions() should somehow reflect this. Are broader dimensions also always represented as actual dimensions of the cube?
  • There will probably be at least two kinds of "broader" relationships:
    1. When the broader entity itself is not represented in the cube, i.e. doesn't have any observations (= is not a dimension?). E.g. when individual countries have data and continents are just used to group them conceptually.
    2. When the broader entity actually has data. E.g. when a cube has observations for Switzerland and each individual canton, like in http://yasgui.org/short/FPHCXqCmK
  • What about dimensions that have more than one broader relationship? What would city.broader() return?
  • How to get the broader entity of a dimension value (the example you show above does this only on a dimension level)? E.g. how to go from Zürich (City) -> Zürich (Canton) -> Switzerland -> Europe …
  • How to get to narrower values? E.g. Zürich (Canton) -> all municipalities of Zürich?
  • Is there a possibility to "hop" multiple levels broader in one call? E.g. going from Zürich (City) -> Europe?

/cc @lucguillemot

@ktk
Copy link
Member

ktk commented Dec 9, 2019

@herrstucki all good questions but I propose we move them to next year. We are definitely out of hours.

@vhf vhf merged commit 0649c1b into master Dec 12, 2019
@vhf vhf deleted the parent-dimension branch December 12, 2019 13:19
@vhf
Copy link
Contributor Author

vhf commented Dec 12, 2019

@zazuko/query-rdf-data-cube@0.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants