Skip to content

Instantly share code, notes, and snippets.

@nevali
Created April 15, 2014 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevali/10786827 to your computer and use it in GitHub Desktop.
Save nevali/10786827 to your computer and use it in GitHub Desktop.
liblod, part 3: an agent can now opt to follow foaf:primaryTopic; and redirects are dealt with much more sensibly—the redirect URL (if status was not a 303) is pushed into a FIFO list of subjects, and subject matching will be attempted in each in turn. in other words, redirects work as you would expect.
$ ./lod-util
./lod-util: a test harness for liblod
Enter a URI to resolve, or .COMMAND (type '.help' for a list of commands)
> .follow
will follow foaf:primaryTopic
> http://bbc.co.uk/spooks
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.bbc.co.uk/programmes/b006mf4b#programme>
dc:title "Spooks" ;
<http://purl.org/ontology/po/genre> <http://www.bbc.co.uk/programmes/genres/drama/actionandadventure#genre> ;
<http://purl.org/ontology/po/masterbrand> <http://www.bbc.co.uk/bbcone#service> ;
<http://purl.org/ontology/po/medium_synopsis> "Tense drama series about the different challenges faced by the British Security Service as they work against the clock to safeguard the nation" ;
<http://purl.org/ontology/po/pid> "b006mf4b" ;
<http://purl.org/ontology/po/series> <http://www.bbc.co.uk/programmes/b006mf48#programme>, <http://www.bbc.co.uk/programmes/b0084lb1#programme>, <http://www.bbc.co.uk/programmes/b00fd3r8#programme>, <http://www.bbc.co.uk/programmes/b00ntg2p#programme>, <http://www.bbc.co.uk/programmes/b00ty203#programme>, <http://www.bbc.co.uk/programmes/b0153b1h#programme>, <http://www.bbc.co.uk/programmes/p008w4dv#programme>, <http://www.bbc.co.uk/programmes/p009sxfg#programme>, <http://www.bbc.co.uk/programmes/p00cfpg2#programme>, <http://www.bbc.co.uk/programmes/p00cfpg4#programme> ;
<http://purl.org/ontology/po/short_synopsis> "Tense drama series about the different challenges faced by the British Security Service" ;
a <http://purl.org/ontology/po/Brand> ;
foaf:depiction <http://www.bbc.co.uk/iplayer/images/progbrand/b006mf4b_512_288.jpg> .
# subject URI is <http://www.bbc.co.uk/programmes/b006mf4b#programme>
# request URI was <http://bbc.co.uk/spooks>
# document URI was <http://www.bbc.co.uk/programmes/b006mf4b.rdf>
> .follow
will not follow foaf:primaryTopic
> http://bbc.co.uk/spooks
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://www.bbc.co.uk/programmes/b006mf4b.rdf>
dct:created "2007-09-10T16:02:43+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
dct:modified "2007-11-28T18:05:51Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
rdfs:label "Description of the brand \"Spooks\"" ;
foaf:primaryTopic <http://www.bbc.co.uk/programmes/b006mf4b#programme> .
# subject URI is <http://www.bbc.co.uk/programmes/b006mf4b.rdf>
# request URI was <http://bbc.co.uk/spooks>
# document URI was <http://www.bbc.co.uk/programmes/b006mf4b.rdf>
>
@nevali
Copy link
Author

nevali commented Apr 15, 2014

Earlier debugging output shows how the subject FIFO is pushed given the above request-URI:

[pushing subject <http://bbc.co.uk/spooks>]
[pushing subject <http://www.bbc.co.uk/spooks>]
[pushing subject <http://www.bbc.co.uk/spooks/>]
[pushing subject <http://www.bbc.co.uk/programmes/b006mf4b/>]
[pushing subject <http://www.bbc.co.uk/programmes/b006mf4b>]
[pushing subject <http://www.bbc.co.uk/programmes/b006mf4b.rdf>]

Putting aside whether some of the redirects on bbc.co.uk should be smarter, this is how we end up with either a document description (if foaf:primaryTopic following is disabled), or the actual brand information (if it's enabled).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment