Hands-on Session 1: Following your nose, music for the minority, the 303 dance, and the transient nature of (wiki) fame
It’s important to note that when working with RDF tools and libraries are your friend. For example, most of the simple demo web user-facing tools are written using the Graphite and ARC PHP libraries.
However, to get an understanding of what’s going on “under the hood” we’re going to use some alternative tools. We’ve tried to find web-based interfaces for ease and speed of access during the tutorial, but we’ve also listed some alternatives you may be able to install on your own machine.
Tool 1: Viewing and converting between RDF serializations
Morph
http://morph.talis.com/
Morph retrieves RDF from a URI and converts it into a serialisation of your choice. We’re going to use it to view some RDF/XML (briefly!) and Turtle.
Alternative web tool: http://triplr.org/
Alternative command-line tools: use “wget” to fetch content, and “rapper” (usually park of the “raptor” package) to convert between serialization.
Example 1: Viewing some RDF/XML, Turtle, and following your nose
- Use Morph to view the RDF from http://dbtune.org/jamendo/artist/834
- This is provided by a Linked Data encoding of Jamendo, provided by dbtune.org
- you can leave “Input” as “Guess”
- but make sure “Output” is “RDF/XML”
- Your browser will now either display the XML serialised RDF, or offer to download it - if the latter, save the XML file and open it in your favourite text editor.
- You should be looking at some RDF/XML describing the aspirationally-named group “Music for the Minority”
- You’ll see some namespaces defined at the start, and referenced throughout by a namespace: prexix. Don’t worry about these too much (for now), but note the fairly intuitively labelled terms following the namespace prefixes.
- That’s enough of RDF/XML - it’s best left to the machines.
- Now use Morph to view the same RDF (http://dbtune.org/jamendo/artist/834), but this time select “Output” as “Turtle”
- You’ll be able to see some literal typed data (including some poor formatting), but you should also be able to follow your nose via some semantic relationships to further URIs. It may be helpful to sketch out the graph as you traverse it.
- Once again, don’t worry too much about the exact “meaning” of these relationships - we’ll be talking about ontologies later. Just try browsing through this section of the web of data.
- Try to cut and paste these linked URIs both directly into your web browser, for a human-readable representation, and into the “Input” field of Morph.
- This is content negotiation at work
- Not everything is RDF! But you should be able to follow links to find out more about:
- a recording the band have made
- where the band are located
- Can you follow further links from the RDF at these URIs too?
- Try the above again but with a different artist, identified by the following URI: http://dbtune.org/jamendo/artist/3080
- You should notice an additional owl:sameAs relationship. This is perhaps unsurprising, since we probably wouldn’t expect Jamendo to be the sole provider of artist information to the world.
- It’s available because the dbtune maintainer (Yves Raimond) performed an alignment analysis over the data and encoded the results in RDF.
- Feed the sameAs URI to Morph. Note that this data is provided by an entirely different service... keep following those links!
- Try starting from some alternate sources of artist information:
Tool 2: Modifying HTTP headers to investigate 303 redirects
AskApache HTTP Headers Tool
http://www.askapache.com/online-tools/http-headers-tool/
This tool enables us to send an HTTP request and view the full response the server replies with (essentially this is debug).
Alternative browser tool: Modify Headers extension for Firefox https://addons.mozilla.org/en-US/firefox/addon/modify-headers/
Alternative command line tool: Use “curl” with the “-H” option and “Accept: application/rdf+xml”.
Example 2: Watching the 303 dance
- Using the AskApache HTTP Headers Tool, set:
- “Target URL” to http://dbtune.org/jamendo/artist/834
- “Accept Header” to “application/rdf+xml”
- De-select “Follow Redirects”, “Auto Referer”, “HexDump”, and “Save Results”
- Enter the CAPTCHA
- Press the “Initiate HTTP Header Capture” button
- Note the “303 See Also” code returned, and the “Location” this refers to (paste the location into Morph?).
- But principally note that, although this was going on in our earlier example, tools can deal with it transparently if that is the desired.
Hands-on Session 2: Content to negoitiate and how to SPARQL
Example 3: More RDF and content negotiation with the Audio File Repository
- Use the AskApache HTTP Headers Tool again on with this URI: http://jamendo.legacy.audiofiles.linkedmusic.org/audiofile/98933
- but this time set the accept type to “audio/mpeg”
- give the 303 location to your web browser (or if your browser doesn’t have a handler for audio, download the file then play it)
- Now use Morph to retrieve and view the RDF. Follow your nose to Jamendo. Make a note of the Jamendo recordings the audio files are encodings of (from the RDF).
- Also try:
Example 4: A simple SPARQL query to the the Audio File Repository
- We’ve put an web interface for the Audio File Repository SPARQL endpoint up at: http://jamendo.legacy.audiofiles.linkedmusic.org/snorql/
- open it in your browser
- note that non-human client can connect directly to the endpoint using the SPARQL protocol
- When the Collection Builder “grounds” a collection it queries the Audio File repository with a simple query to find any audio files which encode the abstract recordings listed in the (ungrounded) collection:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?audiofile WHERE {
<http://dbtune.org/jamendo/track/98933> mo:available_as ?audiofile .
?audiofile a mo:AudioFile .
}
- Substituting in the Jamendo recordings you noted above, try out the query on the Audio File Repository.
Example 5: SPARQLing with Jamando at dbtune
- The Collection Builder creates its collections using the RDF and SPARQL endpoint available from dtune
- There is a similar SPARQL endpoint web interface for the Jamendo data
- Enter the query on slide 50 “SPARQL Queries (3)”
- Do you receive the expected match?
- Change the SELECT statement to return all variable by replacing “?artistname” with “*”, i.e.
- SELECT * FROM {
- Resubmit the query
- Try changing the graph pattern. Instead of matching against the title of the album find all artists who have made albums that have a 7th track. Some hints:
- Extend the Record pattern to match tracks
- Match tracks that have a number 7
- Look at the RDF you discovered earlier to find the required concepts and properties (e.g. http://dbtune.org/jamendo/track/71263 )
- Verify your results - list and look at the albums that match within the graph pattern
- Hint: add “?album” after “?artistname” to the SELECT clause
- Are there fewer artists with 20 track records?
- Do some artists have more than one album with 5 tracks? Does this cause them to be matched multiple times?
- Try changing the part of the SELECT clause to “SELECT DISTINCT ?artistname”