User:Beat Estermann/WD-Intro-2020-08-25

Useful Links edit

Useful Gadgets edit

To activate the gadgets, go to the "Gadget" tab in your preferences and tick the corresponding checkbox.

  • Gadget "relateditems:" Adds a button to the bottom of item pages to display inverse statements.
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.
  • Gadget "Recoin" ("Relative Completeness Indicator") is a script that extends Wikidata entity pages with information about the relative completeness of the information and provides suggestions for further information to be added to an item.
  • There are further Gadgets that facilitate particular tasks when working on Wikidata - check them out!

Tools for (Semi-)Automatic Data Ingests edit

Sum of All GLAMs / Referencing Archival Fonds on Wikidata / Graph-based Query Expansion in Library Discovery Systems edit

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

Return all books written by J. K. Rowling edit

  • The relevant items and properties are: J. K. Rowling (Q34660), author (P50)
SELECT ?book ?bookLabel
WHERE {
  ?book wdt:P50 wd:Q34660 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

What other information is available about J. K. Rowling books? edit

  • Relevant properties are: publisher(P123), publication Date(P577), award received (P166)
SELECT ?book ?bookLabel ?publisherLabel ?publicationDate ?awardsLabel
WHERE {
  ?book wdt:P50 wd:Q34660 .
  ?book wdt:P123 ?publisher;
        wdt:P577 ?publicationDate;
        wdt:P166 ?awards .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }              
}
Try it!

What happened to the other books? edit

  • The Optional function is needed so that all entries are kept.
SELECT ?book ?bookLabel ?publisherLabel ?publicationDate ?awardsLabel
WHERE {
  ?book wdt:P50 wd:Q34660 .
  OPTIONAL {?book wdt:P123 ?publisher .}
  OPTIONAL {?book wdt:P577 ?publicationDate .}
  OPTIONAL {?book wdt:P166 ?awards .}

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }              
}
Try it!

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

Searching & Editing Wikidata edit

Complement information about organizations edit

Search for an organization from the Bern University Library dataset of corporate archives and use "Recoin" (see "Useful Gadgets") to complement the information:

  1. Sanitätsgeschäft M. Schaerer A.G.
  2. Universität Bern, Theodor-Kocher-Institut; Theodor-Kocher-Institut → Theodor Kocher Institute (Q98635935)
  3. Union Schweizerischer Gesellschaften für experimentelle Biolog; Life Sciences Switzerland → Life Sciences Switzerland (Q13416886)
  4. Schweizerische Gesellschaft für Medizinische Radiologie
  5. Schweiz. Verein für Physiologie, Physiolog. Chemie und Pharmak; Freie Vereinigung schweizerischer Physiologen (1932); Schweiz. Verein der Physiologen und Pharmakologen (1944-55) → Schweizerischer Verein für Physiologie, Physiologie Chemie und Pharmakologie (Q98635715)
  6. Ärztlicher Bezirksverein Emmental
  7. Ärztlicher Bezirksverein Oberaargau
  8. Schweizerische Gesellschaft für Biochemie → Swiss Society for Biochemistry (Q98635570)
  9. Institut Für Sozial- und Präventivmedizin der Uni Bern → Institute of Social and Preventive Medicine (Q98635443)
  10. Schweizerische Gesellschaft für Oto-Rhino-Laryngologie → Swiss Society for Oto-Rhino-Laryngology (Q98635727)
  11. Schweizerische Akademie der Medizinischen Wissenschaften → Swiss Academy of Medical Sciences (Q1287710)
  12. Schweizerische Gesellschaft für Chirurgie → Q98635675
  13. Bernische Radium-Stiftung
  14. Schweizerische Gesellschaft für Allgemeine Medizin → Swiss Society of General Medicine (Q98635549)
  15. International Society for Stereology → International Society for Stereology & Image Analysis (Q48796537) (with "archives at" statement)
  16. Pharmacie St. Martin Vevey → Pharmacie St. Martin (Q98635459) (with "archives at" statement)

Hint:

Querying & Editing Wikidata edit

Branches of the Bern University Library edit

Write a query that returns all branches of the Bern University Library.

SELECT ?item ?itemLabel 
WHERE 
{
  ?item wdt:P361 wd:Q15852122.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
Try it!

Hints:

  • Include the image (P18), inception (P571), street address (P6375), location (P276), coordinate location (P625), phone number (P1329), email address (P968), official website (P856), heritage designation (P1435), part of (P361), has part (P527), etc.
  • Try displaying them on a map.
  • Try changing the language to French or English to see which items are missing labels in these languages.

Branches of the Bern University Library without a “street address” statement edit

The example query below outputs all the Swiss museums without a street address (P6375) statement. Take it as a starting point to create a query that outputs all the branches of the Bern University Library without a street address (P6375) statement. Find the missing information for some of the entries on the Internet and add it to Wikidata.

SELECT DISTINCT ?item ?itemLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q33506; # museum
        wdt:P17 wd:Q39.
  MINUS { ?item wdt:P6375 [] }   # exclude if there is a "street address" statement
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr". }
}
Try it!

Hint:

  • 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 library branches 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!

Items about branches of the Bern University Library with statements that are not properly sourced edit

Use the query below to identify items about branches of the Bern University Library with statements that are not properly sourced. Search for an appropriate reference on the Internet and add it to the statement in question.

SSELECT ?item ?itemLabel ?property ?propertyLabel ?statement
WITH {
  SELECT DISTINCT ?item WHERE {
    ?item wdt:P361 wd:Q15852122.
  }
} AS %items
WITH {
  SELECT ?item ?itemLabel WHERE {
    INCLUDE %items.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de,fr,it,en". }
  }
} AS %itemLabels
WITH {
  SELECT ?item ?property ?statement WHERE {
    INCLUDE %items.
    ?property wikibase:claim ?p.
    ?item ?p ?statement.
    MINUS {
      # TODO check what counts as good reference
      ?statement prov:wasDerivedFrom [
        pr:P248|pr:P854 ?goodReference
      ].
    }
    # TODO expand list of properties that don’t need good references:
    FILTER(?p NOT IN (p:P373,  #commons category
                      p:P856,  #official website
                      p:P18,   #image
                      p:P227,   #identifier with weblink
                      p:P214,   #identifier with weblink
                      p:P269,   #identifier with weblink
                      p:P2427,  #identifier with weblink
                      p:P213,   #identifier with weblink
                      p:P4678,  #identifier with weblink
                      p:P3153,  #identifier with weblink
                      p:P902    #identifier with weblink
                      ))  
  }
} AS %statements
WITH {
  SELECT DISTINCT ?property WHERE {
    INCLUDE %statements.
  }
} AS %properties
WITH {
  SELECT ?property ?propertyLabel WHERE {
    INCLUDE %properties.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de,fr,it,en". }
  }
} AS %propertyLabels
WHERE {
  INCLUDE %statements.
  INCLUDE %itemLabels.
  INCLUDE %propertyLabels.
}

ORDER BY ?item
Try it!

Querying Wikidata & Editing Wikipedia edit

The following query may be used in an upcoming Wikipedia editathon organized by the ETH Library. It outputs items for people with archives at the ETH Zurich University Archives, but without a Wikipedia article in German:

SELECT DISTINCT ?person ?personLabel ?personDescription ?occupation
  WHERE {
  ?person wdt:P485 wd:Q39934978 .  
  MINUS { ?sitelink schema:isPartOf <https://de.wikipedia.org/> ;
     schema:about ?person . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de" }
}
Try it!

Exercises:

  • Adapt the query to output people without an article in English Wikipedia.
  • Adapt the query to output people with archives at the Bern University Library.

Hint:

Exploring Ontologies & Editing Wikidata edit

Typology of heritage institutions edit

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

(Semi-)Automatic Reconciliation edit

See dataset of person archives after reconciliation with OpenRefine.