Wikipedia:WikiMUC/Federated Queries Workshop/Documentation
Day 1 Part A
Intro by Lucas QLever OSM: https://wiki.openstreetmap.org/wiki/QLever
Presentation 1: Katharina Brunner Remove NA:
Project from the Queer Archive in Munich
- A web ui for diffing the content between FactGrid and Wikidata
- https://apps.katharinabrunner.de/companions/
- New Project: https://prototypefund.de/project/queersearch/
- Federated queries were hard to see real examples of
- They were very accademic or formal
- Or very simple
- There is no tutorial
- Q: for people without experience, what would be a good tutorial or learning materials for where to start?
- - a good tutorial woul dbe the best. One that starts with the very intro/simple stuff, to make it accesible, and then build it up
- Q: Did you find other people with similar queer data? Did you find a community?
- I followed wikidata LGBT community datamodels someone [please add name] seems to have done most of the modelling
- Community at the queer archives (outside wiki community)
- Often professional digital archivers
- Q: full dataset on Factgrid and then some of it on Wikidata. How do you decide what goes in WD?
- One of the datasets was paosters/books from the queer archive in munich
- We don't need all of this wikidata
- certain publishing houses are still publishing but since 1890s
- It's good to be able to label items about these publishing houses to say they are publishing queer books
- One of the datasets was paosters/books from the queer archive in munich
Presentation 2: Maria Hinzmann and Julia Röttgermann Bidirectional Federated Queries on MiMoTextBase and Wikidata
-> Federation is at the core of Linked Open Data
- Work about the French Enilghtenment
- transferable to other disciplines/domains
- Atomisation of lirary history
- Break it down
- Higher density of asertions for this narrow domain.
- some data were meant for Wikidata too, but not everything.
- they wanted to avoid redundancies
- solution, to link
- https://mimotext.uni-trier.de/
- https://data.mimotext.uni-trier.de/wiki/Main_Page
- Interview discussing the project: https://tech-news.wikimedia.de/2024/06/28/modeling-the-enlightenment-novel-an-interview-with-the-mimotext-team/
- Video explainer of the project and how it uses federated queries: https://commons.m.wikimedia.org/wiki/File:Mining_and_Modeling_Text_at_Trier_University.webm
- Connections between wikibases for federation represented with an External Mimotext ID on wikidata and
a URL "exact match" property on The Mimootext db
- Examples of Uses
- Querying from Mimotext
- Linking geographic information from Wikidata with inforation about narrative themes / locations from Mimotext
- Finding alternative Name of Authors. Taking all the various alternative names from Wikidata and not then maintaing all these alternative names on Mimotext
- Using 3 endpoints:
- Starting on Mimotext, query BNF (french national library) identifiers from Wikidata and then query for information from SPARQL endpoint of BNF
- Here are some query examples (MiMoText -> Wikidata)
- Narrative locations of novels (map): "travel"%20https://query.mimotext.uni-trier.de/#%23title%3ANarrative%20Location%20of%20novels%20about%20%22travel%22%0A%23defaultView%3AMap%7B%22hide%22%3A%20%5B%22%3Fnar_loc%22%2C%20%22%3Ftopic%22%5D%2C%20%22layer%22%3A%20%22%3FthemeLabel%22%7D%0APREFIX%20mmd%3A%3Chttp%3A%2F%2Fdata.mimotext.uni-trier.de%2Fentity%2F%3E%20%23mimotext%20entity%0APREFIX%20mmdt%3A%3Chttp%3A%2F%2Fdata.mimotext.uni-trier.de%2Fprop%2Fdirect%2F%3E%20%23mimotext%20property%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%23wikidata%20entity%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%20%23wikidata%20property%0A%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3FnarrLoc%20%3FnarrLocLabel%20%3FwikidataEntityLink%20%3FcoordinateLocation%20%3Ftheme%20%3FthemeLabel%20WHERE%20%7B%0A%20%20%3Fitem%20mmdt%3AP36%20mmd%3AQ3126.%20%20%23%20work%20item%20is%20about%20travel%0A%20%20%3Fitem%20mmdt%3AP36%20%3Ftheme.%20%20%20%20%23%20work%20is%20about%20themes%0A%20%20%3Fitem%20mmdt%3AP32%20%3FnarrLoc.%20%20%23%20work%20has%20narrative%20location%0A%20%20%3FnarrLoc%20mmdt%3AP13%20%3FWikiLink.%20%20%23%20narrative%20location%20has%20exact%20match%20with%20Wikidata%20ID%0A%20%20%23Federated%20Query%20-%3E%20Wikidata%0A%20%20SERVICE%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%20%7B%0A%20%20%20%20%3FWikiLink%20wdt%3AP625%20%3FcoordinateLocation%20.%0A%20%20%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%0A%20%20%7D%0A%7D%0A see link
- Authors by birth year, with portrait see link
- Alternative author names from Wikidata infobox see link
- Network of influences between authors (using ‘influenced by’)see link
*Querying from Wikidata (l)
- Narrative forms
- Property: literary forms. Not available in WD, but in MM
- Controlled vocabulary exists on wikidata? So we match the raw strings from Mimotext to the controlled vocal there? [ask for clarification]
- LINK _ to example Query:
- https://www.wikidata.org/w/index.php?title=Property:P12047&diff=prev&oldid=2283719036
- Some more Example Queries: Wikidata -> MiMoTextBase
- Narrative forms of French Enlightenment novels in five-year periods (string) https://w.wiki/CHxr
- Narrative forms of French Enlightenment novels in five-year periods (controlled vocabulary) https://w.wiki/CHxi
- Overview of French Enlightenment novels with MiMoText ID (fulltext, BGRF, place, date) https://w.wiki/AFyj
- Themes of French Enlightenment novels with MiMoText ID as BubbleChart https://w.wiki/CJgU
- Tones of French Enlightenment novels https://w.wiki/CJgc
- Possible Questions:
- Controlled vocabulary exists on wikidata? So we match the raw strings from Mimotext to the controlled vocal there? [ask for clarification] this was to try and fill in the notes from above :P
- First matched Raw strings w controlled vocabulary then items in Mimotext matched with the items in Wikidata
- Questions:
- How did you decide what to contribute back to Wikidata or not?
- There is a slide (8.4). Only novels that had semantic narrative locations from more than one source with at least 3 statements. This was about 800 of 1800 novels.
- Were you running your own OpenRefine Reconcilliation service and if how did you find doing that?
- Initailly we used a bot for the bigger dataset. We also used quickstatements - it was a good experience
- OR from MimoText?
- no , the OR reconciliation service as it is
- How did you decide what to contribute back to Wikidata or not?
Presentation 3: Lozana Rossanova NFDI4Culture use-cases for Data Enrichment and Federation with Wikibase4Research
- slides - https://docs.google.com/presentation/d/1PwuPYlvj-ZjTG_RqClsqneaK-htUQF5ff_fdqJbvZ7E/edit?usp=sharing
Wikibase - with additional extensions and tools
Open Science Lab (within TIB Hannover)
Wikibase that contains real and digital representations of real items Federation is useful so we don't need to hold the information on the real objects but we do want to hold information on the 3d digital representations
Usecases Find 3 models of things within a certain geographic area using the locations of the real objects from Wikidata
3-way federated queries: WD Factgrid and instance Use Wikidata to get FactGrid Ids
- Federation not only with WD (or other WBinstances)
QLever of DBLP: https://sparql.dblp.org/
Questions:
- Did you start with pain points and Wikibase was the solution for this?
- The idea of having Wikis is older,there were citizen science projects w\using WD
- When started, needed to use Kompakt. Kompakt doesn't have a database
- Did you start with pain points and Wikibase was the solution for this?
Presenation 4: Hannah Bast Federated Queries with QLever
Qlever https://qlever.cs.uni-freiburg.de/wikidata
First query: all films on Wikidata along with their IMDb rating https://qlever.cs.uni-freiburg.de/wikidata/hIX2ee
quering simultaneously imdb, to have imdb ratings together with the information from WD https://qlever.cs.uni-freiburg.de/wikidata
Second query: The same, but only for films by Quentin Tarantino: https://qlever.cs.uni-freiburg.de/wikidata/cwNuCF Third query: The power network of the EU: https://qlever.cs.uni-freiburg.de/osm-planet/aXwfk5 Fourth query: All buildings in Germany near a train or subway station: https://qlever.cs.uni-freiburg.de/osm-planet/jKxS2A
Questions:
- How are the differnt OSM-Taggings represented as triplets
- Are the differences in the SPARQL dialect? E.g with the label service?
Presentation 5: Max Kristen DeJongeWiki and WikiFAIR
Problem: Running Wikibase in restitive university environment Painpoint: Java
Blazegraph was a problem very early on Doesn't support QueryService at the moment
Wiki: https://set.kuleuven.be/rlicc/dejongewiki/w/index.php/Main_Page Example Room: https://set.kuleuven.be/rlicc/dejongewiki/w/index.php/AC_MC_GW_1F_01.01 Wikibase of Example Room: https://set.kuleuven.be/rlicc/dejongewiki/w/index.php/Item:Q46
Shown Extensions:
https://www.mediawiki.org/wiki/Extension:LinkedWiki https://www.mediawiki.org/wiki/Extension:UnlinkedWikibase
WikiFAIR: https://meta.wikimedia.org/wiki/WikiFAIR
Day 1 Part B
Example queries (even from people that can't attend!):
- kg.kunsten.be > https://kg.kunsten.be/wiki/Datamodel#Federated_queries (ask for some extra info tom@kunsten.be
- I would like to develop some federated queries between kg.kunsten.be and https://vlaamstheaterinstituut.wikibase.cloud/ but the domains are not whitelisted...
- Resistance in Belgium + Wikidata > https://data.arch.be/wiki/In-depth_search (see the last example at the bottom of the page)
- From Mimotext: https://www.wikidata.org/w/index.php?title=Property:P12047&diff=prev&oldid=2283719036
- https://mimotext.github.io/lod-lithist/bidirectional-federation.html
- most common themes on MiMoText by male (https://w.wiki/CJnk) and female (https://w.wiki/CJnm) authors
- QLever federated query that combines Wikidata and Structured Data on Commons to find all images depicting any hummingbird species: https://qlever.cs.uni-freiburg.de/wikimedia-commons/RcZENT
- The queries below are from the Luxembourg private Wikidata instance 'LUDAP' that holds an authority file on persons and other modalities. These queries are used to create links to Wikidata, Use Wikidata to retrieve other potential external IDs, and to use the link between Wikidata to query other third party endpoints for further data analysis before adopting an external identifier. Contact: info@ip-squared.com
- Get Wikidata ID if some other matching ID exists
PREFIX LUDAP: <redacted/entity/>
PREFIX LUDAPt: <redacted/prop/direct/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?person ?personName ?WDitem WHERE {
?person LUDAPt:P1 LUDAP:Q17 . # instance of a person
?person LUDAPt:P9 ?personName.
?person LUDAPt:P41 ?GETTY. # Getty identifier
FILTER NOT EXISTS { ?person LUDAPt:P70 ?WikidataID } . # No Wikidata ID
SERVICE <https://query.wikidata.org/sparql> {
?WDitem wdt:P245 ?GETTY .
}
} ORDER BY ?personName
### Get other ID if Wikidata qid exists
SELECT ?person ?personName ?WDitem ?WDName ?ISNI_link WHERE {
?person LUDAPt:P1 LUDAP:Q17 . # instance of a person
?person LUDAPt:P9 ?personName.
?person LUDAPt:P70 ?WikidataID. #WikidataID existsn
FILTER NOT EXISTS { ?person LUDAPt:P37 ?ISNI } . # ISNI does not exists
BIND(IRI(CONCAT("http://www.wikidata.org/entity/", ?WikidataID )) AS ?WDitem ). #Construct IRI for Wikidata
SERVICE <https://query.wikidata.org/sparql> {
?WDitem wdt:P213 ?WDISNI ;
rdfs:label ?WDName .
FILTER (langMatches( lang(?WDName), "FR" ) ) # Get French label
}
BIND (URI(CONCAT("https://isni.org/isni/",?WDISNI)) AS ?ISNI_link) #Present full ISNI ID for testing purposes.
} ORDER BY ?personName
### Data validation on Wikidata
SELECT ?person ?personName ?VIAF ?WDitem ?WDVIAF ?VIAF_link WHERE {
?person LUDAPt:P1 LUDAP:Q17 . # instance of a person
?person LUDAPt:P9 ?personName.
?person LUDAPt:P70 ?WikidataID. # get local Wikidata QID
?person LUDAPt:P38 ?VIAF. # get local VIAF
BIND(IRI(CONCAT("http://www.wikidata.org/entity/", ?WikidataID )) AS ?WDitem ) . #Construct IRI for Wikidata
SERVICE <https://query.wikidata.org/sparql> {
?WDitem wdt:P214 ?WDVIAF . #Get VIAF from Wikidata
}
BIND (URI(CONCAT("https://viaf.org/viaf/",?WDVIAF)) AS ?VIAF_link)
FILTER (?WDVIAF != ?VIAF) #only show when local and Wikidata VIAF are NOT the same
} ORDER BY ?personName
### Double federated queries to retrieve GND info based on Wikidata ID
PREFIX gndo:<https://d-nb.info/standards/elementset/gnd#>
SELECT DISTINCT ?person ?personName ?WDGND ?GNDName ?dateBirth ?GNDBirth ?dateDeath ?GNDDeath WHERE {
?person LUDAPt:P1 LUDAP:Q17; #instance of person
LUDAPt:P9 ?personName;
LUDAPt:P70 ?WikidataID;
LUDAPt:P19 ?dateBirthRAW.
FILTER((DATATYPE(?dateBirthRAW)) = xsd:dateTime) # filter out EDTF dates
BIND(SUBSTR(STR(?dateBirthRAW), 0 , 11 ) AS ?dateBirth) # Convert datetime for ease of matching.
?person LUDAPt:P21 ?dateDeathRAW.
FILTER((DATATYPE(?dateDeathRAW)) = xsd:dateTime) # filter out EDTF dates
BIND(SUBSTR(STR(?dateDeathRAW), 0 , 11 ) AS ?dateDeath) # Convert datetime for ease of matching.
FILTER(NOT EXISTS { ?person LUDAPt:P39 ?GND. }) # No GND should exists
BIND(IRI(CONCAT("http://www.wikidata.org/entity/", ?WikidataID)) AS ?WDitem) # Create Wikidata IRI
SERVICE <https://query.wikidata.org/sparql> {
?WDitem wdt:P227 ?WDGND. # Retrieve GND from WIkidata
}
SERVICE <http://zbw.eu/beta/sparql/gnd/query> {
?gndPerson gndo:gndIdentifier ?WDGND; # Use Wikidata GND identifier to retrieve further information from GND for mathching purposes.
gndo:preferredNameForThePerson ?GNDName;
gndo:dateOfBirth ?GNDBirth;
gndo:dateOfDeath ?GNDDeath.
}
}
ORDER BY (?personName)
- https://www.mediawiki.org/w/index.php?title=Wikibase%2FFederation&diff=6854348&oldid=6819578
- https://w.wiki/C9p9 This is looking up what texts of Ancient Roman politicians contain most often the word "war" (bellum). It federates with https://lila-erc.eu
- Federation via dblp that has some questions (possibly for Hannah) - https://sparql.dblp.org/YKIrP3 - issue there is how to use IRIs of external IDs properly (to avoid the limitatinos fo literals used for IDs), when BIND(IRI...) is not working.
- Interestingly BIND(IRI...) method working pretty well in Qlever - https://qlever.cs.uni-freiburg.de/wikidata/BZEBw2
- same query from Manor Houses WB service: https://query.wb.manorhouses.tibwiki.io/#PREFIX%20tibt%3A%20%3Chttps%3A%2F%2Fwb.manorhouses.tibwiki.io%2Fprop%2Fdirect%2F%3E%0APREFIX%20tib%3A%20%3Chttps%3A%2F%2Fwb.manorhouses.tibwiki.io%2Fentity%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wdqs%3A%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%20%20%0APREFIX%20fg%3A%20%3Chttps%3A%2F%2Fdatabase.factgrid.de%2Fentity%2F%3E%0APREFIX%20fgt%3A%20%3Chttps%3A%2F%2Fdatabase.factgrid.de%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20Distinct%20%3Fperson%20%3FpersonLabel%20%3FFactgrid_id%20%3Fbirth_date%0AWHERE%7B%0A%3Fperson%20tibt%3AP1%20tib%3AQ5.%0A%3Fperson%20tibt%3AP104%20%3FWikidata_id.%0A%0ASERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%0ABIND%28IRI%28CONCAT%28STR%28wd%3A%29%2C%20%3FWikidata_id%29%29%20AS%20%3FWikidata_item%29%0A%0ASERVICE%20wdqs%3A%20%7B%0A%20%20%3FWikidata_item%20wdt%3AP8168%20%3FFactgrid_id.%0A%7D%0A%0ABIND%28IRI%28CONCAT%28STR%28fg%3A%29%2C%20%3FFactgrid_id%29%29%20AS%20%3FFactgrid_item%29%0A%0ASERVICE%20%3Chttps%3A%2F%2Fdatabase.factgrid.de%2Fsparql%3E%20%7B%0A%20%20%3FFactgrid_item%20fgt%3AP77%20%3Fbirth_date.%0A%7D%0A%20%20%0A%7D%0AOrder%20by%20%3FpersonLabel%0ALimit%20100
- Examples from Rhizome:
- Artists in the ArtBase, who are also listed in Wikidata (includes images from both databases) - https://query.artbase.rhizome.org/#%23defaultView%3AImageGrid%0A%23%20Images%20of%20artists%2C%20from%20either%20ArtBase%20or%20Wikibase%0ASELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20%3Fwikidata_item%20%3Fimage_artbase%20%3Fimage_wikidata%20WHERE%20%7B%0A%20%20%3Fperson%20rt%3AP3%20r%3AQ6%3B%0A%20%20%20%20rt%3AP2%20%3Fwikidata_item.%0A%20%20OPTIONAL%20%7B%20%3Fperson%20rt%3AP126%20%3Fimage_artbase.%20%7D%0A%20%20SERVICE%20wdqs%3A%20%7B%0A%20%20%20%20%3Fwikidata_item%20rdfs%3Alabel%20%3FpersonLabel.%0A%20%20%20%20OPTIONAL%20%7B%20%3Fwikidata_item%20wdt%3AP18%20%3Fimage_wikidata.%20%7D%0A%20%20%20%20FILTER%28%28LANG%28%3FpersonLabel%29%29%20%3D%20%22en%22%29%0A%20%20%7D%0A%7D
- Education data for artists in the ArtBase, pulled from Wikidata - https://query.artbase.rhizome.org/#%23%20WHERE%20OUR%20ARTISTS%20WENT%20TO%20SCHOOL%0A%0ASELECT%20DISTINCT%20%3Fperson%20%3Fremote_item%20%3Fperson_label%20%3Feducated_at_label%20WHERE%20%7B%20%20%0A%20%20%3Fperson%20rt%3AP3%20r%3AQ6%20%3B%20%23%20instance%20of%20%28P3%29%20person%20%28Q6%29%0A%20%20%20%20%20%20%20%20%20%20rt%3AP2%20%3Fremote_item%20%3B%20%23%20exact%20match%20with%20external%20URL%0A%20%20%20%20%20%20%20%20%20%20rdfs%3Alabel%20%3Fperson_label%20%3B%0A%20%20%20%20%20%20%20%20%20%20rt%3AP135%20%3Fsort_key%20.%0A%20%20FILTER%20%28%20STRSTARTS%28STR%28%3Fremote_item%29%2C%20%27http%3A%2F%2Fwww.wikidata.org%27%29%20%29%0A%20%20%0A%20%20SERVICE%20wdqs%3A%20%7B%20%20%20%20%20%20%0A%20%20%20%20%3Fremote_item%20wdt%3AP69%20%3Feducated_at%20.%0A%20%20%20%20%3Feducated_at%20rdfs%3Alabel%20%3Feducated_at_label%20.%20%20%0A%20%20%20%20FILTER%20%28lang%28%3Feducated_at_label%29%20%3D%20%22en%22%29%0A%20%20%7D%0A%7D%0AORDER%20BY%20%3Fsort_key
Person from Factgrid, that has any connection to a person or organisation in Wikidata and DBPedia :
- https://apps.katharinabrunner.de/companions/
- https://database.factgrid.de/query/index.html#%23defaultView%3AImageGrid%0A%23%20Prefix%20standard%20%0A%23%20Factgrid%0APREFIX%20fg%3A%20%3Chttps%3A%2F%2Fdatabase.factgrid.de%2Fentity%2F%3E%0APREFIX%20fgt%3A%20%3Chttps%3A%2F%2Fdatabase.factgrid.de%2Fprop%2Fdirect%2F%3E%0A%23%20DBpedia%0APREFIX%20dbo%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%20%0APREFIX%20dbr%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%20%0A%23%20Wikidata%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdp%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2F%3E%0APREFIX%20wps%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20wdpsv%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fstatement%2Fvalue%2F%3E%0A%23%20misc%0APREFIX%20owl%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23%3E%0APREFIX%20dct%3A%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20bd%3A%20%3Chttp%3A%2F%2Fwww.bigdata.com%2Frdf%23%3E%0APREFIX%20schema%3A%20%3Chttp%3A%2F%2Fschema.org%2F%3E%0Aprefix%20foaf%3A%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%20%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0ASELECT%20DISTINCT%20%0A%23%20all%20data%0A%3Ffg_item%20%3Ffg_itemLabel%20%3Fwd_item%20%3Fdb_item%20%3Fvalue%20%3FvalueLabel%20%3Frelation%20%3Frelation_stringLabel%20%3Fimage%20%3Fsource%0A%23%20more%20distinct%0A%23%20%3Ffg_item%20%3FvalueLabel%20%3Fimage%20%3Fsortname%0AWHERE%20%7B%0A%0A%20%20%23%20labels%20from%20Factgrid%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%0A%20%20%23%20starting%20point%20is%20a%20factgrid%20item%0A%20%20BIND%28fg%3AQ225307%20as%20%3Ffg_item%29%0A%20%20%23%20transform%20wikidata%20qid%20in%20factgrid%20to%20wikidata%20entity%20iri%0A%20%20%3Flink%20schema%3Aabout%20%3Ffg_item%20.%0A%20%20%3Flink%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fwww.wikidata.org%2F%3E%20.%20%0A%20%20%3Flink%20schema%3Aname%20%3Fqid.%0A%20%20BIND%28IRI%28CONCAT%28STR%28wd%3A%29%2C%20%3Fqid%29%29%20AS%20%3Fwd_item%29%0A%0A%20%20%23%20FACTGRID%3A%20Get%20relations%20with%20all%20humans%20and%20organisations%0A%20%20%7B%0A%20%20%20%20%23%20get%20all%20statments%20to%20a%20PERSON%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%3Ffg_item%20%3Frelation%20%3Fvalue%20.%0A%20%20%20%20%20%20%3Fvalue%20fgt%3AP2%20fg%3AQ7%20.%0A%20%20%20%20%20%20%3Frelation_string%20wikibase%3AdirectClaim%20%3Frelation.%0A%20%20%20%20%20%20BIND%20%28%22factgrid%22%20AS%20%3Fsource%29%0A%20%20%20%20%20%20OPTIONAL%20%7B%20%3Fvalue%20fgt%3AP189%20%3Fimage%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%7D%0A%0A%20%20%23%20WIKIDATA%3A%20Get%20relations%20with%20all%20humans%20and%20organisations%0A%20%20UNION%20%7B%0A%20%20%20%20%23%20Wikidata%3A%20get%20all%20statments%20to%20a%20PERSON%0A%20%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20SERVICE%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%20%7B%0A%20%20%20%20%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cmul%2Cen%22.%0A%20%20%20%20%20%20%20%20%20%20%3Fwd_item%20rdfs%3Alabel%20%3Fwd_itemLabel.%0A%20%20%20%20%20%20%20%20%20%20%3Fvalue%20rdfs%3Alabel%20%3FvalueLabel.%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%3Fwd_item%20%3Frelation%20%3Fvalue%20.%0A%20%20%20%20%20%20%20%20%23%20%3Fwd_item%20rdfs%3Alabel%20%3Fwd_itemLabel.%0A%20%20%20%20%20%20%20%20%3Fvalue%20wdt%3AP31%20wd%3AQ5%20.%0A%20%20%20%20%20%20%20%20%23%20%3Fvalue%20rdfs%3Alabel%20%3FvalueLabel.%0A%20%20%20%20%20%20%20%20%23%20FILTER%28LANG%28%3FvalueLabel%29%20%3D%20%22%5BAUTO_LANGUAGE%5D%22%29%20.%0A%20%20%20%20%20%20%20%20%23%20FILTER%28LANG%28%3Fwd_itemLabel%29%20%3D%20%22%5BAUTO_LANGUAGE%5D%22%29%20.%0A%20%20%20%20%20%20%20%20%23%3Frelation_string%20wikibase%3AdirectClaim%20%3Frelation.%0A%20%20%20%20%20%20%20%20BIND%20%28%22wikidata%22%20AS%20%3Fsource%29%0A%20%20%20%20%20%20%20%20OPTIONAL%20%7B%20%3Fvalue%20wdt%3AP18%20%3Fimage%20%7D%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20%23%20WIKIPEDIA%3A%20Persons%20mentioned%20in%20Wikipedia%20article%20%0A%20%20UNION%20%7B%0A%20%20%20%20%23%20fetch%20data%20from%20DBpedia%0A%20%20%20%20SERVICE%20%3Chttps%3A%2F%2Fdbpedia.org%2Fsparql%3E%20%7B%0A%20%20%20%20%20%20%23%20get%20Wikidata%20QID%20from%20DBPedia%20resource%0A%20%20%20%20%20%20%3Fdb_item%20owl%3AsameAs%20%3Fwd_item%20.%0A%0A%20%20%20%20%20%20OPTIONAL%20%7B%20%0A%20%20%20%20%20%20%20%20%23%20get%20all%20wikipedia%20links%0A%20%20%20%20%20%20%20%20%3Fdb_item%20dbo%3AwikiPageWikiLink%20%3Fvalue%20.%0A%20%20%20%20%20%20%20%20%23%20just%20those%20that%20are%20persons%0A%20%20%20%20%20%20%20%20%3Fvalue%20a%20dbo%3APerson%20.%0A%20%20%20%20%20%20%20%20%3Fvalue%20rdfs%3Alabel%20%3FvalueLabel%20.%0A%20%20%20%20%20%20%20%20FILTER%28LANG%28%3FvalueLabel%29%20%3D%20%22%5BAUTO_LANGUAGE%5D%22%29%20.%0A%20%20%20%20%20%20%20%20%23%20remove%20Stefan%20Zweig%2C%20because%20there%20is%20some%20data%20fuckup%20within%20that%20resource%20%28I%20informed%20DBpedia%29%0A%20%20%20%20%20%20%20%20MINUS%20%7BFILTER%28REGEX%28STR%28%3Fvalue%29%2C%20%22Stefan_Zweig%7CLGBT_rights_by_country_or_territory%7CBarbara%20Hammer%7CDeutschland%7CComing_out%22%29%29%7D%0A%20%20%20%20%20%20%20%20%23%20also%20get%20their%20wikidata%20qids%0A%20%20%20%20%20%20%20%20%23%3Fvalue%20owl%3AsameAs%20%3Fdb_wikilink_wd_item%20FILTER%28regex%28str%28%3Fdb_wikilink_wd_item%29%2C%20%22wikidata%22%20%29%29%0A%20%20%20%20%20%20%20%20%23%20get%20image%0A%20%20%20%20%20%20%20%20OPTIONAL%20%7B%20%3Fvalue%20dbo%3Athumbnail%20%3Fimage%20%7D%0A%0A%20%20%20%20%20%20%20%20BIND%20%28%22wikipedia%22%20AS%20%3Fsource%29%0A%20%20%20%20%20%20%20%20BIND%20%28%22mentioned_in_wikipedia%22%20AS%20%3Frelation_stringLabel%29%0A%20%20%20%20%20%20%20%20BIND%20%28dbo%3AwikiPageWikiLink%20AS%20%3Frelation%29%0A%20%20%20%20%20%20%20%20%23BIND%20%28wdt%3AP452%20AS%20%3Frelation%29%0A%0A%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%7D%0A%20%20%20%20%23%20WIKIPEDIA%3A%20Get%20Persons%20from%20DBPedia%0A%20%20%7D%20UNION%20%7B%0A%20%20%20%20%23%20fetch%20data%20from%20DBpedia%0A%20%20%20%20SERVICE%20%3Chttps%3A%2F%2Fdbpedia.org%2Fsparql%3E%20%7B%0A%20%20%20%20%20%20%23%20get%20Wikidata%20QID%20from%20DBPedia%20resource%0A%20%20%20%20%20%20%3Fdb_item%20owl%3AsameAs%20%3Fwd_item%20.%0A%20%20%20%20%20%20%3Fwd_item%20%3Frelation%20%3Fvalue%20.%0A%20%20%20%20%20%20%3Fvalue%20a%20dbo%3APerson%20.%0A%20%20%20%20%20%20%3Fvalue%20rdfs%3Alabel%20%3FvalueLabel%20.%0A%20%20%20%20%20%20FILTER%28LANG%28%3FvalueLabel%29%20%3D%20%22%5BAUTO_LANGUAGE%5D%22%29%20.%0A%20%20%20%20%20%20%23%20remove%20Stefan%20Zweig%2C%20because%20there%20is%20some%20data%20fuckup%20within%20that%20resource%20%28I%20informed%20DBpedia%29%0A%20%20%20%20%20%20MINUS%20%7BFILTER%28REGEX%28STR%28%3Fvalue%29%2C%20%22Stefan_Zweig%7CLGBT_rights_by_country_or_territory%7CBarbara%20Hammer%7CDeutschland%7CComing_out%22%29%29%7D%0A%20%20%20%20%20%20BIND%20%28%22dbpedia%22%20AS%20%3Fsource%29%0A%20%20%20%20%20%20OPTIONAL%20%7B%20%3Fvalue%20dbo%3Athumbnail%20%3Fimage%20%7D%0A%0A%20%20%20%20%7D%0A%20%20%20%20%23%20WIKIPEDIA%3A%20Get%20Organisation%20from%20DBPedia%0A%20%20%7D%20UNION%20%7B%0A%20%20%20%20%23%20fetch%20data%20from%20DBpedia%0A%20%20%20%20SERVICE%20%3Chttps%3A%2F%2Fdbpedia.org%2Fsparql%3E%20%7B%0A%20%20%20%20%20%20%23%20get%20Wikidata%20QID%20from%20DBPedia%20resource%0A%20%20%20%20%20%20%3Fdb_item%20owl%3AsameAs%20%3Fwd_item%20.%0A%20%20%20%20%20%20%3Fwd_item%20%3Frelation%20%3Fvalue%20.%0A%20%20%20%20%20%20%3Fvalue%20a%20dbo%3AOrganisation%20.%0A%20%20%20%20%20%20%3Fvalue%20rdfs%3Alabel%20%3FvalueLabel%20.%0A%20%20%20%20%20%20FILTER%28LANG%28%3FvalueLabel%29%20%3D%20%22%5BAUTO_LANGUAGE%5D%22%29%20.%0A%20%20%20%20%20%20%23%20remove%20Stefan%20Zweig%2C%20because%20there%20is%20some%20data%20fuckup%20within%20that%20resource%20%28I%20informed%20DBpedia%29%0A%20%20%20%20%20%20MINUS%20%7BFILTER%28REGEX%28STR%28%3Fvalue%29%2C%20%22Stefan_Zweig%7CLGBT_rights_by_country_or_territory%7CBarbara%20Hammer%7CDeutschland%7CComing_out%22%29%29%7D%0A%20%20%20%20%20%20BIND%20%28%22dbpedia%22%20AS%20%3Fsource%29%0A%20%20%20%20%20%20OPTIONAL%20%7B%20%3Fvalue%20dbo%3Athumbnail%20%3Fimage%20%7D%0A%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A
Documentation of the second part of Day 1:
- formatter URI for RDF resource (https://www.wikidata.org/wiki/Property:P1921) can be used to make Wikibase generate the correct URI for an entity, instead of having to use BIND(IRI(CONCAT("somePrefix", ?id)) AS ?x) in your query; but it’s tricky to use correctly:
- create the property
- add the formatter URI for RDF resource
- wait 24 hours for the property info cache to expire
- only then start adding actual statements for the property
- difference between http and https!
Great working example on QLever showing genres on MimoText: https://qlever.cs.uni-freiburg.de/wikidata/NlrCC3
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federated_queries: Second example uses Wikidata to determine the nationality of the artists
Determine Education by artist:
Explain prefixes better in the federation examples, and also when they are not needed, see example above, pin button in query service
Explain the intrinsic details of the BIND keyword Label Service only on Wikibase Endpoints! For other endpoints: rdfs:label
Allowlisting!!
Dragan's question(s) What's better to use for external links, a "same as" property pointing to the remote entity or a "external id" wikibase item? is there a way to associate a SPARQL endpoint URL to a property or value that can be used in federated querying?
Day 2 (06.12.2024): https://de.wikipedia.org/wiki/Wikipedia:WikiMUC/Federated_Queries_Documentation_Brunch
Day 2 (06.12.2024):
https://de.wikipedia.org/wiki/Wikipedia:WikiMUC/Federated_Queries_Documentation_Brunch
Documentation to (possibly) improve:
Deprecation of following pages:
- https://www.mediawiki.org/wiki/Wikibase/Federation
- https://meta.wikimedia.org/wiki/Federated_knowledge_graphs
- https://www.mediawiki.org/wiki/Special:MyLanguage/Wikibase/Federated_querying (Was considered as an "Introduction to Federated Queries", but never created), page does now exist and links to Wikidata Federated queries overview page
- https://doc.wikimedia.org/Wikibase/master/php/docs_components_repo-federated-properties.html
- Smaller parts here: https://www.mediawiki.org/wiki/Wikibase/FAQ#Why_should_a_Wikibase%E2%80%99s_first_property_be_%22SameAs%22?
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federation_report/issues
- Old Federation input page: https://www.wikidata.org/wiki/Wikidata:SPARQL_federation_input
- https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Federation
- https://en.wikibooks.org/wiki/SPARQL/Federated_query
- https://en.wikibooks.org/wiki/SPARQL/Prefixes
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced#Federation
Various community tutoprials from Wikibase projects (Factgrid, MiMoText, etc) - consolidate & interlink
- Instructions for Wikibase configuration - where?
The two ;-) lists:
- Deprecated list - bot does not work anymore - https://www.wikidata.org/wiki/Wikidata:Lists/SPARQL_endpoints
- List that will be fixed with the MultiChillBot update - https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federation_report
- unknown list - https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/SPARQL_Federation_endpoints
- This is the production config - https://gerrit.wikimedia.org/r/plugins/gitiles/operations/puppet/+/refs/heads/production/modules/query_service/templates/allowlist.txt.epp
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federation_report
Update MultiChillBot?
For 3rd party wikibases using the wikibase suite images the allowlist is hard coded at:
Open Phabricator tickets to remove broken endpoints:
-> Try to categorise those
Possible categories:
- Wikidata (whitelisting?)
- What about Cloud?
- Federation across different Graph Engines (!)
- Wikidata (whitelisting?)
What do we think is missing:
- Whitelisting
Wikibase Stakeholder Meeting that day: https://notepad.rhizome.org/wbsg-2024-12-05?edit
3 Working Groups (add your names and notes below each group):
General documentation
- (Max, Lozana, Valerie, Maria)
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federated_queries
Updated Pages:
Introduction:
The vision of Linked Open Data is to overcome disconnected data silos. Federated queries, in other words the simultaneous querying of multiple SPARQL endpoints, play a key role in realizing this potential. Ideally, different datasets that have been created in very different contexts can refer to each other, so that 'federation' brings together knowledge stored in different locations in the global Linked Open Data Cloud. In order to actually be able to connect several knowledge graphs via 'federated queries', a number of requirements must be met. This page focuses on federation, which has Wikidata as a starting point and addresses other SPARQL endpoints via federation.
(To learn more about what steps are necessary when hosting a Wikibase instance yourself, see: #)
Connected items In order to be able to write federated queries with Wikidata as starting point, you need to know the Wikidata data model (https://commons.wikimedia.org/wiki/File:SPARQL_data_representation.png) and the data model(s) of the SPARQL endpoint(s) you want to query. To enable federation, the items between the different knowledge graphs must refer to each other. There are standardized properties such as owl:sameAs and wdt:exact match for this purpose. In addition, matching in Wikidata often works via “external identifiers”. Precise knowledge of the data model with regard to the respective property is therefore important.
Allowlist
The SPARQL endpoints must also each allow federation to another SPARQL endpoint. The current [Wikidata allowlist #] provides an overview of all SPARQL endpoints that you can query via Wikidata.
Prefixes
When creating queries manually, or using a query visual helper, it is useful to understand the concept of prefixes. Prefixes are shortcuts replaceing the need to write a full URI path to a resource. Prefixes can be defined at the start of every SPARQL query to ease readability and avoid potential for spelling mistakes. The Wikidata Prefixes are build-in in the Wikidata Query Service and therefore queries also work without Wikidata prefixes being defined again in the query. However, it is good practice to make all relevant prefixes (including those from Wikidata) transparent, especially when writing federated queries.
Calling up an external endpoints
The basic mechanism of federation is to use the SERVICE operator to call up another endpoint. As part of the Prefix defaults, wdqs already defines the the Wikidata endpoint <https://query.wikidata.org/sparql>, so a simple federation syntax to Wikidata would look like this:
SERVICE wdqs {
?a ?b ?c
}
or if not using prefixes the call function would look like this:
SERVICE <https://query.wikidata.org/sparql> {
?a ?b ?c
}
Using external identifiers / IRIs / and the BIND operator When federating, typically we want to get more information about items that exist, or are referenced, in more than one LOD resource. This means we need to have a connecting mechanism between the two reources. One common way of doing that is using External ID properties in Wikidata. However, the default result when asking for the value of an External ID property in Wikidata is a literal and not an IRI that can be used in federated queries. This means we will only get a QID, rather than a full IRI. To be able to re-use the same QUID as a starting point in the federated part of the query, we need to BIND the QID literal to a path (either with a prefix or not). To do this, we need to implement the following syntax:
BIND(IRI(CONCAT(STR(wd:), ?Wikidata_id)) AS ?Wikidata_item)
There is a workaround to avoid using BIND, but there are some caveats. Instead of using the typical path to request a value for a property (i.e. via wdt:, or <http://www.wikidata.org/prop/direct/>), you could also use wdtn: (or <http://www.wikidata.org/prop/direct-normalized/>). This will call up the value generated via the formatter URI for RDF resource (https://www.wikidata.org/wiki/Property:P1921), if it has been defined for the respective external ID property. This will then generate the correct URI for an entity, instead of having to use BIND(IRI(CONCAT("somePrefix", ?id)) AS ?x) in your query. But there are some potential issues that have to be kept in mind:
- once the formatter URI for RDF resource has been added, you have to wait 24 hours for the property info cache to expire
- only then start adding actual statements for the property, previously added statements will not be formatted properly (so for those BIND operator will still be needed)
- note the difference between http and https - the source of truth is always the Concept URI (available in the sidebar on most Wikibase installations including Wikidata); the correct address (http/https) method has to be used consistently when defining prefixes, BINDings, or when adding values to the formatter URI for RDF property.
Examples
(Katharina, Lucas,...)
- Can you look at this one and improve: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced#Federation
Allowlist
(Tom, Lukas)
TO DOs:
- Add federated query examples from this etherpad to the example page https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples/advanced#Federation
- Improve main documentation: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federated_queries
- add more simple examples
- add explanations and links to Qlever
- Improve main documentation: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Federated_queries
- figure out what to do with the mediawiki.org federation docs:
NEEDS from the community scoped for Wikidata / Wikibase Suite team:
- Make defining prefixes (in the Pin button - i.e. in the UI) easier in the Docker distribution for WB Suite + get rid of the "magic" implicit Prefixes.
- https://phabricator.wikimedia.org/T335448
- https://phabricator.wikimedia.org/T379232 (non Wikibase Cloud)
- Default prefixes (both "magic" ones and the prefixes defined by the Pin button) should be custom for WB Cloud, not same as wd / wdt etc (Configuration open per Wikibase)
- Suggestion to use the config system of tib wikibases - here - https://gitlab.com/nfdi4culture/wikibase4research/wikibase4research
- Document setting up the sparql endpoint in the Docker distribution (not the WDQS address but the actual query.[your WB address and domain]/sparql
- Easier configuration of allowlist.txt - TIB to share their fundings after the workshop - this needs to be enabled not just for Suite but also for Cloud.
- Better documentation for Wikibase Cloud specifics, e.g if and how they federate with each other
- Config at dashboard for Wikibase Cloud stuff
- https://phabricator.wikimedia.org/T335448
- UI Update for the "Pin" function of the Query Service UI as a more prominent button not in the sidebar, but above the query editing space - reference the QLever UI
- Selectable Dropdown of Allowlist - this can be tied to the Pin button, so that once selecting a service from the dropdown, the relevant prefixes are added at the top of the query editor
- Wikidata Query Service UI is not neutral for other Wikibases, e.g logo and auto-complete function should work depending on selected Prefixes
2024-12-05 13:38
Example of Wikibase query service qirk when the shorten URL creation fails. We were unsure if this is due to WB's installation to the external shorten url service, tinyurl or something else at work. Ideally, WB provides a shorten URL similar to Wikidata's w.wiki that can be customized by respective Wikibase instance. In our case, we'd love to be able to have the namespace be for instance w.siwiki.
Smithsonian Wikibase: SI-WikiNames federated query example below (comments in CAPs explaining the issue inserted between ### lines)
- Citizenship of artists from WD
- defaultView:ImageGrid
PREFIX
wddt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?person ?remote_item ?person_label ?image ?citizenship_label WHERE {
?person p:P208/ps:P208/wdt:P209* wd:Q18 ; # instance of human/person (Q18) wdt:P17 ?remote_item ; # exact match with external URL WD QID rdfs:label ?person_label .
IN ORDER TO GENERATE SHORTEN URL, A FORCED SPACE AFTER THE "UNCAT" FUNCTION
BIND(uri(concat ("http://www.wikidata.org/entity/", ?remote_item)) AS ?WID)
SERVICE <https://query.wikidata.org/sparql> {
?WID wddt:P27 ?citizenship .
?citizenship rdfs:label ?citizenship_label .
OPTIONAL { ?WID wddt:P18 ?image .} FILTER (lang(?citizenship_label) = "en")
}
}
ORDER BY (?person_label)