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

Jump to navigation Jump to search
Line 935: Line 935:
====Named Entity (Person or Organization)====
====Named Entity (Person or Organization)====
====Place of Production====
====Place of Production====
This example identifies manuscripts produced in [https://catalog.digital-scriptorium.org/entity/Q3086 Egypt] or [https://catalog.digital-scriptorium.org/entity/Q3093 Cairo].
A note on place queries: the DS authorities are not hierarchical, so this query only identifies manuscripts specifically described as being produced in Egypt or in Cairo, and not other places in Egypt, such as other cities or other geographic areas contained within Egypt. To find manuscripts produced in those specific locations, the query would have to include each of those specific values.
<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 for manuscripts produced in Egypt or in Cairo
SELECT ?record ?recordLabel ?placeString (GROUP_CONCAT(?placeLabel;separator="|") as ?places)
WHERE {
# set variable value for place or places to be queried
VALUES ?place { wd:Q3086 wd:Q3093 }
# bind query variables
  BIND(p:P27 AS ?placeAsRecordedStatement).
  BIND(ps:P27 AS ?placeAsRecorded).
  BIND(pq:P28 AS ?hasPlace).
# statement: manuscript record has statement for place of production
  ?record ?placeAsRecordedStatement ?placeStatement .
# statement: place statement has place object recorded as string value
  ?placeStatement ?placeAsRecorded ?placeString .
# statement: place statement has qualifier for structured/authority value
  ?placeStatement ?hasPlace ?place .
# return English language labels
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?record rdfs:label ?recordLabel .
    ?place rdfs:label ?placeLabel .
  }
  }
GROUP BY ?record ?recordLabel ?placeString
ORDER BY ?recordLabel
</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%20for%20manuscripts%20produced%20in%20Egypt%20or%20in%20Cairo%0ASELECT%20%3Frecord%20%3FrecordLabel%20%3FplaceString%20%28GROUP_CONCAT%28%3FplaceLabel%3Bseparator%3D%22%7C%22%29%20as%20%3Fplaces%29%0AWHERE%20%7B%0A%23%20set%20variable%20value%20for%20place%20or%20places%20to%20be%20queried%0AVALUES%20%3Fplace%20%7B%20wd%3AQ3086%20wd%3AQ3093%20%7D%0A%23%20bind%20query%20variables%0A%20%20BIND%28p%3AP27%20AS%20%3FplaceAsRecordedStatement%29.%0A%20%20BIND%28ps%3AP27%20AS%20%3FplaceAsRecorded%29.%0A%20%20BIND%28pq%3AP28%20AS%20%3FhasPlace%29.%0A%0A%23%20statement%3A%20manuscript%20record%20has%20statement%20for%20place%20of%20production%0A%20%20%3Frecord%20%3FplaceAsRecordedStatement%20%3FplaceStatement%20.%0A%23%20statement%3A%20place%20statement%20has%20place%20object%20recorded%20as%20string%20value%0A%20%20%3FplaceStatement%20%3FplaceAsRecorded%20%3FplaceString%20.%0A%23%20statement%3A%20place%20statement%20has%20qualifier%20for%20structured%2Fauthority%20value%0A%20%20%3FplaceStatement%20%3FhasPlace%20%3Fplace%20.%0A%0A%23%20return%20English%20language%20labels%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%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%3Fplace%20rdfs%3Alabel%20%3FplaceLabel%20.%0A%20%20%7D%0A%20%20%7D%0AGROUP%20BY%20%3Frecord%20%3FrecordLabel%20%3FplaceString%0AORDER%20BY%20%3FrecordLabel here].
====Subject====
====Subject====
This example identifies manuscripts described as being about [https://catalog.digital-scriptorium.org/entity/Q3035 Arab astronomy].
This example identifies manuscripts described as being about [https://catalog.digital-scriptorium.org/entity/Q3035 Arab astronomy].
Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits

Navigation menu