Hi Eric,
This should work, although others with more SPARQL experience may have
suggestions on how to simplify it:
SELECT ?personLabel ?archivesAtLabel ?describedAt WHERE {
> ?person wdt:P106 wd:Q49757;
> wdt:P135 wd:Q213457;
> p:P485 ?archivesStatement.
> ?archivesStatement ps:P485 ?archivesAt;
> pq:P973 ?describedAt.
> SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
> }
> ORDER BY (?personLabel)
Try it! ↗ <https://w.wiki/4w2G>
My understanding is that you need to retrieve the entire statement for P485
(?archivesStatement) using p: instead of wdt:, and *then* retrieve the
value and the qualifier (using pq:).
If you want to retrieve even those poets without a P973 qualifier for P485,
you can add an "optional" wrapper around the P973 line (link
<https://w.wiki/4w2J>).
Hope this helps!
Karly
On Wed, Mar 9, 2022 at 9:07 AM Eric Lease Morgan <[log in to unmask]> wrote:
> How can I write a WikiData SPARQL query to return the URLs of a special
> collection?
>
> I have the following query:
>
> SELECT ?personLabel ?archivesatLabel WHERE {
> ?person wdt:P106 wd:Q49757;
> wdt:P135 wd:Q213457;
> wdt:P485 ?archivesat.
> SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
> }
> ORDER BY (?person)
>
> The query finds people who are beatnik poets and have archival
> collections. The query outputs a little table such as this:
>
> personLabel archivesatLabel
> Ira Cohen Beinecke Rare
> Tuli Kupferberg Fales Library
> Michael McClure University of Victoria
> Jack Kerouac Harry Ransom Center
> Jack Kerouac University of Victoria
> Jack Kerouac Stuart A. Rose Manuscript
> John Wieners University of Delaware
>
> This is nice, but some of the artchivesat properties also point to URL's
> where the archives are described in greater detail. See, for example, the
> "record" for Ed Dorn:
>
> https://www.wikidata.org/wiki/Q5334756
>
> I want these URL's returned in my query, and the result would look
> something like this:
>
> personLabel archivesatLabel describedat
> Ira Cohen Beinecke Rare http://foobfhdhar.edu/
> Tuli Kupferberg Fales Library http://fafdsasdfobar.edu/
> Michael McClure University of Victoria http://foasdfar.edu/
> Jack Kerouac Harry Ransom Center http://fossbar.edu/
> Jack Kerouac University of Victoria http://foobasr.edu/
> Jack Kerouac Stuart A. Rose Manuscript http://foobar.edu/
> John Wieners University of Delaware http://fasdoobar.edu/
>
> But the following does NOT work:
>
> SELECT ?personLabel ?archivesatLabel ?describedat WHERE {
> ?person wdt:P106 wd:Q49757;
> wdt:P135 wd:Q213457;
> wdt:P485 ?archivesat;
> wdt:P973 ?describedat.
> SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
> }
> ORDER BY (?person)
>
>
> What am I doing wrong? Do I need an additional prefix? How can I get the
> URLs associated with describedat to be included in the output?
>
> --
> Eric Morgan
> University of Notre Dame
>
|