For Johan,
Was looking through the citeproc-py code. Great to see the RDF driver.
However, you might want to look at this example for a perhaps easier
and more flexible approach (because completely decoupled from
serialization format):
http://inkdroid.org/bzr/lcsh/web/concept.py
So here he’s using RDFLib to do the RDF parsing, and then mapping the
triples to an object.
Another (more generic) alternative, is this:
http://www.openvest.com/trac/wiki/RDFAlchemy
Example code I was playing with:
#!/usr/bin/env python
encoding: utf-8
from config.namespaces import BIBO, DC
from rdfalchemy import rdfSubject, rdfSingle, rdfMultiple
class Document(rdfSubject):
rdf_type = BIBO.Document
title = rdfSingle(DC.title)
date = rdfSingle(DC.date)
issued = rdfSingle(DC.issued)
peer_reviewed = rdfSingle(BIBO.peerReviewed)
# for convenience, we leave room for a more denormalized representation
creators = rdfMultiple(DC.creator)
contributions = rdfMultiple(BIBO.contribution)
subjects = rdfMultiple(DC.subject)
def concept_sort(a,b):
return cmp(a.pref_label, b.pref_label)
# self.subjects.sort(concept_sort)
class Article(Document):
volume = rdfSingle(BIBO.volume)
issue = rdfSingle(BIBO.issue)
pages = rdfSingle(BIBO.pages)
page_start = rdfSingle(BIBO.pageStart)
page_end = rdfSingle(BIBO.pageEnd)
periodical = rdfSingle(DC.isPartOf)
class AcademicArticle(Article):
pass
class Chapter(Document):
# reference to a Book
published_in = rdfSingle(DC.isPartOf)
class Review(Article):
# reviewed resource
review_of = rdfSingle(BIBO.reviewOf)
class PublishedDocument(Document):
publisher = rdfSingle(DC.publisher)
class Book(PublishedDocument):
pass
Bruce