query-fff02a8979509a42f92c7004b9a7f8d5

rq turtle/ttl

QuickStatements V1 syntax if results downloaded in TSV format SELECT DISTINCT ?remove ?statement2 WHERE { ?item wdt:P171 wd:Q25347. ?item p:P2868 ?s. ?s ps:P2868 wd:Q810198; pq:P642 ?basionymof . FILTER NOT EXISTS { ?s prov:wasDerivedFrom ?r } ?item wdt:P12766 ?basionymof . # "basionym of" statement already present SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } BIND (ENCODE_FOR_URI(REPLACE(STR(?item), ".Q", "Q")) AS ?qid) BIND (STR("-STATEMENT") AS ?remove) # the statement identifier returned by the query is in the following format: # http://www.wikidata.org/entity/statement/Q17464368-AFA4527C-4A51-4633-BE6D-07B2AD2B51BC # we need to strip the prefix, and replace the first hyphen with a dollar sign # which is what QuickStatements V1 recognizes BIND (ENCODE_FOR_URI(REPLACE(STR(?s), ".Q", "Q")) AS ?statement) BIND (REPLACE(?statement, "(Q\d+)-(.)", "$1\$$2") AS ?statement2) } LIMIT 10

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# QuickStatements V1 syntax if results downloaded in TSV format
SELECT DISTINCT ?remove ?statement2 WHERE {
  ?item wdt:P171* wd:Q25347.
  ?item p:P2868 ?s.
  ?s ps:P2868 wd:Q810198;
     pq:P642 ?basionymof .
  FILTER NOT EXISTS { ?s prov:wasDerivedFrom ?r }
  ?item wdt:P12766 ?basionymof . # "basionym of" statement already present
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
  BIND (ENCODE_FOR_URI(REPLACE(STR(?item), ".*Q", "Q")) AS ?qid)
  BIND (STR("-STATEMENT") AS ?remove)
  # the statement identifier returned by the query is in the following format:
  # http://www.wikidata.org/entity/statement/Q17464368-AFA4527C-4A51-4633-BE6D-07B2AD2B51BC
  # we need to strip the prefix, and replace the first hyphen with a dollar sign
  # which is what QuickStatements V1 recognizes
  BIND (ENCODE_FOR_URI(REPLACE(STR(?s), ".*Q", "Q")) AS ?statement)
  BIND (REPLACE(?statement, "(Q\\d+)-(.*)", "$1\\$$2") AS ?statement2) 
} LIMIT 10

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?basionymof") v3("?item") v5("?qid") v2("?r") v6("?remove"):::projected v1("?s") v7("?statement") v8("?statement2"):::projected c10(["bd:serviceParam"]):::iri c12(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal c3(["wd:Q25347"]):::iri c6(["wd:Q810198"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"prov:wasDerivedFrom"--> e0v2 e0v2("?r"):::projected e0v1("?s"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"prov:wasDerivedFrom"--> v2 v3 --"p:direct/P171"--> c3 v3 --"p:P2868"--> v1 v1 --"p:statement/P2868"--> c6 v1 --"p:qualifier/P642"--> v4 v3 --"p:direct/P12766"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind1[/"encode-for-uri(replace(str(?item),'.*Q','Q'))"/] v3 --o bind1 bind1 --as--o v5 bind2[/"str('-STATEMENT')"/] bind2 --as--o v6 bind3[/"encode-for-uri(replace(str(?s),'.*Q','Q'))"/] v1 --o bind3 bind3 --as--o v7 bind4[/"replace(?statement,'(Q\d+)-(.*)','$1\$$2')"/] v7 --o bind4 bind4 --as--o v8