Created
July 9, 2011 16:51
-
-
Save AlBaker/1073737 to your computer and use it in GitHub Desktop.
DBPedia Query example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.codehaus.groovy.sparql:groovy-sparql:0.1') | |
import groovy.sparql.* | |
def sparql = new Sparql("http://dbpedia.org/sparql") | |
def query = """ | |
PREFIX owl: <http://www.w3.org/2002/07/owl#> | |
SELECT distinct ?c ?p WHERE { ?c a owl:Class } LIMIT 10 | |
""" | |
sparql.eachRow query, { row -> | |
println row | |
} | |
/***** | |
Note: | |
Uses Groovy SPARQL: http://goo.gl/hhjng | |
Setup Gradle / Maven / Gradpe: http://goo.gl/8bnrC | |
Output: | |
[c:http://www.w3.org/2002/07/owl#Thing] | |
[c:http://www.w3.org/2002/07/owl#Nothing] | |
[c:577a6db1:131063b7345:-7ff5] | |
[c:577a6db1:131063b7345:-7ff4] | |
[c:577a6db1:131063b7345:-7ff3] | |
[c:http://dbpedia.org/ontology/Company] | |
[c:http://dbpedia.org/ontology/Cycad] | |
[c:http://dbpedia.org/ontology/Plant] | |
[c:http://dbpedia.org/ontology/Place] | |
[c:http://dbpedia.org/ontology/CricketLeague] | |
******/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment