At the moment there is a tree view which is quite complex but it is neither practical nor useful. Ideally there should be another option to represent queries like a simple tree. See example:
https://tools.wmflabs.org/wikidata-todo/tree.html?q=Q1785783&rp=361&lang=en&method=list&depth=4
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Simple tree query visualization | wikidata/query/gui | master | +241 -3 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T90870 selfcontained projects around Wikidata (tracking) | |||
Open | None | T165473 [Epic] new visualizations for Wikidata Query Service | |||
Resolved | • Jonas | T152676 Simple tree query visualization |
Event Timeline
Have a look at https://www.npmjs.com/package/wikidata-taxonomy for some previous work about creation of hierarchies from Wikidata. The tool includes some additional information such as number of instances and number of sitelinks and additional parents. A tree visualization could also show arbitrary additional information so it would be like the table visualization but with a special first row with the hierarchy. One must also make sure to handle multihierarchies.
Change 354967 had a related patch set uploaded (by Jonas Kress (WMDE); owner: Jonas Kress (WMDE)):
[wikidata/query/gui@master] Simple tree query visualization
https://gerrit.wikimedia.org/r/354967
Change 354967 merged by jenkins-bot:
[wikidata/query/gui@master] Simple tree query visualization
https://gerrit.wikimedia.org/r/354967
@Jonas 3 things:
- I tried running the example for "Tree" ("Continents, countries, regions and capitals") at https://query.wikidata.org/ but it gives "Unable to display result".
- Also, this new feature needs to be documented at https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual#Default_views
- Lastly, I'd suggest adding another "tree" example at the GUI, for the specific example given in the description here. That will probably be a simpler example, for non-technical people to adapt/reuse.
- Specifically http://tools.wmflabs.org/wikidata-todo/tree.html?q=Q1785783&rp=361&lang=en&method=list&depth=4
- (I have this similar example bookmarked https://tools.wmflabs.org/wikidata-todo/tree.html?rp=279&method=list&q=8261 and I hope to be able to adapt that, based on the one above once it's converted. :-)
Thanks!
Sorry, there went something wrong with the deployment.
- Also, this new feature needs to be documented at https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual#Default_views
It is documented here:
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_Help/Result_Views
- Lastly, I'd suggest adding another "tree" example at the GUI, for the specific example given in the description here. That will probably be a simpler example, for non-technical people to adapt/reuse.
- Specifically http://tools.wmflabs.org/wikidata-todo/tree.html?q=Q1785783&rp=361&lang=en&method=list&depth=4
- (I have this similar example bookmarked https://tools.wmflabs.org/wikidata-todo/tree.html?rp=279&method=list&q=8261 and I hope to be able to adapt that, based on the one above once it's converted. :-)
I don't fully understand why you prefer this over the current implementation.
Could you please elaborate on this?
Thanks!
- Lastly, I'd suggest adding another "tree" example at the GUI, for the specific example given in the description here. That will probably be a simpler example, for non-technical people to adapt/reuse.
- Specifically http://tools.wmflabs.org/wikidata-todo/tree.html?q=Q1785783&rp=361&lang=en&method=list&depth=4
- (I have this similar example bookmarked https://tools.wmflabs.org/wikidata-todo/tree.html?rp=279&method=list&q=8261 and I hope to be able to adapt that, based on the one above once it's converted. :-)
I don't fully understand why you prefer this over the current implementation.
Could you please elaborate on this?
Happily! I just mean: the current example (http://tinyurl.com/y9en7f7k) is very complicated (which is great! it shows off the power of WDQS, and provides a complex example for experienced people to adapt).
But for me, as a (representative) newbie to WDQS and databases in general, I'd like to also have a very simple example, that I could adapt more easily, for the simple queries I often want to make.
It's also just a good/useful habit, to use the specific example given in a feature-request, as a demonstration link - either in the documentation, or at least in the closing comment of the phabricator task - e.g. "Your request has been implemented! The example you gave in the description, can now be done on WDQS as <link>." :-)
But in general, it's usually appreciated to have one simple example, and one complex example, for a powerful tool like this.
Sorry, I was not aware of that problem.
If you are interested in classic music I guess @Lucas_Werkmeister_WMDE could provide you with some good examples.
Simple queries you could try out are 'cats' or 'presidents and spouse' from the example page.
You could also request a query.
Here’s a SPARQL version of the example at the top of the page (Chopin):
#defaultView:Tree SELECT ?i0 ?i0Label ?i1 ?i1Label ?i2 ?i2Label ?i3 ?i3Label ?i4 ?i4Label WHERE { BIND(wd:Q1785783 AS ?i0). ?i0 ^wdt:P361 ?i1. OPTIONAL { ?i1 ^wdt:P361 ?i2. OPTIONAL { ?i2 ^wdt:P361 ?i3. OPTIONAL { ?i3 ^wdt:P361 ?i4. } } } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
But it’s a bit weird because there’s not really any rigid structure there, just “follow P361 for n levels”. So I don’t think that’s a good example query.
Perhaps this one is better? Viennese composers and their compositions by tonality:
# Viennese composers and their compositions by tonality #defaultView:Tree SELECT ?composer ?composerLabel ?composerImage ?tonality ?tonalityLabel ?composition ?compositionLabel WHERE { ?composer wdt:P31 wd:Q5; wdt:P19|wdt:P20|wdt:P551 wd:Q1741. OPTIONAL { ?composer wdt:P18 ?composerImage. } ?composition wdt:P86 ?composer; wdt:P826 ?tonality. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY ?composerLabel ?tonalityLabel
Is that query simple enough or still too complicated? I’m afraid I’m not the best person to judge that ;)
Also – @Jonas, tree view seems to be broken on query.wikidata.org again, I get “unable to display result” with a console error that “a(…).jstree is not a function”. not “broken again”, but “still broken” (fix not deployed yet, should happen today).
The Chopin example could be written like this to become a simple example:
SELECT ?parent ?parentLabel ?child ?childLabel WHERE { ?parent wdt:P361* wd:Q1785783 . ?child wdt:P361 ?parent . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
@nichtich that’s not the same thing – that tree always only has two levels, and nodes will appear multiple times (e. g. Waltzes by Chopin is a toplevel node but also a child node of List of compositions by Frédéric Chopin by genre). If I understand correctly, that query structure only works for a graph view, but not for the tree view.
I think this task can be closed – the tree view is now correctly deployed, it’s documented, and @WikidataFacts added an example to the examples page.