I'm a long-time fan of the graph visualization tool Gephi and since Wikimania 2019 I got involved with Wikidata. I was aware of the Gephi plugin "Semantic Web Importer", but when I check it out, I only find old tutorials connecting to DBpedia, not Wikidata:
- "Visualising Related Entries in Wikipedia Using Gephi" by Tony Hirst, 2012-07-03
- "Let’s Play Gephi: Dbpedia, RDF, Sparql and your favorite Actors" by Matthieu Totet, 2015-10-06
- "Gephi tutorials: Semantic Web Importer" by Matthieu Totet, 2017-01-31
It took a tiny bit of fiddling, but turns out Wikidata seems perfectly compatible with the Semantic Web Importer plugin. Get the REST endpoint for the Wikidata:SPARQL query service (EndPoint URL: https://query.wikidata.org/sparql
, query tag name: query
), explicitly supply the needed prefixes and then it should work to adapt the WDQS example "Groups of characters in the Marvel universe" for Gephi (it requires a CONSTRUCT rather than a SELECT):
#defaultView:Graph
SELECT ?char ?charLabel ?group ?groupLabel ("7FFF00" as ?rgb)
WHERE {
?group wdt:P31 wd:Q14514600 ; # group of fictional characters
wdt:P1080 wd:Q931597. # from Marvel universe
?char wdt:P463 ?group # member of group
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
Example Gephi Semantic Web Import SPARQL query:
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Groups of characters in the Marvel universe
CONSTRUCT {
?group gephi:label ?groupLabel .
?group gephi:category "group" .
?char gephi:label ?charLabel .
?char gephi:category "character" .
?char wdt:P463 ?group
} WHERE {
?group wdt:P31 wd:Q14514600 ; # group of fictional characters
wdt:P1080 wd:Q931597. # from Marvel universe
?char wdt:P463 ?group # member of group
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".}
}
From there on, you should be able to fetch, process and analyse Wikidata straight into Gephi!
@barripdmx Search in Spanish, or something regarding Spain?
Sounds like you should get acquainted with SPARQL, this is a good tutorial:
https://m.youtube.com/watch?feature=youtu.be&v=b3ft3CzkLYk
If you want Spanish, it's as simple as changing "en" to "es" in my example. Wikidata is multilingual and serve wikipedias of all language versions, that's a point of the project.
If you're interested in Spain, start with checking out the properties of its Wikidata item, and what is related to it (too many items). Load and modify a suitable example from Wikidata query service, get it to work, then modify it as I did and you can plug it into Gephi Semantic Web Importer. Easy :-D
https://www.wikidata.org/wiki/Q29
https://www.wikidata.org/wiki/Special:WhatLinksHere/Q29
https://query.wikidata.org/