query-2a2802fa6ce9ff16e696beab187e3d09

rq turtle/ttl

Retrieve article links from wikidata query serviceWikidata Query Service Question --- Objective 1: retrieve article links from wikidata query service Objective 1 Example: https://query.wikidata.org/#PREFIX%20schema%3A%20%3Chttp%3A%2F%2Fschema.org%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fcid%20%3Fcountry%20%3Farticle%20WHERE%20%7B%0A%20%20%20%20%3Fcid%20wdt%3AP31%20wd%3AQ178561%20.%0A%20%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20%3Fcid%20rdfs%3Alabel%20%3Fcountry%20filter%20%28lang%28%3Fcountry%29%20%3D%20%22en%22%29%20.%0A%20%20%20%20%7D%0A%20%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20%3Farticle%20schema%3Aabout%20%3Fcid%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AinLanguage%20%22en%22%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wikipedia.org%2F%3E%20.%0A%20%20%20%20%7D%0A%7D%20--- - Now the result seems to work here at face value. - However, there are 14414 results with only 8728 links. - That leaves me with 5686 items without a corresponding article link. - Most of these are because they don't have an English article. - For instance if we search "Battle for Glinu" (Q46002). It has 4 Wikipedia entries in different languages: hr,ru,sh,sr. - However, when I change the languages, or include them all, I cant seem to retrieve anymore links. --- 15:42, 17 January 2022 (UTC)) talk (Dipsacus fullonumThe query cannot give links to articles in English Wikipedia which don't exists. So what is that you want from the query? --: Does this query do what you want?UnlimitedRed@ 16:02, 17 January 2022 (UTC)) talk (UnlimitedRedHi. I want the query to provide links even if there is no english article. For instance the Battle of Glinu has links available, just not in english. I want one of those links.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?cid ?country ?article ?language WHERE {
    VALUES ?language { "en" "hr" "ru" "sh" "sr" }
    ?cid wdt:P31 wd:Q178561 .
    OPTIONAL {
      ?cid rdfs:label ?country filter (lang(?country) = "en") .
    }
    OPTIONAL {
      ?article schema:about ?cid .
      ?article schema:inLanguage ?language .
      ?article schema:isPartOf [ wikibase:wikiGroup "wikipedia" ] .
    }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?article"):::projected v3("?cid"):::projected v1("?country"):::projected v2("?language"):::projected a1((" ")) c3(["wd:Q178561"]):::iri c8(["wikipedia"]):::literal bind0[/VALUES ?language/] bind0-->v2 bind00(["en"]) bind00 --> bind0 bind01(["hr"]) bind01 --> bind0 bind02(["ru"]) bind02 --> bind0 bind03(["sh"]) bind03 --> bind0 bind04(["sr"]) bind04 --> bind0 v3 --"wdt:P31"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."schema:about".-> v3 v4 --"schema:inLanguage"--> v2 a1 --"wikibase:wikiGroup"--> c8 v4 --"schema:isPartOf"--> a1 end