blinry / wikidata-cardgame

Use Wikidata to generate fact cards on arbitrary topics!
https://cardgame.morr.cc
64 stars 7 forks source link

Allow querying for arbitrary predicates #15

Open k-nut opened 5 years ago

k-nut commented 5 years ago

Related to #9 I think it would be great if the users could optionally pass in another property that should be used as the base for the search. If we for example wanted to search for presidents, we would probably have to filter by P39 (position held) instead of P31/P279*. Maybe this could be done as an optional URL parameter?

blinry commented 5 years ago

I'd love that! If we think really big, we could put a whole SPARQL expression in the URL, so that you can request any set of Wikidata items you want. I see at least two options (I also include the language parameter of #16 to see how that would play together):

  1. Do it like query.wikidata.org – URL-encode the whole statement, and use ?item as a magic placeholder. It would look like this: https://cardgame.morr.cc/?%3Fitem%20wdt%3AP39%20wd%3AQ11696&lang=ca This would allow the largest flexibility, but yields scary URLs. It would also allow for multiple statements, which is awesome.

  2. Try something more refined: https://cardgame.morr.cc/?Q11696&prop=P39&lang=ca. More readable, less flexible?

What do you think? Do you see a third option I've missed?

blinry commented 5 years ago

I just noticed that I had added a more advanced property in e70170c, then accidentally removed it again. It's back now in cef5886! ?item (wdt:P31|wdt:P106|wdt:P39)/wdt:P279*|wdt:P171* – this includes "position held", "occupation" and "parent taxon", which are all properties which feel like "is a …". We could aim at making the "do what I mean!" case as good as possible, and allow more advanced queries nevertheless.

k-nut commented 5 years ago

I wonder how much of a performance impact it has to query for so many things at once?

I like option 1 that you proposed initially. I think that this would be quite a "pro level" feature and the people that are interested in it would not mind complicated urls. Multi level statements would be super cool. It would allow us to do things like "village in Niedersachsen" which would be awesome!