query-3cf2165f8bc947d23f6208abf2fcb3db

rq turtle/ttl

Wikipedia articles about Ashmolean items, their links to the Ashmolean web site, and candidate links from Wikidata Phabricator reportDoesn't work yet as MWAPI doesn't return enough external links.

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?itempage ?extlink ?url ?ash_id WHERE {
{SELECT DISTINCT ?name ?item ?itempage WHERE {
    ?item wdt:P195 wd:Q636400.   # items in the Ashmolean
    ?itempage schema:about ?item;
         schema:isPartOf <https://en.wikipedia.org/>;   # ENWP articles about them
         schema:name ?name     # Title of article
}
 }
OPTIONAL {SERVICE wikibase:mwapi { # External links from each article
    bd:serviceParam wikibase:api "Generator";
         wikibase:endpoint "en.wikipedia.org";
         mwapi:generator "allpages";
         mwapi:gapfrom ?name;
         mwapi:gapto ?name;
         mwapi:prop "extlinks";
         mwapi:ellimit 50 .
    ?extlink wikibase:apiOutput "extlinks/el/text()".
  }
    FILTER CONTAINS(?extlink, "ashmolean.org")
 }
OPTIONAL {?item wdt:P973 ?url FILTER CONTAINS(STR(?url), "ashmolean.org")
                }
OPTIONAL {?item wdt:P6610 ?ash_id}
} ORDER BY ?itempage

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?ash_id"):::projected v3("?extlink"):::projected v4("?item") v1("?itempage"):::projected v5("?name") v2("?url"):::projected c6([https://en.wikipedia.org/]):::iri c13(["en.wikipedia.org"]):::literal c9(["bd:serviceParam"]):::iri c15(["allpages"]):::literal c21(["50^^xsd:integer"]):::literal c23(["extlinks/el/text()"]):::literal c19(["extlinks"]):::literal c3(["wd:Q636400"]):::iri c11(["Generator"]):::literal v4 --"wdt:P195"--> c3 v1 --"schema:about"--> v4 v1 --"schema:isPartOf"--> c6 v1 --"schema:name"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c9 -."mwapi:api".-> c11 c9 --"mwapi:endpoint"--> c13 c9 --"mwapi:generator"--> c15 c9 --"mwapi:gapfrom"--> v5 c9 --"mwapi:gapto"--> v5 c9 --"mwapi:prop"--> c19 c9 --"mwapi:ellimit"--> c21 v3 --"mwapi:apiOutput"--> c23 end end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P973".-> v2 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P6610".-> v6 end