Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Last active March 11, 2019 16:59
Show Gist options
  • Select an option

  • Save psychemedia/5999271 to your computer and use it in GitHub Desktop.

Select an option

Save psychemedia/5999271 to your computer and use it in GitHub Desktop.
Simple query for grabbing philosopher influence netwrok out of dbPedia
//Mapping philsopher influence netwroks
//via http://blog.ouseful.info/2012/07/03/visualising-related-entries-in-wikipedia-using-gephi/
CONSTRUCT{
?p <http://dbpedia.org/ontology/influenced> ?influenced.
} WHERE {
?p a
<http://dbpedia.org/ontology/Philosopher> .
?p <http://dbpedia.org/ontology/influenced> ?influenced.
} LIMIT 10000
//Choose labels to provide a more readable version of graph
prefix gephi:<http://gephi.org/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT{
?philosopher gephi:label ?philosopherName .
?influence gephi:label ?influenceName .
?philosopher <http://dbpedia.org/ontology/influencedBy> ?influence
} WHERE {
?philosopher a
<http://dbpedia.org/ontology/Philosopher> .
?philosopher <http://dbpedia.org/ontology/influencedBy> ?influence.
?philosopher foaf:name ?philosopherName.
?influence foaf:name ?influenceName.
} LIMIT 10000
//----
//To search for other influence networks, use SNORQL (http://dbpedia.org/snorql/):
SELECT DISTINCT ?c WHERE {
?a <http://dbpedia.org/ontology/influencedBy> ?b.
?a rdf:type ?c.
?b a ?c.
} limit 50 offset 150
http://dbpedia.org/snorql/?query=SELECT+DISTINCT+%3Fc+WHERE+%7B%0D%0A%3Fa+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2FinfluencedBy%3E+%3Fb.%0D%0A%3Fa+rdf%3Atype+%3Fc.%0D%0A%3Fb+rdf%3Atype+%3Fc.%0D%0A%7D+limit+50+offset+0%0D%0A
//-------------------------------------------------------
//Mapping Related Musical Genres on Wikipedia/DBPedia With Gephi
//via http://blog.ouseful.info/2012/07/04/mapping-related-musical-genres-on-wikipediadbpedia-with-gephi/
prefix gephi:<http://gephi.org/>
CONSTRUCT{
?genreA gephi:label ?genreAname .
?genreB gephi:label ?genreBname .
?genreA <http://ouseful.info/edge> ?genreB .
?genreB <http://ouseful.info/edge> ?genreA .
} WHERE {
?band <http://dbpedia.org/ontology/genre> <http://dbpedia.org/resource/Psychedelic>.
?band <http://dbpedia.org/property/background> "group_or_band"@en.
?band <http://dbpedia.org/ontology/genre> ?genreA.
?band <http://dbpedia.org/ontology/genre> ?genreB.
?genreA rdfs:label ?genreAname.
?genreB rdfs:label ?genreBname.
FILTER(?genreA != ?genreB && langMatches(lang(?genreAname), "en") && langMatches(lang(?genreBname), "en"))
}
//To find candidate values via SNORQL (http://dbpedia.org/snorql/):
SELECT DISTINCT ?c WHERE {
?a <http://dbpedia.org/ontology/influencedBy> ?b.
?a rdf:type ?c.
?b a ?c.
} limit 50 offset 150
http://dbpedia.org/snorql/?query=SELECT+DISTINCT+%3Fgenre+WHERE+%7B%0D%0A++%3Fband+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2Fbackground%3E+%22group_or_band%22%40en.%0D%0A++%3Fband+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2Fgenre%3E+%3Fgenre.%0D%0A%7D+limit+50+offset+0
//-------------------------------------------------------
//Mapping How Programming Languages Influenced Each Other According to Wikipedia
//Via http://blog.ouseful.info/2012/07/03/mapping-how-programming-languages-influenced-each-other-according-to-wikipedia/
prefix gephi:<http://gephi.org/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT{
?a gephi:label ?an .
?b gephi:label ?bn .
?a <http://dbpedia.org/ontology/influencedBy> ?b
} WHERE {
?a a <http://dbpedia.org/ontology/ProgrammingLanguage>.
?b a <http://dbpedia.org/ontology/ProgrammingLanguage>.
?a <http://dbpedia.org/ontology/influencedBy> ?b.
?a foaf:name ?an.
?b foaf:name ?bn.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment