User:Vahurzpu/Queries
Jump to navigation
Jump to search
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
Try it!
High schools in Virginia with coordinate location (P625) but no OpenStreetMap links[edit]
PREFIX osmt: <https://wiki.openstreetmap.org/wiki/Key:>
SELECT DISTINCT ?school WHERE {
?school wdt:P31 wd:Q9826.
?school wdt:P131* wd:Q1370.
?school wdt:P625 [].
FILTER (!BOUND(?osmid)).
SERVICE <https://sophox.org/sparql> {
OPTIONAL {?osmid osmt:wikidata ?school}.
}
}
US laws where the United States Public Law (P3837) citation disagrees with legislated by (P467)[edit]
SELECT ?law ?pl ?plterm ?normalterm WHERE
{
?law wdt:P31 wd:Q476068.
?law wdt:P3837 ?pl.
BIND (STRBEFORE(?pl, "-") as ?congstr).
?plterm p:P31 ?termprop.
?termprop ps:P31 wd:Q15238777.
?termprop pq:P642 wd:Q11268.
?termprop pq:P1545 ?congstr.
?law wdt:P467 ?normalterm.
FILTER (?normalterm != ?plterm)
}
Uncited dates of death for people who have NYT obituaries in Wikidata[edit]
SELECT ?subject ?subjectLabel ?obiturl WHERE
{
?item wdt:P31 wd:Q309481.
?item wdt:P1433 wd:Q9684.
?item wdt:P953 ?obiturl.
?item wdt:P921 ?subject.
?subject p:P570 ?deathStatement.
MINUS {?deathStatement wikibase:rank wikibase:DeprecatedRank}
MINUS {?deathStatement prov:wasDerivedFrom []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
People at Janelia Research Campus (Q1319362), along with their identifiers on the Janelia webpage[edit]
SELECT ?qid_person ?janelia_person ?orcid
WHERE
{
?item wdt:P1416 wd:Q1319362.
OPTIONAL {?item wdt:P496 ?orcid.}
?item p:P1416 [prov:wasDerivedFrom [pr:P854 ?biourl]].
BIND (STRAFTER(STR(?biourl), "/people/") AS ?janelia_person).
BIND (STRAFTER(STR(?item), "/entity/") AS ?qid_person).
}
People whose place of death (P20) is in a Nazi concentration camp (Q328468), but died outside the existence of Nazi Germany (Q7318)[edit]
SELECT ?person ?personLabel ?deathday WHERE {
wd:Q7318 wdt:P571 ?start.
wd:Q7318 wdt:P576 ?end.
?person wdt:P570 ?deathday.
?person wdt:P20 ?camp.
?camp wdt:P31 wd:Q328468.
FILTER (!((?deathday > ?start) && (?deathday < ?end))).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?deathday
described at URL (P973) that is part of English Wikipedia (Q328)[edit]
SELECT ?item ?itemLabel ?url WHERE {
?item wdt:P973 ?url.
FILTER CONTAINS(STR(?url), "en.wikipedia").
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Advisors without Academic Tree ID (P2381) of students with the ID[edit]
SELECT DISTINCT ?advisor ?advisorLabel WHERE
{
?student wdt:P184 ?advisor.
?student wdt:P2381 [].
MINUS {?advisor wdt:P2381 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Authors in the High Energy Physics category of arXiv (Q118398) without INSPIRE-HEP author ID (P2930)[edit]
SELECT DISTINCT ?author ?authorLabel WHERE {
?paper wdt:P818 ?arxiv.
FILTER STRSTARTS(?arxiv, "hep").
?paper wdt:P50 ?author.
MINUS {?author wdt:P2930 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Approximate equivalent of the DNB No WP on Wikisource[edit]
This query returns Wikisource pages where at least one of the main subjects is missing an English Wikipedia article. Right now this excludes DNB redirect pages; many of these are missing main subjects entirely.
SELECT ?subject ?subjectLabel ?ws WHERE
{
?item wdt:P1433 wd:Q15987216.
?item wdt:P31 wd:Q19389637.
?ws schema:about ?item.
?item wdt:P921 ?subject.
MINUS {
?wp schema:about ?subject.
?wp schema:isPartOf <https://en.wikipedia.org/>.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Get data about people based on items connected through Commons sitelinks[edit]
I don't expect to reuse this query much, or maybe ever, but the pattern for "get the person, either directly or through their category" is useful on Commons generally. Also, while I didn't think of this earlier, it wouldn't be that hard to directly input sitelinks.
SELECT ?subject ?birth ?death ?commonscat ?creatorpage
WITH {
SELECT ?subject WHERE {
VALUES ?item {wd:Q332331 wd:Q449885 wd:Q6264333}
{
?item wdt:P31 wd:Q5.
BIND (?item AS ?subject).
} UNION {
?item wdt:P301 ?subject.
}
}
} AS %subjects
WHERE {
INCLUDE %subjects.
OPTIONAL {?subject wdt:P569 ?birth.}
OPTIONAL {?subject wdt:P570 ?death.}
OPTIONAL {?subject wdt:P373 ?commonscat.}
OPTIONAL {?subject wdt:P1472 ?creatorpage.}
}
Statements on an item supported by a Wikimedia import[edit]
SELECT ?st ?itemLabel ?propLabel WHERE {
BIND (wd:Q42 as ?item).
?item ?pprop ?st.
?st rdf:type wikibase:BestRank.
?st prov:wasDerivedFrom ?ref.
?ref pr:P143|pr:P4656 [].
?prop wikibase:claim ?pprop.
MINUS {?prop wikibase:propertyType wikibase:ExternalId}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
English Wikipedia's "taxa by author" categories without metadata[edit]
SELECT ?cat ?title WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "en.wikipedia.org";
wikibase:api "Generator";
mwapi:generator "categorymembers";
mwapi:gcmtitle "Category:Taxa by author";
mwapi:gcmprop "ids|title|type";
mwapi:gcmlimit "max".
?title wikibase:apiOutput mwapi:title.
?cat wikibase:apiOutputItem mwapi:item.
}
MINUS {
?cat p:P4224 ?contains.
?contains ps:P4224 wd:Q16521.
?contains pq:P405 ?author.
}
FILTER (?title != "Category:Animal taxa by author").
FILTER (?title != "Category:Botanical taxa by author").
}
Wikisource pages linked to humans that aren't in the right namespace[edit]
SELECT ?person ?wspage WHERE {
?person wdt:P31 wd:Q5.
?sitelink schema:about ?person; schema:isPartOf <https://en.wikisource.org/>; schema:name ?wspage.
FILTER (!STRSTARTS(?wspage, "Author:")).
FILTER (!STRSTARTS(?wspage, "Portal:")).
}