Skip to content

Instantly share code, notes, and snippets.

@ssp
Last active May 26, 2016 21:40
Show Gist options
  • Select an option

  • Save ssp/58d3ae7b0bcef234a04d6b8c8d7829d9 to your computer and use it in GitHub Desktop.

Select an option

Save ssp/58d3ae7b0bcef234a04d6b8c8d7829d9 to your computer and use it in GitHub Desktop.
Colours from Wikidata/dbpedia
SELECT ?color ?label (lang(?label) AS ?language) ?hex ?hue WHERE {
?color rdf:type dbo:Colour.
?color dbo:colourHexCode ?hex.
?color dbo:hsvCoordinateHue ?hue.
?color rdfs:label ?label.
FILTER (lang(?label) ="de" || lang(?label) ="en" || lang(?label) ="fr" || lang(?label) ="tr")
}
ORDER BY DESC(?hue)
An attempt to query for colours and their hex values to get their names in several languages.
* [Query Wikidata](https://query.wikidata.org/#%23Cats%0ASELECT%20%3Fitem%20%3Flabel%20(lang(%3Flabel)%20AS%20%3Flanguage)%20%3Frgb%20WHERE%20%7B%0A%20%20%3Fitem%20wdt%3AP31%2Fwdt%3AP279*%20wd%3AQ1075.%0A%20%20%3Fitem%20wdt%3AP465%20%3Frgb.%0A%20%20%3Fitem%20rdfs%3Alabel%20%3Flabel.%0A%20%20FILTER%20(lang(%3Flabel)%3D%22de%22%20%7C%7C%20lang(%3Flabel)%20%3D%20%22en%22%20%7C%7C%20lang(%3Flabel)%20%3D%20%22fr%22%20%7C%7C%20lang(%3Flabel)%20%3D%20%22tr%22)%0A%7D%0AORDER%20BY%20ASC(%3Frgb)%0A)
* [Query dbpedia](http://dbpedia.org/snorql/?query=SELECT+%3Fcolor+%3Flabel+%28lang%28%3Flabel%29+AS+%3Flanguage%29+%3Fhex+%3Fhue+WHERE+%7B%0D%0A++%3Fcolor+rdf%3Atype+dbo%3AColour.%0D%0A++%3Fcolor+dbo%3AcolourHexCode+%3Fhex.%0D%0A++%3Fcolor+dbo%3AhsvCoordinateHue+%3Fhue.%0D%0A++%3Fcolor+rdfs%3Alabel+%3Flabel.%0D%0A++FILTER+%28lang%28%3Flabel%29+%3D%22de%22+%7C%7C+lang%28%3Flabel%29+%3D%22en%22+%7C%7C+lang%28%3Flabel%29+%3D%22fr%22+%7C%7C+lang%28%3Flabel%29+%3D%22tr%22%29%0D%0A%7D%0D%0AORDER+BY+DESC%28%3Fhue%29)
SELECT ?color ?label (lang(?label) AS ?language) ?rgb WHERE {
?color wdt:P31/wdt:P279* wd:Q1075. # instance or subclass of »colour«
?color wdt:P465 ?rgb. # store sRGB value in ?rgb
?color rdfs:label ?label. # store label in ?label
FILTER (lang(?label)="de" || lang(?label) = "en" || lang(?label) = "fr" || lang(?label) = "tr")
}
ORDER BY ASC(?rgb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment