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

Line 115: Line 115:
==Unenriched Strings Generator==
==Unenriched Strings Generator==
This query generates a list of string values of a particular type of ''as recorded'' data occurring in a DS Record which have not be qualified by an authority value (i.e., reconciled to its linked data equivalent in a Linked Open Vocabulary or Authority).
This query generates a list of string values of a particular type of ''as recorded'' data occurring in a DS Record which have not be qualified by an authority value (i.e., reconciled to its linked data equivalent in a Linked Open Vocabulary or Authority).
<syntaxhighlight lang="SPARQL">
<syntaxhighlight lang="SPARQL">
SELECT ?record ?recordLabel ?string ?authority ?authorityLabel ?roleLabel
SELECT
WHERE {
  # declared variables for values matching the following pattern
  ?record p:P14 ?stringStatement .
?record
  ?stringStatement ps:P14 ?string .
  # a link to a DS record
  #FILTER NOT EXISTS { ?stringStatement pq:P17 ?authority . }
?recordLabel
  OPTIONAL { ?stringStatement pq:P15 ?role . }
  # the name/label of the DS record
?string
  # the string value as recorded in the original catalog record
?authority
  # a link to the authority record to which the string value has been reconciled
?authorityLabel
  # a label for the the authority record in the DS database
#?roleLabel
  # where applicable, a label for role information (un-comment roleLabel variable when querying name data to get role information)
 
WHERE
  # the patterns or conditions that need to be met to return values for the above variables
  {
    ?record p:P14 ?stringStatement .
  # identifies records with statements with corresponding property (change P-value for as recorded value to be queried)
    ?stringStatement ps:P14 ?string .
  # identifies statements that have strings with corresponding property (change P-value for as recorded value to be queried)
    FILTER NOT EXISTS { ?stringStatement pq:P17 ?authority . }
  # identifies those statements which have not been enriched with authority values (change P-value for authority file value to be queried)
    #OPTIONAL { ?stringStatement pq:P15 ?role . }
  # only used for name data, un-comment optional clause when querying name data
    
    
     SERVICE wikibase:label {
     SERVICE wikibase:label {
Line 128: Line 149:
}
}
ORDER BY ASC (?string)
ORDER BY ASC (?string)
<syntaxhighlight>
# this sorts the results alphabetically by as recorded string values
</syntaxhighlight>
Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits