Skip to content

Instantly share code, notes, and snippets.

View moskomule's full-sized avatar
🎯
Focusing

Ryuichiro Hataya moskomule

🎯
Focusing
View GitHub Profile
@moskomule
moskomule / wikigraph.sql
Created November 4, 2016 03:24
create lists of vertices and edges from Wikipedia page.sql and redirects.sql
## verex list
SELECT p.page_id, p.page_title
FROM page p
WHERE p.page_namespace=0
INTO OUTFILE '/tmp/vertices.tsv'
FIELDS TERMINATED BY ' ';
## edge list
SELECT l.pl_from, p.page_id
FROM page p, pagelinks l
@moskomule
moskomule / sparql_access.py
Created October 30, 2016 09:37
fetch more than 10000 contents from DBpedia etc. by sparql
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://localhost:8890/sparql")
for i in range(25):
query = """
select ?slabel ?olabel
where {
?s rdfs:subClassOf ?o.
?s rdf:type owl:Class.
?o rdf:type owl:Class.