Last active
December 12, 2015 02:38
-
-
Save AlBaker/4700005 to your computer and use it in GitHub Desktop.
Using Groovy SPARQL with Dbpedia
This file contains hidden or 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.5') | |
import groovy.sparql.* | |
def sparql = new Sparql(endpoint:"http://dbpedia.org/sparql") | |
def query = """ | |
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | |
PREFIX yago: <http://dbpedia.org/class/yago/> | |
SELECT ?president ?name WHERE { | |
?president a yago:PresidentsOfTheUnitedStates ; | |
foaf:name ?name | |
} | |
""" | |
sparql.eachRow query, { row -> | |
println "${row.president} is ${row.name}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment