query-0dc09db9a37d973bd9060f4934b4d588

rq turtle/ttl

Case variations of author name strings

Example uppercase strings: https://w.wiki/nDK

Example items: Q2381157 Q21076181 Q21339258 Q21391696 Q21393244 Q21514479 Q21609166 Q22112765 Q22222864 Q63496558 Q64008584 Q88059762

PREFIX target: http://www.wikidata.org/entity/Q21393244

SELECT DISTINCT ?string (COUNT(?work) AS ?count) WITH { # Find strings associated with the target item SELECT DISTINCT ?string_ WHERE { { target: rdfs:label ?string_. } # in label UNION { target: skos:altLabel ?string_. } # in alias UNION { ?author_statement ps:P50 target: ; pq:P1932 ?string_. # in "stated as" strings for "author" statements on work items } } } AS %RAWstrings WITH { # Calculate capitalization variants of these raw strings SELECT DISTINCT ?string WHERE { INCLUDE %RAWstrings { { BIND(STR(?string_) AS ?string)} # the raw strings

UNION

{ BIND(UCASE(STR(?string_)) AS ?string)} # uppercased versions of the raw strings

UNION

{ BIND(LCASE(STR(?string_)) AS ?string)} # lowercased versions of the raw strings

          }

} } AS %NORMALIZEDstrings WHERE { # Find works that have "author name string" values equal to these normalized strings INCLUDE %NORMALIZEDstrings OPTIONAL { ?work wdt:P2093 ?string. }

} GROUP BY ?string ORDER BY DESC (?count)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
# Case variations of author name strings
# Example uppercase strings: https://w.wiki/nDK
# Example items: Q2381157 Q21076181 Q21339258 Q21391696 Q21393244 Q21514479 Q21609166 Q22112765 Q22222864 Q63496558 Q64008584 Q88059762

PREFIX target: <http://www.wikidata.org/entity/Q21393244>

SELECT 
DISTINCT ?string 
(COUNT(?work) AS ?count) 
WHERE {
  # Find works that have "author name string" values equal to these normalized strings
   {
  # Calculate capitalization variants of these raw strings
  SELECT DISTINCT ?string WHERE {
     {
  # Find strings associated with the target item
  SELECT DISTINCT ?string_ WHERE {
    { target: rdfs:label ?string_. } # in label
    UNION
    { target: skos:altLabel ?string_. } # in alias
    UNION
    {
      ?author_statement ps:P50 target: ; 
                        pq:P1932 ?string_. # in "stated as" strings for "author" statements on work items
    }
  }
}            {
   { BIND(STR(?string_) AS ?string)} # the raw strings
#    UNION
#    { BIND(UCASE(STR(?string_)) AS ?string)} # uppercased versions of the raw strings
#    UNION
#    { BIND(LCASE(STR(?string_)) AS ?string)} # lowercased versions of the raw strings
              }
  }
}  OPTIONAL { ?work wdt:P2093 ?string. }

}
GROUP BY ?string
ORDER BY DESC (?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?author_statement") v6("?count") v4("?string"):::projected v2("?string_") v5("?work"):::projected c1([http://www.wikidata.org/entity/Q21393244]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v3 --"ps:P50"--> c1 v3 --"pq:P1932"--> v2 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; c1 --"skos:altLabel"--> v2 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; c1 --"rdfs:label"--> v2 end union0r <== or ==> union0l end bind0[/"str(?string_)"/] v2 --o bind0 bind0 --as--o v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P2093".-> v4 end bind2[/"count(?work)"/] v5 --o bind2 bind2 --as--o v6