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.

Revisions

  1. ssp renamed this gist May 26, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ssp renamed this gist May 26, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. ssp revised this gist May 26, 2016. 4 changed files with 9 additions and 11 deletions.
    1 change: 0 additions & 1 deletion Colours from Wikidata or dbpedia
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    An attempt to query for colours and their hex values to get their names in several languages.
    4 changes: 4 additions & 0 deletions Colours from Wikidata or dbpedia.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    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)
    7 changes: 2 additions & 5 deletions Wikidata.sparql
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,7 @@ 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
    OPTIONAL { # restrict to certain languages
    ?color rdfs:label ?label.
    FILTER (lang(?label)="de" || lang(?label) = "en" || lang(?label) = "fr" || lang(?label) = "tr")
    }
    FILTER (lang(?label)="de" || lang(?label) = "en" || lang(?label) = "fr" || lang(?label) = "tr")
    }
    ORDER BY ASC(?rgb) # order by sRGB value (no HSV in Wikidata, it seems)
    ORDER BY ASC(?rgb)

    8 changes: 3 additions & 5 deletions dbpedia.sparql
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,8 @@
    SELECT ?color ?label (lang(?label) AS ?language) ?hex ?hue WHERE {
    ?color rdf:type dbo:Colour.
    ?color dbo:colourHexCode ?hex.
    ?color dbo:hsvCoordinateHue ?hue.
    OPTIONAL {
    ?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)
  4. ssp created this gist May 26, 2016.
    1 change: 1 addition & 0 deletions Colours from Wikidata or dbpedia
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    An attempt to query for colours and their hex values to get their names in several languages.
    11 changes: 11 additions & 0 deletions Wikidata.sparql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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
    OPTIONAL { # restrict to certain languages
    ?color rdfs:label ?label.
    FILTER (lang(?label)="de" || lang(?label) = "en" || lang(?label) = "fr" || lang(?label) = "tr")
    }
    }
    ORDER BY ASC(?rgb) # order by sRGB value (no HSV in Wikidata, it seems)

    10 changes: 10 additions & 0 deletions dbpedia.sparql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    SELECT ?color ?label (lang(?label) AS ?language) ?hex ?hue WHERE {
    ?color rdf:type dbo:Colour.
    ?color dbo:colourHexCode ?hex.
    ?color dbo:hsvCoordinateHue ?hue.
    OPTIONAL {
    ?color rdfs:label ?label.
    FILTER (lang(?label) ="de" || lang(?label) ="en" || lang(?label) ="fr" || lang(?label) ="tr")
    }
    }
    ORDER BY DESC(?hue)