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

Jump to navigation Jump to search
Line 983: Line 983:


====Named Entity (Person or Organization)====
====Named Entity (Person or Organization)====
This
<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 associated with particular name(s) (personal or corporate entity or entities)
SELECT ?record ?recordLabel ?nameString (GROUP_CONCAT(?nameLabel;separator="|") as ?names) ?typeLabel ?roleLabel
WHERE {
VALUES ?name { wd:Q383 wd:Q425 wd:Q1488 wd:Q3203 wd:Q28158 } # Lawrence Schoenberg, Catholic Church, Masters of the Gold Scrolls, Ali Qushji, Ananda Coomaraswamy
# bind query variables
  BIND(p:P14 AS ?nameAsRecordedStatement).
  BIND(ps:P14 AS ?nameAsRecorded).
  BIND(pq:P17 AS ?hasName).
  BIND(pq:P15 AS ?hasRole).
  BIND(wdt:P16 AS ?hasType).
 
# statement: manuscript record has statement for associated name
  ?record ?nameAsRecordedStatement ?nameStatement .
# statement: name statement has name object recorded as string value
  ?nameStatement ?nameAsRecorded ?nameString .
# statement: name statement has qualifier for structured/authority value
  ?nameStatement ?hasName ?name .
# statement: associated name has role
  ?nameStatement ?hasRole ?role .
# statement: authority value has type (Personal or Corporate)
  ?name ?hasType ?type .
# return English language labels
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?record rdfs:label ?recordLabel .
    ?name rdfs:label ?nameLabel .
    ?role rdfs:label ?roleLabel .
    ?type rdfs:label ?typeLabel .
  }
  }
GROUP BY ?record ?recordLabel ?nameString ?roleLabel ?typeLabel
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%20associated%20with%20particular%20name%28s%29%20%28personal%20or%20corporate%20entity%20or%20entities%29%0ASELECT%20%3Frecord%20%3FrecordLabel%20%3FnameString%20%28GROUP_CONCAT%28%3FnameLabel%3Bseparator%3D%22%7C%22%29%20as%20%3Fnames%29%20%3FtypeLabel%20%3FroleLabel%0AWHERE%20%7B%0AVALUES%20%3Fname%20%7B%20wd%3AQ383%20wd%3AQ425%20wd%3AQ1488%20wd%3AQ3203%20wd%3AQ28158%20%7D%20%23%20Lawrence%20Schoenberg%2C%20Catholic%20Church%2C%20Masters%20of%20the%20Gold%20Scrolls%2C%20Ali%20Qushji%2C%20Ananda%20Coomaraswamy%0A%23%20bind%20query%20variables%0A%20%20BIND%28p%3AP14%20AS%20%3FnameAsRecordedStatement%29.%0A%20%20BIND%28ps%3AP14%20AS%20%3FnameAsRecorded%29.%0A%20%20BIND%28pq%3AP17%20AS%20%3FhasName%29.%0A%20%20BIND%28pq%3AP15%20AS%20%3FhasRole%29.%0A%20%20BIND%28wdt%3AP16%20AS%20%3FhasType%29.%0A%20%20%0A%23%20statement%3A%20manuscript%20record%20has%20statement%20for%20associated%20name%0A%20%20%3Frecord%20%3FnameAsRecordedStatement%20%3FnameStatement%20.%0A%23%20statement%3A%20name%20statement%20has%20name%20object%20recorded%20as%20string%20value%0A%20%20%3FnameStatement%20%3FnameAsRecorded%20%3FnameString%20.%0A%23%20statement%3A%20name%20statement%20has%20qualifier%20for%20structured%2Fauthority%20value%0A%20%20%3FnameStatement%20%3FhasName%20%3Fname%20.%0A%23%20statement%3A%20associated%20name%20has%20role%0A%20%20%3FnameStatement%20%3FhasRole%20%3Frole%20.%0A%23%20statement%3A%20authority%20value%20has%20type%20%28Personal%20or%20Corporate%29%0A%20%20%3Fname%20%3FhasType%20%3Ftype%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%3Fname%20rdfs%3Alabel%20%3FnameLabel%20.%0A%20%20%20%20%3Frole%20rdfs%3Alabel%20%3FroleLabel%20.%0A%20%20%20%20%3Ftype%20rdfs%3Alabel%20%3FtypeLabel%20.%0A%20%20%7D%0A%20%20%7D%0AGROUP%20BY%20%3Frecord%20%3FrecordLabel%20%3FnameString%20%3FroleLabel%20%3FtypeLabel%0AORDER%20BY%20%3FrecordLabel here].
====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].
This example identifies manuscripts produced in [https://catalog.digital-scriptorium.org/entity/Q3086 Egypt] or [https://catalog.digital-scriptorium.org/entity/Q3093 Cairo].
Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits

Navigation menu