Filtering BIBFRAME 2.0

All Processor classes have a source property that stores the data. Using the bf_rdf RDF graph from the marc2bibframe2 XSLT process as a triplestore parameter, we will create an instance of a SPARQLProcessor Python class and pass in a Python list made up of a RML Turtle file, loc-bf-to-lean-bf.ttl that is a RML mapping rule set included in bibcat.


>>> rml_processor = processor.SPARQLProcessor(
        triplestore=bf_rdf,
        rml_rules=['loc-bf-to-lean-bf.ttl'])

Next we will call the rml_processor.run method that takes the mapping rules and applies them to the source, in the case of the SPARQLProcessor class, the bf_rdf graph. For other RML Processor subclasses, the run method requires keyword parameters depending on what is found in the RML rules. The resulting RDF triples that are generated from the RML mapping during the run method execution is stored in a instance property called output.


>>> rml_processor.output
>>> rml_processor.run()
>>> rml_processor.output
)>
>>> len(rml_processor.output)
45

The new lean BIBFRAME graph has 45 triples verses the original source RDF graph that had 120 triples.

Now, we see the resulting lean BIBFRAME 2.0 graph by printing the rml_processor.output graph as turtle:


@prefix adms: <http://www.w3.org/ns/adms#> .
@prefix bc: <http://knowledgelinks.io/ns/bibcat/> .
@prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix kds: <http://knowledgelinks.io/ns/data-structures/> .
@prefix locn: <http://www.w3.org/ns/locn#> .
@prefix oslo: <http://purl.org/oslo/ns/localgov#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix relators: <http://id.loc.gov/vocabulary/relators/> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix schema: <http://schema.org/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/8383316#Instance> a bf:Instance ;
    rdfs:label "Pride and prejudice /" ;
    bf:dimensions "18 cm." ;
    bf:instanceOf <http://example.org/8383316#Work> ;
    bf:issuance <http://id.loc.gov/vocabulary/issuance/mono> ;
    bf:note [ a bf:Note ;
            rdfs:label "Series title also at head of t.-p." ] ;
    bf:provisionActivity [ a bf:ProvisionActivity,
                bf:Publication ;
            bf:date "c1918" ;
            bf:place "New York, Chicago [etc." ],
        [ a bf:ProvisionActivity,
                bf:Publication ;
            bf:date "1918"^^<http://id.loc.gov/datatypes/edtf> ;
            bf:place <http://id.loc.gov/vocabulary/countries/nyu> ] ;
    bf:provisionActivityStatement "New York, Chicago [etc.] : C. Scribner's sons, [c1918]" ;
    bf:responsibilityStatement "by Jane Austen; with an introduction by William Dean Howells" ;
    bf:title [ a bf:Title ;
            rdfs:label "Pride and prejudice /" ;
            bf:mainTitle "Pride and prejudice" ] .

<http://example.org/8383316#Work> a bf:Text,
        bf:Work ;
    bf:contribution [ a bf:Contribution ;
            bf:agent _:ub1bL38C22,
                <http://example.org/8383316#Agent100-11>,
                <http://example.org/8383316#Agent700-17> ;
            bf:role relators:ctb ],
        [ a bf:Contribution ;
            bf:agent _:ub1bL38C22,
                <http://example.org/8383316#Agent100-11>,
                <http://example.org/8383316#Agent700-17> ;
            bf:role relators:ctb ] .

<http://example.org/8383316#Agent100-11> a bf:Agent ;
    rdfs:label "Austen, Jane, 1775-1817." .

<http://example.org/8383316#Agent700-17> a bf:Agent ;
    rdfs:label "Howells, William Dean, 1837-1920." .

relators:ctb a bf:Role .

_:ub1bL38C22 a bf:Agent ;
    rdfs:label "C. Scribner's sons" .

This lean BIBFRAME can still reference and use the original Library of Congress because the subject URIs are the same. The reasoning behind this mapping is to simplify the BIBFRAME 2.0 mappings to other vocabularies and to tune the triplestore for performance.

Original contented Copyrighted © 2017 by Jeremy Nelson and KnowledgeLinks under Creative Commons License, Source code repository licensed under the Apache 2 and available on Github.