DS Catalog:SPARQL Query Service/example queries: Difference between revisions

Jump to navigation Jump to search
Line 107: Line 107:
====Holding Institutions====
====Holding Institutions====
====Languages====
====Languages====
The following query
<syntaxhighlight lang="SPARQL">
# prefixes
PREFIX wd: <https://catalog.digital-scriptorium.org/entity/>
PREFIX wds: <https://catalog.digital-scriptorium.org/entity/statement/>
PREFIX wdv: <https://catalog.digital-scriptorium.org/value/>
PREFIX wdt: <https://catalog.digital-scriptorium.org/prop/direct/>
PREFIX p: <https://catalog.digital-scriptorium.org/prop/>
PREFIX ps: <https://catalog.digital-scriptorium.org/prop/statement/>
PREFIX pq: <https://catalog.digital-scriptorium.org/prop/qualifier/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# find manuscript records with languages recorded
SELECT ?record ?recordLabel ?languageString (GROUP_CONCAT(?languageLabel;separator="|") as ?languages) (GROUP_CONCAT(?externalID;separator="|") as ?externalIDs)
WHERE {
# bind query variables
  BIND(p:P21 AS ?languageAsRecordedStatement).
  BIND(ps:P21 AS ?languageAsRecorded).
  BIND(pq:P22 AS ?hasLanguage).
  BIND(wdt:P42 AS ?hasWikidataQID).
# statement: manuscript record has statement for language
  ?record ?languageAsRecordedStatement ?languageStatement .
# statement: language statement has language object recorded as string value
  ?languageStatement ?languageAsRecorded ?languageString .
# statement: language statement has qualifier for structured/authority value
  ?languageStatement ?hasLanguage ?language .
# statement: authority value is represented by URI in external controlled vocabulary
  ?language ?hasWikidataQID ?QID .
 
# render QIDs as URLs
  BIND(CONCAT("https://wikidata.org/entity/",?QID) AS ?externalID)
# return English language labels
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]".
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?record rdfs:label ?recordLabel .
    ?language rdfs:label ?languageLabel .
  }
  }
GROUP BY ?record ?recordLabel ?languageString
ORDER BY ?recordLabel
LIMIT 10000
</syntaxhighlight>
Try it [https://catalog.digital-scriptorium.org/query/#%23%20prefixes%0APREFIX%20wd%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fentity%2F%3E%0APREFIX%20wds%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fentity%2Fstatement%2F%3E%0APREFIX%20wdv%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fvalue%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20p%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fprop%2F%3E%0APREFIX%20ps%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20pq%3A%20%3Chttps%3A%2F%2Fcatalog.digital-scriptorium.org%2Fprop%2Fqualifier%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0A%23%20find%20manuscript%20records%20with%20languages%20recorded%0ASELECT%20%3Frecord%20%3FrecordLabel%20%3FlanguageString%20%28GROUP_CONCAT%28%3FlanguageLabel%3Bseparator%3D%22%7C%22%29%20as%20%3Flanguages%29%20%28GROUP_CONCAT%28%3FexternalID%3Bseparator%3D%22%7C%22%29%20as%20%3FexternalIDs%29%0AWHERE%20%7B%0A%23%20bind%20query%20variables%0A%20%20BIND%28p%3AP21%20AS%20%3FlanguageAsRecordedStatement%29.%0A%20%20BIND%28ps%3AP21%20AS%20%3FlanguageAsRecorded%29.%0A%20%20BIND%28pq%3AP22%20AS%20%3FhasLanguage%29.%0A%20%20BIND%28wdt%3AP42%20AS%20%3FhasWikidataQID%29.%0A%23%20statement%3A%20manuscript%20record%20has%20statement%20for%20language%0A%20%20%3Frecord%20%3FlanguageAsRecordedStatement%20%3FlanguageStatement%20.%0A%23%20statement%3A%20language%20statement%20has%20language%20object%20recorded%20as%20string%20value%0A%20%20%3FlanguageStatement%20%3FlanguageAsRecorded%20%3FlanguageString%20.%0A%23%20statement%3A%20language%20statement%20has%20qualifier%20for%20structured%2Fauthority%20value%0A%20%20%3FlanguageStatement%20%3FhasLanguage%20%3Flanguage%20.%0A%23%20statement%3A%20authority%20value%20is%20represented%20by%20URI%20in%20external%20controlled%20vocabulary%0A%20%20%3Flanguage%20%3FhasWikidataQID%20%3FQID%20.%0A%20%20%0A%23%20render%20QIDs%20as%20URLs%0A%20%20BIND%28CONCAT%28%22https%3A%2F%2Fwikidata.org%2Fentity%2F%22%2C%3FQID%29%20AS%20%3FexternalID%29%0A%0A%23%20return%20English%20language%20labels%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%0A%20%20%20%20%3Frecord%20rdfs%3Alabel%20%3FrecordLabel%20.%0A%20%20%20%20%3Flanguage%20rdfs%3Alabel%20%3FlanguageLabel%20.%0A%20%20%7D%0A%20%20%7D%0AGROUP%20BY%20%3Frecord%20%3FrecordLabel%20%3FlanguageString%0AORDER%20BY%20%3FrecordLabel%0ALIMIT%2010000 here].
====Materials====
====Materials====
====Other associated names/agents====
====Other associated names/agents====
Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits

Navigation menu