Created
February 9, 2013 22:19
-
-
Save AlBaker/4747365 to your computer and use it in GitHub Desktop.
Groovy Sparql released
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('com.github.albaker:GroovySparql:0.6') | |
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 | |
} LIMIT 3 | |
""" | |
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