I’ve been periodically poking at getting Linked Data/RDF views hooked into the World Digital Library web application, following Ed Summers’ lead from his work on Chronicling America. The RDF views also use the OAI-ORE vocabulary to express aggregations – in WDL, an item is an aggregation of its constituent files. The goal is to provide a semantically rich and holistic representation of a WDL item (identifier, constituent files, metadata, translations, and so on).
The ORE format is a new one for me so it’s hard to say whether the output of my dev branch is valid ORE or not. Plus I’m a sucker for validators. Turns out Rob Sanderson has developed a Python library for validating ORE, and this little snippet is what I’ve been using to validate the ORE. I didn’t put much effort into making it readable, so much as banging something functional out so I can meet deadlines, so mea culpa and all that. But without further hemming and hawing, the code:
# validate.py
import sys
from foresite import *
rem = RdfLibParser().parse(ReMDocument(sys.argv[1]))
aggr = rem.aggregation
n3 = RdfLibSerializer('n3')
rem2 = aggr.register_serialization(n3)
print rem2.get_serialization(n3).data
Most of this code is naively copied and pasted from Rob’s excellent Foresite documentation.
I invoke it thusly: python validate.py {URL}
And the output:
@prefix _27: .
@prefix _28: .
@prefix _29: .
@prefix bibo: .
@prefix dc: .
@prefix dcterms: .
@prefix ore: .
@prefix rdf: .
@prefix rdfs: .
@prefix rdfs1: .
_28:ResourceMap a ore:ResourceMap;
dc:format "text/rdf+n3";
dcterms:created "2009-07-31T14:23:31Z";
dcterms:modified "2009-07-31T14:23:31Z";
ore:describes _29:id.
_29:id a bibo:Image,
ore:Aggregation;
dcterms:DDC "973";
dcterms:alternative "Antietam, Maryland. Allan Pinkerton, President Lincoln, and Major General John A. McClernand"@en;
dcterms:created "1862年10月3日"@zh,
"3 de octubre de 1862"@es,
"3 de outubro de 1862"@pt,
"3 octobre 1862"@fr,
"3 октÑÐ±Ñ€Ñ 1862 года"@ru,
"October 3, 1862"@en,
" ٣ آكتوبر، ١٨٦٢"@ar;
dcterms:creator "Gardner, Alexander"@en,
"Gardner, Alexander"@es,
"Gardner, Alexander"@fr,
"Gardner, Alexander"@pt,
"Гарднер, ÐлекÑандр"@ru,
"جاردنر, أليكسندر"@ar,
"åŠ å¾·çº³, 亚历山大"@zh;
... (and so on and so forth)
dcterms:title "Antietam, Maryland. Allan Pinkerton, President Lincoln, and Major General John A. McClernand: Another View"@en,
"Antietam, Maryland. Allan Pinkerton, el Presidente Lincoln y el General Principal John A. McClernand: Otra visión"@es,
"Antietam, Maryland. Allan Pinkerton, le président Lincoln et le général-major John A. McClernand: Autre vue"@fr,
"Antietam, Maryland. Allan Pinkerton, Â Presidente Lincoln e Major-General John A. McClernand: Outra Vista"@pt,
"ÐнтитÑм, штат МÑриленд. Ðллан Пинкертон, президент Линкольн и генерал-майор Джон Ð. Макклернанд: Другой Ñнимок"@ru,
"أنتينام، ميريلاند ألان بينكرتون، الرئيس لينكولن، واللواء جون أ. ماكليرناند: منظر آخر"@ar,
"安蒂特姆,马里兰州 è‰¾ä¼¦Â·å¹³å…‹é¡¿ã€æž—肯总统和少将约翰·A ·马克克拉å—: å¦ä¸€ä¸ªè§†è§’"@zh;
ore:aggregates ,
;
ore:isDescribedBy ;
rdfs:seeAlso .
a _27:FileDataObject;
dcterms:format "image/gif";
_27:fileSize "34531"^^.
a _27:FileDataObject;
dcterms:format "image/tiff";
_27:fileSize "1301614"^^.
ore:Aggregation rdfs1:isDefinedBy ;
rdfs1:label "Aggregation".
ore:ResourceMap rdfs1:isDefinedBy ;
rdfs1:label "ResourceMap".
You might pick up on some warts I have yet to fix, but there you go.
