User:Beat Estermann/WD-Atelier 2018

From Wikidata
Jump to navigation Jump to search

Participants[edit]

See: Wikipedia-Workshop, 30. Juni 2018.

Useful Links[edit]

importScript( 'User:Pasleim/derivedstatements.js' ); // User:Pasleim/derivedstatements.js
Explanatory note: For many items Wikidata has more information than can be seen on the item page. For example on Whitcomb L. Judson Whitcomb L. Judson (Q731876) you see that he is an inventor but you don't see his invention. That's because discoverer or inventor discoverer or inventor (P61) only links from the invention to the inventor and not the other way round. To solve this general problem that statements are only displayed in one way the script adds at the end of all item pages a new button to load inverse statements.

Trivia[edit]

Examples of Data Use[edit]

Examples of data use in the context of Wikipedia[edit]

Examples of data use outside Wikipedia/Wikimedia: external applications[edit]

Example Queries[edit]

Things named after French Presidents[edit]

#defaultView:Map
SELECT ?truc ?presLabel ?trucLabel ?coord ?layer WHERE {
 {
 SELECT DISTINCT ?truc (SAMPLE(?coord) AS ?coord) (SAMPLE(?layer) AS ?layer) WHERE {
 ?pres wdt:P39 wd:Q191954 ;
 rdfs:label ?layer.
 FILTER((LANG(?layer)) = "fr")
 
 ?truc wdt:P138 ?pres ;
 wdt:P625 ?coord.
 }
 GROUP BY ?truc ?trucLabel
 }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}
Try it!


Things named after Swiss Federal Councilors[edit]

#defaultView:Map
SELECT ?truc ?fcLabel ?trucLabel ?coord ?layer WHERE {
 {
 SELECT DISTINCT ?truc (SAMPLE(?coord) AS ?coord) (SAMPLE(?layer) AS ?layer) WHERE {
 ?fc wdt:P39 wd:Q11811941 ;
 rdfs:label ?layer.
 FILTER((LANG(?layer)) = "fr")
 
 ?truc wdt:P138 ?fc ;
 wdt:P625 ?coord.
 }
 GROUP BY ?truc ?trucLabel
 }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}
Try it!

Plays by Swiss Playwrights[edit]

SELECT DISTINCT ?play ?playLabel ?author ?authorLabel
WHERE {
  ?play wdt:P31/wdt:P279* wd:Q25379 ; 
        wdt:P50 ?author .
  ?author wdt:P27 wd:Q39 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
}
Try it!

Plays that Were Performed in Switzerland[edit]

SELECT DISTINCT ?play ?playLabel ?author ?premiere ?venueLabel

WHERE {
  ?play wdt:P31/wdt:P279* wd:Q25379 ; 
        wdt:P50 ?author .
  ?production wdt:P31/wdt:P279* wd:Q43099500 ;
              wdt:P144 ?play ;
              wdt:P276 ?venue .
  ?venue wdt:P361*/wdt:P131/wdt:P17 wd:Q39 .
             
  OPTIONAL { ?production wdt:P1191 ?premiere . }
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }

}

ORDER BY ?premiere
Try it!


Subclasses of Heritage Institutions[edit]

SELECT ?item
       (group_concat(distinct ?superClassLabel_en;separator="; ") as ?superClassLabels_en)    #Concatenate the values in order not to get several rows per item.
       (replace(group_concat(distinct ?superClass;separator="; "), "http://www.wikidata.org/entity/", "") as ?superClasses)   #Strip the path in order to get only the Q-number.        
	   ?Label_en
       (group_concat(distinct ?Alias_en;separator="; ") as ?Aliases_en)    #Concatenate the values in order not to get several rows per item.
       ?Label_de
       (group_concat(distinct ?Alias_de;separator="; ") as ?Aliases_de)
       ?Label_fr
       (group_concat(distinct ?Alias_fr;separator="; ") as ?Aliases_fr)
       ?Label_it
       (group_concat(distinct ?Alias_it;separator="; ") as ?Aliases_it)
       ?Label_es
       (group_concat(distinct ?Alias_es;separator="; ") as ?Aliases_es)
       ?Label_ru
       (group_concat(distinct ?Alias_ru;separator="; ") as ?Aliases_ru)
       ?Description_en       
       ?Description_de
       ?Description_fr
       ?Description_it
       ?Description_es
       ?Description_ru
WHERE {
  {?item wdt:P279+ wd:Q33506} UNION {?item wdt:P279+ wd:Q166118} UNION {?item wdt:P279+ wd:Q7075}.
  OPTIONAL { ?item rdfs:label ?Label_en . FILTER (lang(?Label_en) = "en") }
  OPTIONAL { ?item rdfs:label ?Label_de . FILTER (lang(?Label_de) = "de") } 
  OPTIONAL { ?item rdfs:label ?Label_fr . FILTER (lang(?Label_fr) = "fr") }
  OPTIONAL { ?item rdfs:label ?Label_it . FILTER (lang(?Label_it) = "it") }
  OPTIONAL { ?item rdfs:label ?Label_es . FILTER (lang(?Label_es) = "es") }
  OPTIONAL { ?item rdfs:label ?Label_ru . FILTER (lang(?Label_ru) = "ru") }
  OPTIONAL { ?item skos:altLabel ?Alias_en . FILTER (lang(?Alias_en) = "en") }
  OPTIONAL { ?item skos:altLabel ?Alias_de . FILTER (lang(?Alias_de) = "de") } 
  OPTIONAL { ?item skos:altLabel ?Alias_fr . FILTER (lang(?Alias_fr) = "fr") }
  OPTIONAL { ?item skos:altLabel ?Alias_it . FILTER (lang(?Alias_it) = "it") }
  OPTIONAL { ?item skos:altLabel ?Alias_es . FILTER (lang(?Alias_es) = "es") }
  OPTIONAL { ?item skos:altLabel ?Alias_ru . FILTER (lang(?Alias_ru) = "ru") }
  OPTIONAL { ?item schema:description ?Description_en . FILTER (lang(?Description_en) = "en") }
  OPTIONAL { ?item schema:description ?Description_de . FILTER (lang(?Description_de) = "de") } 
  OPTIONAL { ?item schema:description ?Description_fr . FILTER (lang(?Description_fr) = "fr") }
  OPTIONAL { ?item schema:description ?Description_it . FILTER (lang(?Description_it) = "it") }
  OPTIONAL { ?item schema:description ?Description_es . FILTER (lang(?Description_es) = "es") }
  OPTIONAL { ?item schema:description ?Description_ru . FILTER (lang(?Description_ru) = "ru") }
  OPTIONAL { ?item wdt:P279 ?superClass }
  OPTIONAL { ?item wdt:P279/rdfs:label ?superClassLabel_en . FILTER (lang(?superClassLabel_en) = "en") }
}
group by ?item  						#List all the variables for which the values are not concatenated!
         ?Label_en ?Description_en 
         ?Label_de ?Description_de 
         ?Label_fr ?Description_fr 
         ?Label_it ?Description_it
         ?Label_es ?Description_es
         ?Label_ru ?Description_ru
Try it!

Let's Practice![edit]

Querying & Editing Wikidata[edit]

Schauspielhaus Productions without a “based on” statement[edit]

Use the example query below to identify performing arts productions which do not have a "based on" statement to indicate the literary work they were based on. Complement the statement based on the Repertoire of Schauspielhaus Zürich, which contains information about the author of the work (download the Schauspielhaus Repertoire in Excel format).

Hints:

  • The entries for Schauspielhaus Zürich start around Q47404135 (the Q numbers represent the order in which the items were ingested into Wikidata).
  • When adding the "based on" statement, make sure that you indicate the Repertoire of Schauspielhaus Zürich as its source.

For advanced learners:

  • Can you modify the query to only include items which were performed at Schauspielhaus Zürich? – Add your query below the sample query.
  • Can you track the advancement of the work of your colleagues? – Run your query at different points in time and report the item count over time (create a small table below the sample queries).
SELECT DISTINCT ?item ?itemLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q43099500.   # performing arts production
  MINUS { ?item wdt:P144 [] }   # exclude if there is a "based on" statement
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,it". }
}
Try it!

Swiss heritage institutions without a “director” statement[edit]

Take the example query above as a starting point to create a query that outputs all Swiss museums without a director / manager (P1037) statement. Find the missing information for some of the listed museums on the Internet and add it to Wikidata.

Hints:

  • Indicate the website where you found the information as the source of your statement.

For advanced learners:

  • What other information can you add about the museum based on the information you can easily find on the Internet or in other sources you have at hand? – Take the entry on the Rijksmuseum (Q190804) as a source of inspiration for further statements to be added!
  • Do the same for Swiss libraries and/or archives.

Swiss heritage institutions without a German/French label[edit]

Use the example query in the data ingest guideline to identify Swiss museums without a label in German and/or French. Search for the relevant information on the Internet and add it to Wikidata.

For advanced learners:

  • Follow the guideline to download the data to a spreadsheet. Complete the labels and/or descriptions in the spreadsheet and feed them back into Wikidata using the Quick Statements tool.

Querying Wikidata & Editing Wikipedia[edit]

Use the query below to list actors and actresses who appeared in theatrical productions of Schauspielhaus Zürich who do not have an entry in the German Wikipedia in the order of the number of their appearances. Search for information about said actors/actresses and write a short Wikipedia article about them.

For people preferring to edit Wikipedia in English, French, Italian, etc.:

  • Adapt the query below to output the same list, but for actors and actresses who do not have an entry in your language. Add the query below. Create Wikipedia articles in your language.

For advanced users:

  • Create a list of all actors and actresses who appeared in theatrical productions of Schauspielhaus Zürich in the order of the number of their appearances with an overview which artists have a Wikipedia entry in which language.
  • The query below counts the number of appearances, counting actors who appeared several times in the same production (different roles) more than once. Adapt the query to indicate the number of individual productions in which the actor/actress appeared instead of providing the number of appearances. List the adapted query below.
SELECT ?actor ?actorLabel (count(*) AS ?count)
  WHERE {
  ?prod (wdt:P31/wdt:P279*) wd:Q43099500 ;
        wdt:P272 wd:Q40313234 .
  ?prod wdt:P161 ?actor . 
  MINUS { ?sitelink schema:isPartOf <https://de.wikipedia.org/> ;
     schema:about ?actor . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de" } .
} 

GROUP BY ?actor ?actorLabel
ORDER BY DESC (?count)
Try it!
  • The following query may be used in an upcoming editathon in Marseille. It outputs items for women in Marseille (place of birth or place of death) with a Wikidata entry, but without a Wikipedia article in French:
SELECT ?person ?personLabel ?personDescription ?occupation
  WHERE {
  { ?person wdt:P19 wd:Q23482 } UNION { ?person wdt:P20 wd:Q23482 }.
  ?person wdt:P21 wd:Q6581072 .
  MINUS { ?sitelink schema:isPartOf <https://fr.wikipedia.org/> ;
     schema:about ?person . }
  OPTIONAL {?person wdt:P106 ?occupation }.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr" } .
}
Try it!

Editing Wikidata[edit]

Pilot Ingest Ehrenreich Collection[edit]

The dataset for a small pilot data ingest of the Ehrenreich Collection contains the operas listed hereafter. Make sure that each work has an entry on Wikidata with a listing of all the character roles, and that each of the character roles has its own entry. Note in the list which items you have checked / added to Wikidata:

  • WAGNER: TRISTAN UND ISOLDE ✓ Done
  • PONCHIELLI: LA GIOCONDA ✓ Done
  • R. STRAUSS: ARIADNE AUF NAXOS ✓ Done
  • HANDEL: ORLANDO (incomplete)
  • GLUCK: ORPHÉE ✓ Done
  • BERLIOZ: BENVENUTO CELLINI ✓ Done

Example items:

Follow-up Data Ingest Operatic Roles[edit]

In June 2018, information about operatic roles was ingested from German Wikipedia. In some cases, the role designations and descriptions contain possessive pronouns that are out of context in Wikidata (e.g. "Seine Frau"; "Ihre Tochter"). Use the queries below to identify such cases and add the missing context to the description. Note that the "derivedstatements" gadget (listed in the section "Useful Links") allows to easily list all the characters of a play in a row, in the order of their ingestion.

Possessive pronouns in the item's label:

SELECT DISTINCT ?role ?roleLabel ?roleAlias ?play ?playLabel
WHERE 
{
  ?play wdt:P31/wdt:P279* wd:Q25379.
  ?role wdt:P31/wdt:P279* wd:Q95074.
  ?role wdt:P1441 ?play.
  ?role rdfs:label ?role_label.
  FILTER (contains(lcase(?role_label), 'sein')|| contains(lcase(?role_label), 'ihr') || contains(lcase(?role_label), 'deren') || contains(lcase(?role_label), 'dessen') ).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
Try it!

Same as above, but this time looking at the item's alias:

SELECT DISTINCT ?role ?roleLabel ?role_alias ?play ?playLabel
WHERE 
{
  ?play wdt:P31/wdt:P279* wd:Q25379.
  ?role wdt:P31/wdt:P279* wd:Q95074.
  ?role wdt:P1441 ?play.
  ?role skos:altLabel ?role_alias.
  FILTER (contains(lcase(?role_alias), 'sein')|| contains(lcase(?role_alias), 'ihr') || contains(lcase(?role_alias), 'deren') || contains(lcase(?role_alias), 'dessen') ).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
Try it!

Pilot ingest Théâtre de Genève / opera[edit]

(dataset and description on demand)

Exploring Ontologies & Editing Wikidata[edit]

Typology of heritage institutions[edit]

Use the Wikidata Ontology Explorer to inspect the typology of museums, archives, and libraries on Wikidata. Find out which are the most used properties in connection with these classes. Click through the main classes and properties and make sure that they have appropriate labels and descriptions in your language.

For Wikipedians:

  • Find out whether the main sub-classes already have their Wikipedia articles and create the missing ones or improve the existing ones.

For advanced learners:

  • Create overview tables of the most used sub-classes and properties, indicating for which ones labels and descriptions exist in a given set of languages. Add the code here.
  • Create an overview table of the most used properties in connection with a given class (museum, archive, library), detailing for which ones Wikipedia articles exist in a given set of languages.

Typology of concerts, recordings[edit]

Do the same as above, but for musical performance (Q6942562), for recording (Q13557414), and for voice type (Q1063547).

For advanced learners & musicologists:

  • Try to identify errors and gaps in the class trees and correct them.

Explore data modelling practices in Wikidata[edit]

Find out what property is commonly used to link creative works to book series:

  • Inspect the two queries below.
  • Replace the property P179 in the second query by the property that is second on the list resulting from the first query.
  • Check what happens if you remove the requirement that the item linked to the book series be a creative work - let it be any item.
  • Adapt the queries to your own needs and interests!
#List of properties linking a creative work to a book series, ordered by frequency of use
SELECT ?property ?propertyLabel ?count WITH {
  SELECT ?property ?value (COUNT(DISTINCT ?item) AS ?count) WHERE {
    ?bookseries wdt:P31/wdt:P279* wd:Q277759.
    ?item ?wdt ?bookseries.
    ?item wdt:P31/wdt:P279* wd:Q17537576.
    ?property a wikibase:Property;
              wikibase:directClaim ?wdt.
    FILTER(?property != wd:P31)
  }
  GROUP BY ?property ?value
  ORDER BY DESC(?count)
  LIMIT 10
} AS %results WHERE {
  INCLUDE %results.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-US,en,en". }
}
ORDER BY DESC(?count)
Try it!
# List pairs of creative works / bookseries linked by the property P179 (series)
SELECT ?item ?itemLabel ?bookseries ?bookseriesLabel 
WHERE
{
  ?bookseries wdt:P31/wdt:P279* wd:Q277759.
  ?item wdt:P179 ?bookseries.
  ?item wdt:P31/wdt:P279* wd:Q17537576.
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!