Class: WikidataPositionHistory::SPARQL::PositionQuery
- Defined in:
- lib/sparql/position_query.rb
Overview
SPARQL for fetching metadata about a position
Instance Method Summary collapse
Methods inherited from ItemQuery
#initialize, #results_as, #wdqs_url
Constructor Details
This class inherits a constructor from WikidataPositionHistory::SPARQL::ItemQuery
Instance Method Details
#raw_sparql ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sparql/position_query.rb', line 7 def raw_sparql " # position-metadata\n\n SELECT DISTINCT ?item ?inception ?inception_precision ?abolition ?abolition_precision\n ?replaces ?replacedBy ?derivedReplaces ?derivedReplacedBy\n ?isPosition ?isLegislator\n ?isConstituency ?representative_count ?legislature\n WHERE {\n VALUES ?item { wd:%s }\n BIND(EXISTS { wd:%s wdt:P279+ wd:Q4164871 } as ?isPosition)\n BIND(EXISTS { wd:%s wdt:P279+ wd:Q4175034 } as ?isLegislator)\n BIND(EXISTS { wd:%s wdt:P31/wdt:P279+ wd:Q192611 } as ?isConstituency)\n\n OPTIONAL { ?item p:P571 [ a wikibase:BestRank ;\n psv:P571 [ wikibase:timeValue ?inception; wikibase:timePrecision ?inception_precision ]\n ] }\n OPTIONAL { ?item p:P576 [ a wikibase:BestRank ;\n psv:P576 [ wikibase:timeValue ?abolition; wikibase:timePrecision ?abolition_precision ]\n ] }\n OPTIONAL { ?item wdt:P1365 ?replaces }\n OPTIONAL { ?item wdt:P1366 ?replacedBy }\n OPTIONAL { ?derivedReplaces wdt:P1366 ?item }\n OPTIONAL { ?derivedReplacedBy wdt:P1365 ?item }\n\n OPTIONAL { # if constituency\n ?item p:P1410 [ a wikibase:BestRank ; ps:P1410 ?representative_count ; pq:P194 ?legislature ]\n }\n }\n SPARQL\nend\n" |
#sparql_args ⇒ Object
39 40 41 |
# File 'lib/sparql/position_query.rb', line 39 def sparql_args [itemid] * 4 end |