Visualizing RDF

From ActiveArchives
Jump to: navigation, search

RDF is quite hard to visualize. While the abstract nature of the "triples for everything" approach is the key to RDF's flexibility and applicability for different contexts, it also makes it difficult to get a grip on what the resulting structures actually look like. To take an example, consider the data available from Freebase (the "Wikipedia" of linked data), on visual artist Eva Hesse: When viewed Firefox one gets a syntax colored and outline-style view of the XML with collapsible hierarchy. Here a small fragment:


As with many "machine-readable" formats, RDF introduces a lot of "packaging" that one needs to unwrap to get to the core data that one is actually interested in seeing/using. Luckily, in addition to its "native" RDF-XML format, there are a number of other textual representations for RDF. Dave Beckett, creator of the standard Redland library for working with RDF, has also produced a number of command-line tools to access the library. The rapper command, for instance, can be used translate RDF data between a number of different formats. The default input format is RDF-XML and the default output format is called "ntriples".

Typing the command:


... displays the following output (here just 9 of the 139 total triples are shown):

<> <> <> .
<> <> <> .
<> <> "1953" .
<> <> <> .
<> <> "1952" .
<> <> <> .
_:genid1 <> <> .
_:genid1 <> "1576301" .
<> <> _:genid1 .

Ntriples is very useful as a format for understanding the essential structure of RDF. An RDF source is essentially a set of "triples" in the form:


The first element in a triple is called the subject (that which is being described), the second the predicate (or type of relationship being described), and the third, the object (that which is referred to). The linguistic underpinings of RDF is echoed in the terminology and the use of a period to mark the end of each triple. Unlike a natural language text, however, the order of the lines is not considered important (just the order within each "sentence"). In addition, while RDF databases are sometimes described as databases of "facts", the actual semantic meaning or "truth" of what's being described by a triple is entirely up to the author(s).

Triples can also be thought of as qualified links, or "links with flavors". Building on the familiar basis of HTML links (where the source page containing a link would be the subject, and the links reference (or "href") the object), RDF adds the ability to give each link a kind of tag or category (also in the form of a URL) to further specify the meaning or kind of relationship of the link. (In fact in the first versions of HTML, link elements contain a "rel" attribute already hinting at how semantic links might be written.) In addition to URLs, textual data (called literals) can be used as objects to refer to information like names, dates or numeric values. In a nutshell, the components of a triple can be one of three possible things:

  • A URI (or URL), shown between less-than/greater-than symbols, (i.e. <>)
  • A "literal" value displayed in quotation marks (e.g. "Michael Murtaugh"),
  • A "blank" node, (in the form _:blaHdiEBlah), which functions like a temporary URL, effectively allowing for grouping of triples without needing to actually come up with a URL.

While the flatness of ntriples makes the essential structure of RDF clear, it also obscures the repetitive and potentially hierarchical nature of the data as a whole. In ntriples, many nodes are listed repeatedly for each bit of information (making it hard to see what information belongs to what), and the order of the triples is not necessarily logical from the point of view of reading. While the RDF-XML structure (potentially) addresses a number of these issues, the "turtle" format (also created by Dave Beckett) does the same without (re)introducing the bloat of XML. The command:

rapper --output turtle

produces the output:

@prefix rdf: <> .
@prefix fb: <> .
    fb:people.deceased_person.cause_of_death <> ;
    fb:people.deceased_person.date_of_death "1970-05-29" ;
    fb:people.deceased_person.place_of_death <> ;
    fb:people.person.date_of_birth "1936-01-11" ; <>, <>, <>, <> ;
    a <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <> ;
<> "1959" ; <> ; "1957" ; <> ;
    a <> .

Here information is grouped hierarchically so that triples with the same subject appear as lists, subgrouped by predicate (type). In the case of more grouped information, things are still spread out over multiple "nodes", as in the case of the list of "education" information, where information is grouped into clumps for a time periods (start_date, end_date) for a particular educational institution.

Rapper also supports output as a "dot" file, which can be rendered as an image using the tools provided by graphviz:

rapper --output dot >
dot -Tsvg > evahesse.svg

View full SVG here

This rather "spacy" visualization of the file is indeed graphical; with some effort one can read the fact that in 1957, Eva Hesse both finished her studies as Cooper Union, and began her studies at the Yale School of Art. What is also made visible is how the literal boxes and lines algorithmic rendering of the data is not the most readable visual means of grouping and connecting pieces of information -- certainly when many relationships are being depicted and no sensitivity is given (or available in the case of an algorithmic layout such as that graphviz performs) to the relative importance or meaning to the relationships.

For comparison, if we can go back to the "human-readable" freebase page on Eva Hesse, where one finds summaries of information in more familiar tabular "info box" style:



The challenge is how to produce a means of visualizing and navigating RDF-encoded data in a way that accepts the generality of a graph structure while still allowing for familiar tabular / hierarchical and concise views that provide a legible overview of the that which is being described.

Filtering with SPARQL

Visualizing RDF, Part 2


Rapper, and other RDF tools

By Dave Beckett, author of the "redland" rdf library (librdf), the turle format, and various commandline tools to work with RDF.

Installing rapper on debian:

apt-get install redland-utils



apt-get install graphviz

Read the man page:

man graphviz


What links here

Personal tools