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 via rapper(1):

# count triples
$ rapper -c
# or the unix way
$ rapper -q | wc -l
# get triples from home page
$ rapper -g -q -o turtle
# What was it doing?
$ rapper -g -q -c --trace
# 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 Protocol and RDF Query Language

Query: Find names and websites of people on PlanetRDF:

PREFIX foaf: <>
SELECT ?name ?website
FROM   <>
WHERE { ?person foaf:weblog ?website ;
                foaf:name ?name .
        ?website a foaf:Document


&query=PREFIX foaf: <

roqet — querying command line

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 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 guess
# debug print
$ rdfproc test print
# Ntriples please
$ rdfproc test serialize ntriples
# query
$ rdfproc test query sparql - 'select ?o where { ?s <> ?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 '...'


Triplr — Web Command Line: the address bar

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


Run a query returning JSON via Triplr




Emergency Command Line Results

$ rapper -c
rapper: Parsing URI with parser rdfxml
rapper: Serializing with serializer ntriples
rapper: Parsing returned 40 triples
$ rapper -g -q -o turtle

results: home.ttl

$ rapper -g -q -c --trace
rapper: Processing URI
rapper: Processing URI
rapper: Processing URI
rapper: Processing URI
$ rapper -g -c --trace index.html 
rapper: Parsing URI file:///Users/dajobe/websites/ with parser guess
rapper: Processing URI file:///Users/dajobe/websites/
rapper: Guessed parser name 'grddl'
rapper: Parsing returned 58 triples