Jump to content

Sparql.anything

From mediawiki.org
Github page
Command line parameters
SPARQL-parameters
Start using docker
Web UI
SPARQL Endpoint
IMPORTANT NOTES
  • Docker container allows remote execution of commands through SPARQL-query (command parameter)
  • It allows reading local files (least location and from-archive parameters.
  • Container answers to non-localhost also (ie. if IP is public then service is public)


Example query

[edit]

Example for querying population grouped by gender. (ie. data for age pyramid) from Stats.fi

PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX  fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX column: <http://www.w3.org/1999/02/22-rdf-syntax-ns#_>

SELECT ?time ?gender ?agegroup ?value
WHERE
  { SERVICE <x-sparql-anything:>
      { fx:properties
                  fx:media-type  "application/json" ;
                  fx:location  "https://pxdata.stat.fi:443/PxWeb/api/v1/fi/StatFin/vamuu/statfin_vamuu_pxt_11lj.px" ; 
                  fx:http.method  "POST" ;
                  fx:http.payload  "{ \"query\": [ { \"code\": \"Kuukausi\", \"selection\": { \"filter\": \"item\", \"values\": [ \"2022M10\" ] } }, { \"code\": \"Alue\", \"selection\": { \"filter\": \"item\", \"values\": [ \"SSS\" ] } }, { \"code\": \"Sukupuoli\", \"selection\": { \"filter\": \"item\", \"values\": [ \"1\", \"2\" ] } }, { \"code\": \"Ikä\", \"selection\": { \"filter\": \"agg:5-vuotisikä 0-4, 5-9, , 100-.agg\", \"values\": [ \"0-4\", \"5-9\", \"10-14\", \"15-19\", \"20-24\", \"25-29\", \"30-34\", \"35-39\", \"40-44\", \"45-49\", \"50-54\", \"55-59\", \"60-64\", \"65-69\", \"70-74\", \"75-79\", \"80-84\", \"85-89\", \"90-94\", \"95-99\", \"100-\" ] } } ], \"response\": { \"format\": \"json\" } }" 
         . ?row xyz:key ?keys
         . ?row xyz:values ?values    
         . ?keys column:1 ?time
         . ?keys column:2 ?rowval_2    
         . ?keys column:3 ?gender
         . ?keys column:4 ?agegroup
         . ?values column:1 ?value
      }
  BIND(xsd:integer(strbefore(?agegroup,"-")) as ?sortkey) 
  }
ORDER BY ?sortkey

Try it!

Target workflow

[edit]
  1. Statistics finland: Väestörakenteen ennakkotiedot
  2. SPARQL.anything (NEEDS PROPER DOCKER CONTAINER + SECURE SETUP)
  3. Tabular data from SPARQL to Commons (https://github.com/JoeClos/listeria-bot)
  4. Wikimedia Commons page (https://github.com/JoeClos/listeria-bot)
  5. Lua module which reads the values from Wikimedia Commons (MISSING)
  6. Age pyramid graph. (MISSING)

Example age pyramid

[edit]
Huom
esimerkkimaa ei ole Suomi