Command Line Semantic Web with Redland

Dave Beckett@dajobe

This talk is personal opinion.
I am not speaking on behalf of my employer Yahoo! although they are awesome.
The slides are presented via S5

Redland RDF C Libraries

Redland libraries uses

Command Line Redland

Every library has a utility and a manpage:

Library Utility Use Manpage
Raptor rapper(1) RDF triples to / from syntax rapper.1
Rasqal roqet(1) Querying the RDF graph roqet.1
Redland rdfproc(1) RDF graph manipulations rdfproc.1
"Bindings" python(1), perl(1), ... RDF graph manipulations  

rapper — syntax command line

Raptor http://librdf.org/raptor/ via rapper(1):

# count triples
$ rapper -c http://librdf.org/redland.rdf
# or the unix way
$ rapper -q http://librdf.org/redland.rdf | wc -l
# get triples from home page
$ rapper -g -q -o turtle http://www.dajobe.org/
# What was it doing?
$ rapper -g -q -c --trace http://www.dajobe.org/
# parse the slides
$ rapper -g -q -o turtle index.html
# what just happened?
rapper -g -c --trace index.html

rapper parsing — What just happened?

rapper execute example

RDF Graph Query

SPARQL

SPARQL Protocol and RDF Query Language

Query: Find names and websites of people on PlanetRDF:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?website
FROM   <http://planetrdf.com/bloggers.rdf>
WHERE { ?person foaf:weblog ?website ;
                foaf:name ?name .
        ?website a foaf:Document
      }

Protocol:

http://.../qps?
query-lang=http://www.w3.org/TR/rdf-sparql-query/
&graph-id=http://planetrdf.com/bloggers.rdf
&query=PREFIX foaf: <http://xmlns.com/foaf/0.1/...

roqet — querying command line

Rasqal http://librdf.org/rasqal/ via roqet(1):

# use planetrdf query
$ roqet example.rq
# I'd like json please
$ roqet -r json example.rq
# or CSV
$ roqet -r csv example.rq
# just the names in column 2
$ roqet -r csv example.rq | awk -F, '{print $2}'

roqet querying — What just happened?

roqet execute example

rdfproc — RDF graph command line

Redland http://librdf.org/ via rdfproc(1):

$ rdfproc
Redland RDF processor utility 1.0.10
Copyright 2000-2008 David Beckett. Copyright 2000-2005 University of Bristol
Try `rdfproc --help' for more information.
# Guess - aka GRDDL parse
$ rdfproc test parse http://www.dajobe.org/ guess
# debug print
$ rdfproc test print
# Ntriples please
$ rdfproc test serialize ntriples
# query
$ rdfproc test query sparql - 'select ?o where { ?s <http://xmlns.com/foaf/0.1/name> ?o} '

Web dev command line

Multiple language bindings have their own utility.

$ python
Python 2.5.5 (r255:77872, Feb  1 2010, 19:53:42) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
<<< import RDF
<<< 
$ perl -MRDF::Redland '...'

etc.

Triplr — Web Command Line: the address bar

Like the above but in the cloud. So it must be AWESOME!

Triplr: http://triplr.org/

Run a query returning JSON via Triplr

Thanks

Slides: http://bit.ly/semweb-sxsw

Redland: http://librdf.org/

Emergency Command Line Results

$ rapper -c http://librdf.org/redland.rdf
rapper: Parsing URI http://librdf.org/redland.rdf with parser rdfxml
rapper: Serializing with serializer ntriples
rapper: Parsing returned 40 triples
$ rapper -g -q -o turtle http://www.dajobe.org/

results: home.ttl

$ rapper -g -q -c --trace http://www.dajobe.org/
rapper: Processing URI http://www.dajobe.org/
rapper: Processing URI http://www.dajobe.org/foaf.rdf
rapper: Processing URI http://journal.dajobe.org/journal/comments.rdf
rapper: Processing URI http://www.dajobe.org/xslt/grokXFN.xsl
$ rapper -g -c --trace index.html 
rapper: Parsing URI file:///Users/dajobe/websites/www.dajobe.org/talks/201003-semweb-sxsw/index.html with parser guess
rapper: Processing URI file:///Users/dajobe/websites/www.dajobe.org/talks/201003-semweb-sxsw/slides.xslt
rapper: Guessed parser name 'grddl'
rapper: Parsing returned 58 triples