Maven details are:
- groupId: com.github.albaker
- artifactId: GroovySparql
- version: 0.6
This should help folks wanting to try Linked Data a very easy way using all of the usual Groovy tools (GroovyConsole, groovysh (REPL), groovy <script>), etc. Grails plugin is also in the works.
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('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}" | |
} | |