예제 #1
0
파일: rdf.py 프로젝트: edsu/open-oni
def page_to_graph(p, g=None):
    if not g:
        g = make_graph()

    uri = abstract_uri(p)
    g.add((uri, RDF.type, NDNP['Page']))
    g.add((uri, NDNP['sequence'], Literal(p.sequence)))
    g.add((uri, ORE['isAggregatedBy'], abstract_uri(p.issue)))

    jp2_uri = URIRef(p.jp2_url)
    g.add((uri, ORE['aggregates'], jp2_uri))
    g.add((jp2_uri, DC['format'], Literal('image/jp2')))
    g.add((jp2_uri, EXIF['width'], Literal(p.jp2_width)))
    g.add((jp2_uri, EXIF['height'], Literal(p.jp2_length)))

    ocr_uri = URIRef(p.ocr_url)
    g.add((uri, ORE.aggregates, ocr_uri))
    g.add((ocr_uri, DC['format'], Literal('text/xml')))
   
    pdf_uri = URIRef(p.pdf_url)
    g.add((uri, ORE.aggregates, pdf_uri))
    g.add((pdf_uri, DC['format'], Literal('application/pdf')))

    txt_uri = URIRef(p.txt_url)
    g.add((uri, ORE.aggregates, txt_uri))
    g.add((txt_uri, DC['format'], Literal('text/plain')))

    thumb_uri = image_urls.thumb_image_url(p)
    g.add((uri, ORE.aggregates, thumb_uri))
    g.add((uri, FOAF.depiction, thumb_uri))
    g.add((thumb_uri, DC['format'], Literal('image/jpeg')))
    g.add((uri, DCTERMS['issued'], Literal(p.issue.date_issued, 
                                           datatype=XSD.date)))
    g.add((uri, DCTERMS['title'], Literal('%s - %s - %s' % 
        (p.issue.title.display_name, p.issue.date_issued, p.sequence))))

    if p.number:
        g.add((uri, NDNP['number'], Literal(p.number)))
    if p.section_label:
        g.add((uri, NDNP['section'], Literal(p.section_label)))

    add_rem(g, uri, rdf_uri(p))

    return g
예제 #2
0
파일: image_urls.py 프로젝트: edsu/open-oni
def thumb_image_url(page):
    return image_urls.thumb_image_url(page)