Building Bibliographic RDF Applications and Microservices

Ingesting Metadata

In this activity we will use different BIBCAT ingesters for three different vocabularies from different different formats. We will first use the MODSIngester Class wth an remote Islandora Repository along with a brief look at the IslandoraIngester a subclass of the OAIIngester Class, second we will work with ContentDM export of Dublin Core metadata with the DCIngester Class, and finally we will look at a CSV file of manually entered metadata to use the RowIngester Class.

Ingesting a Remote MODS File

  1. In an active Python session, import the requests module
    >>> import requests
    And import the MODSIngester Class
    >>> from bibcat.ingesters.mods import MODSIngester
  2. Using the requests.get method, retrieve the results of getting this URL from Colorado College's legacy Islandora repository: https://digitalcc.coloradocollege.edu/islandora/object/coccc:10797/datastream/MODS
    >>> mods_url = "https://digitalcc.coloradocollege.edu/islandora/object/coccc:10797/datastream/MODS"
    >>> mods_result = requests.get(mods_url)
    >>> mods_result.status_code
    200
    >>> mods_result.encoding = 'utf-8'
    >>> raw_xml = mods_result.text
    >>> print(raw_xml)
    <mods xmlns="http://www.loc.gov/mods/v3" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:schema="http://schema.org/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schema:itemtype="CreativeWork">
      <titleInfo>
        <title>Consumption treatment - Dr. Charles Fox Gardiner </title>
      </titleInfo>
      <titleInfo type="alternative">
        <title>Colorado Springs Century Chest Collection, 1901, Ms 0349, Folder 62, Consumption treatment - Dr. Charles Fox Gardiner </title>
      </titleInfo>
      <name type="personal">
        <namePart>Ehrich, Louis R., 1849-1911</namePart>
        <role>
          <roleTerm authority="marcrelator" type="text">contributor</roleTerm>
        </role>
      </name>
      <name type="personal">
        <namePart>Finley, Judith Reid, 1936-</namePart>
        <role>
          <roleTerm authority="marcrelator" type="text">contributor</roleTerm>
        </role>
      </name>
      <typeOfResource>mixed material</typeOfResource>
      <originInfo>
        <dateCreated keyDate="yes">1901</dateCreated>
        <publisher></publisher>
        <place>
          <placeTerm>Colorado Springs, Colorado</placeTerm>
        </place>
        <place>
          <placeTerm type="text"></placeTerm>
        </place>
        <dateIssued></dateIssued>
        <copyrightDate></copyrightDate>
        <dateOther></dateOther>
        <dateCaptured>2015</dateCaptured>
        <frequency></frequency>
      </originInfo>
      <abstract>Historic documentation of life at the turn of the 19th century created by residents of Colorado Springs, Colorado in 1901 for the citizens of 2001.  Under the direction of Louis R. Ehrich, a prominent 19th century businessman, the items were sealed in a chest which was stored in various buildings on the Colorado College campus until the official opening January 1, 2001 at the Charles Leaming Tutt Library.  Contents of Ms349, Fd 62, Consumption treatment - Dr. Charles Fox Gardiner include: 1 printed chart “Illustrating Dr. Charles Fox Gardiner’s Paper on Light and Air in the Treatment of Consumption in Colorado.”; 1 printed page “Diet List for Pulmonary Invalids with Fair Digestion” by Dr. Gardiner; 1 printed copy of article “Light and Air in the Treatment of Consumption in Colorado” by Dr. Gardiner, reprinted from The Medical News, July 22, 1899; 1 printed copy of “the Dangers of Tubercular Infection and Their Partial Arrest by Climatic Influences” by Dr. Gardiner, reprinted from The American Journal of the Medical Sciences, February, 1898; 1 b&w photo “Charles Fox Gardiner, M. D., aged 40 years.”; 1 5-page, handwritten letter, dated August 3, 1901, addressed “To My Professional Brothers of the Year 2001” signed by Charles Fox Gardiner, including genealogical information on backside of last page.  
    </abstract>
      <note type="admin">Title supplied by cataloger.</note>
      <language type="text">
        <languageTerm>English</languageTerm>
      </language>
      <genre authority="marcgt"></genre>
      <physicalDescription>
        <genre>letter</genre>
        <digitalOrigin>reformatted digital</digitalOrigin>
        <extent></extent>
        <form></form>
        <note></note>
      </physicalDescription>
      <subject>
        <topic>Time capsules</topic>
      </subject>
      <subject>
        <topic>History</topic>
      </subject>
      <subject>
        <topic>Correspondence</topic>
      </subject>
      <subject>
        <topic>Pictorial works</topic>
      </subject>
      <subject>
        <geographic>Colorado</geographic>
      </subject>
      <subject>
        <geographic>Colorado Springs (Colo.)</geographic>
      </subject>
      <accessCondition type="useAndReproduction"> Copyright restrictions apply. Contact Colorado College Special Collections for permission to publish.
    </accessCondition>
      <location>
        <url usage="primary display">http://hdl.handle.net/10176/coccc:10797</url>
      </location>
      <name type="personal">
        <namePart>Gardiner, Charles Fox, 1857-1947</namePart>
        <role>
          <roleTerm authority="marcrelator" type="text">creator</roleTerm>
        </role>
      </name>
      <name type="corporate">
        <namePart></namePart>
        <role>
          <roleTerm authority="marcrelator" type="text">creator</roleTerm>
        </role>
      </name>
      <name type="corporate">    
    <namePart></namePart>
        <role>
          <roleTerm authority="marcrelator" type="text">contributor</roleTerm> 
       </role>
      </name>
      <genre authority="marcgt">letter</genre>
      <genre authority="marcgt">picture</genre>
      <subject>
        <cartographics>
          <scale></scale>
        </cartographics>
      </subject>
      <subject>
        <cartographics>
          <coordinates></coordinates>
        </cartographics>
      </subject>
      <targetAudience></targetAudience>
      <note></note>
      <note type="admin">Alternative Title derived from Colorado Springs Century Chest Collection, 1901, Ms 0349 finding aid, January 23, 2015.</note>
      <note type="admin">Transcription of letter by Judith Reid Finley.</note>
      <note type="admin">Documents originally digitized in JPEG format. JPEG document files were converted to PDF format in 2015.</note>
      <note type="funding"></note>
      <subject>
        <topic>Medicine</topic>
      </subject>
      <subject>
        <topic>Tuberculosis</topic>
      </subject>
      <subject>
        <temporal>1901</temporal>
      </subject>
      <subject>
        <name type="personal">
          <namePart></namePart>
        </name>
      </subject>
      <subject>
        <name type="personal">
          <namePart>Gardiner, Charles Fox, 1857-1947</namePart>
        </name>
      </subject>
      <subject>
        <name type="personal">
          <namePart>Ehrich, Louis R., 1849-1911</namePart>
        </name>
      </subject>
      <subject>
        <name type="corporate">
          <namePart></namePart>
        </name>
      </subject>
      <subject>
        <genre></genre>
      </subject>
      <relatedItem type="host">
        <titleInfo>
          <title>Colorado Springs Century Chest Collection, 1901</title>
        </titleInfo>
      </relatedItem>
      <relatedItem type="constituent">
        <titleInfo>
          <title></title>
        </titleInfo>
      </relatedItem>
      <relatedItem type="series">
        <titleInfo>
          <title></title>
        </titleInfo>
      </relatedItem>
      <relatedItem type="preceding">
        <titleInfo>
          <title></title>
        </titleInfo>
      </relatedItem>
      <relatedItem type="succeeding">
        <titleInfo>
          <title></title>
        </titleInfo>
      </relatedItem>
      <identifier type="local">Ms 0349, Fd 62</identifier>
      <identifier type="isbn"></identifier>
      <identifier type="issn"></identifier>
      <recordInfo>
        <languageOfCataloging>
          <languageTerm authority="iso639-2b" type="text">English</languageTerm>
          <languageTerm authority="iso639-2b" type="code">eng</languageTerm>
        </languageOfCataloging>
      </recordInfo>
    </mods>
    
        
  3. Create a MODSIngester Class instance using the default MODS rules
    >>> mods_ingester = MODSIngester()
    Use https://digitalcc.coloradocollege.edu/islandora/object/coccc:10797/ as the item_iri
    >>> item_iri = rdflib.URIRef("https://digitalcc.coloradocollege.edu/islandora/object/coccc:10797/")
  4. Transform the raw_xml with theitem_iri
    >>> mods_ingester.transform(xml=raw_xml, item_uri=item_iri)
  5. Print the serialized mods_ingester.graph in Turtle format
    >>> print(mods_ingester.graph.serialize(format='turtle').decode())
    @prefix bc: <http://knowledgelinks.io/ns/bibcat/> .
    @prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
    @prefix kds: <http://knowledgelinks.io/ns/data-structures/> .
    @prefix loc: <http://id.loc.gov/authorities/> .
    @prefix m21: <http://knowledgelinks.io/ns/marc21/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @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 schema: <http://schema.org/> .
    @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
    @prefix void: <http://rdfs.org/ns/void#> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <https://digitalcc.coloradocollege.edu/islandora/object/coccc:10797/> a bf:Item ;
        bf:electronicLocation <http://hdl.handle.net/10176/coccc:10797> ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T17:01:55.320898" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:itemOf <http://bibcat.org/6ee82e34-01c5-11e7-9ebd-ac87a3129ce6> .
    
    <http://bibcat.org/6ee82e34-01c5-11e7-9ebd-ac87a3129ce6> a bf:Instance ;
        bf:contributor <http://bibcat.org/6fc909c2-01c5-11e7-9248-ac87a3129ce6>,
            <http://bibcat.org/6fccc5da-01c5-11e7-876d-ac87a3129ce6> ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T17:01:55.285548" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:genreForm [ a bf:GenreForm ;
                rdf:value "picture" ],
            [ a bf:GenreForm ;
                rdf:value "letter" ] ;
        bf:instanceOf [ a bf:Work ;
                bf:geographicCoverage "Colorado",
                    "Colorado Springs (Colo.)" ;
                bf:originPlace "Colorado Springs, Colorado" ] ;
        bf:language [ a bf:Language ;
                rdf:value "English" ] ;
        bf:note [ a bf:Note ;
                bf:noteType "admin"@en ;
                rdf:value "Title supplied by cataloger." ],
            [ a bf:Note ;
                bf:noteType "admin"@en ;
                rdf:value "Documents originally digitized in JPEG format. JPEG document files were converted to PDF format in 2015." ],
            [ a bf:Note ;
                bf:noteType "admin"@en ;
                rdf:value "Alternative Title derived from Colorado Springs Century Chest Collection, 1901, Ms 0349 finding aid, January 23, 2015." ],
            [ a bf:Note ;
                bf:noteType "admin"@en ;
                rdf:value "Transcription of letter by Judith Reid Finley." ] ;
        bf:provisionActivity [ a bf:Publication ;
                bf:Publisher [ a bf:Organization ] ] ;
        bf:subject [ a bf:Topic ;
                rdf:value "Pictorial works" ],
            [ a bf:Topic ;
                rdf:value "Time capsules" ],
            [ a bf:Topic ;
                rdf:value "Medicine" ],
            [ a bf:Temporal ;
                rdf:value "1901" ],
            [ a bf:Topic ;
                rdf:value "Correspondence" ],
            [ a bf:Topic ;
                rdf:value "Tuberculosis" ],
            [ a bf:Topic ;
                rdf:value "History" ],
            <http://bibcat.org/6fc909c2-01c5-11e7-9248-ac87a3129ce6>,
            <http://bibcat.org/6fce77cc-01c5-11e7-b3b6-ac87a3129ce6> ;
        bf:summary [ a bf:Summary ;
                rdf:value """Historic documentation of life at the turn of the 19th century created by residents of Colorado Springs, Colorado in 1901 for the citizens of 2001.  Under the direction of Louis R. Ehrich, a prominent 19th century businessman, the items were sealed in a chest which was stored in various buildings on the Colorado College campus until the official opening January 1, 2001 at the Charles Leaming Tutt Library.  Contents of Ms349, Fd 62, Consumption treatment - Dr. Charles Fox Gardiner include: 1 printed chart “Illustrating Dr. Charles Fox Gardiner’s Paper on Light and Air in the Treatment of Consumption in Colorado.”; 1 printed page “Diet List for Pulmonary Invalids with Fair Digestion” by Dr. Gardiner; 1 printed copy of article “Light and Air in the Treatment of Consumption in Colorado” by Dr. Gardiner, reprinted from The Medical News, July 22, 1899; 1 printed copy of “the Dangers of Tubercular Infection and Their Partial Arrest by Climatic Influences” by Dr. Gardiner, reprinted from The American Journal of the Medical Sciences, February, 1898; 1 b&w photo “Charles Fox Gardiner, M. D., aged 40 years.”; 1 5-page, handwritten letter, dated August 3, 1901, addressed “To My Professional Brothers of the Year 2001” signed by Charles Fox Gardiner, including genealogical information on backside of last page.  
    """ ] ;
        bf:title [ a bf:VarientTitle ;
                bf:mainTitle "Colorado Springs Century Chest Collection, 1901, Ms 0349, Folder 62, Consumption treatment - Dr. Charles Fox Gardiner " ],
            [ a bf:InstanceTitle ;
                bf:mainTitle "Colorado Springs Century Chest Collection, 1901, Ms 0349, Folder 62, Consumption treatment - Dr. Charles Fox Gardiner " ],
            [ a bf:InstanceTitle ;
                bf:mainTitle "Consumption treatment - Dr. Charles Fox Gardiner " ] ;
        relators:cre <http://bibcat.org/6fce77cc-01c5-11e7-b3b6-ac87a3129ce6> .
    
    <http://bibcat.org/6fccc5da-01c5-11e7-876d-ac87a3129ce6> a bf:Person ;
        rdfs:label "Finley, Judith Reid, 1936-" .
    
    <http://bibcat.org/6fc909c2-01c5-11e7-9248-ac87a3129ce6> a bf:Person ;
        rdfs:label "Ehrich, Louis R., 1849-1911" .
    
    <http://bibcat.org/6fce77cc-01c5-11e7-b3b6-ac87a3129ce6> a bf:Person ;
        rdfs:label "Gardiner, Charles Fox, 1857-1947" .
    
        

Islandora OAI-PMH Ingester

  1. Import the IslandoraIngester Class the oai_pmh Module
    >>> from bibcat.ingesters.oai_pmh import IslandoraIngester
  2. We will use the Colorado State Publications Library's repository at http://hermes.cde.state.co.us/drupal/ when creating an IslandoraIngester instance.
    >>> islandora_ingester = IslandoraIngester(repository="http://hermes.cde.state.co.us/drupal/")
  3. The OAIPMHIngester is the parent class of the IslandoraIngester and has an important method harvest that interacts with the OAI PMH feed from a respository. The harvest method takes an optional parameters, sample_size that if it has a value, a random sample will be generated instead of trying to ingest the entire repository. We will now run the harvest method with a sample size of 150
    >>> islandora_ingester.harvest(sample_size=150)
    Starting OAI-PMH harvest of PIDS from Islandora at 2017-03-06 14:53:04.403323
    Started Retrieval of 19961 Identifiers 2017-03-06 14:53:04.882095
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ................................................................................
    ......................................Sample size 150 identifiers size 150
    
    Finished at 2017-03-06 15:00:37.658774, total time 7.533333333333333 minutes
    0..........100....Islandora OAI-PMH harvested at 2017-03-06 15:04:18.372195, 
    total time 11.216666666666667 mins.
        
    The IslandoraIngester automatically pushes each record to the Triplestore.
  4. Future plans for include deriving three child classes of OAIPMHIngester; a ContentDM ingester, a LibGuides ingester, and an ingester for Hydra based systems.

Ingesting Dublin Core RDF

  1. Download the dpl-dc-example.xml and save in a new input directory in your /tmp/rdf-app
  2. In your Python session, open and load the contents into a dc_raw variable
    >>> with open("input/dpl-dc-example.xml") as fo:
        dc_raw = fo.read()
        
  3. Import the DCIngester from the dc module
    >>> from bibcat.ingesters.dc import DCIngester
    Create an instance of DCIngester using the default kds-bibcat-dc-ingestion.ttl RDF Ingestion rules.
    >>> dc_ingester = DCIngester()
  4. Transform the dc_raw RDF XML into BIBFRAME
    >>> dc_ingester.transform(xml=dc_xml)
    Display the serialized Turtle from dc_ingester.graph output graph:
    >>> print(dc_ingester.graph.serialize(format='turtle').decode())
    @prefix bc: <http://knowledgelinks.io/ns/bibcat/> .
    @prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
    @prefix kds: <http://knowledgelinks.io/ns/data-structures/> .
    @prefix loc: <http://id.loc.gov/authorities/> .
    @prefix m21: <http://knowledgelinks.io/ns/marc21/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @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 schema: <http://schema.org/> .
    @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
    @prefix void: <http://rdfs.org/ns/void#> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    
    
    <http://cdm16079.contentdm.oclc.org:80/cdm/ref/collection/p15330coll22/id/0> a bf:Item ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T21:21:10.100396" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:itemOf <http://bibcat.org/a6c8ca92-01e9-11e7-a39a-a8667f19014b> ;
        bf:usageAndAccessPolicy [ a bf:UsePolicy ;
                rdf:value "Restrictions applying to use or reproduction of this image available from the Western History/Genealogy Dept., Denver Public Library." ] .
    
    <http://bibcat.org/a6c8ca92-01e9-11e7-a39a-a8667f19014b> a bf:Instance ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T21:21:10.005478" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:identifiedBy [ a bf:Local ;
                rdf:value """NS-850
    
    00105850.tif""" ] ;
        bf:instanceOf [ a bf:Work ;
                bf:originDate "[1901?]" ] ;
        bf:language [ a bf:Language ;
                rdf:value "eng" ] ;
        bf:layout [ a bf:Layout ;
                rdf:value """1 photoprint ; 15 x 24 cm. (5 3/4 x 9 1/2 in.)
    Photograph""" ] ;
        bf:note [ a bf:Note ;
                rdf:value """Members of Buffalo Bill's Wild West Show band ride horses down a dirt street during a parade for the show. The men are playing their instruments while riding horses. Among the instruments being played is a trombone, a trumpet and the drums. A group of soldiers on horseback follows the band in the parade. The men are members of "Buffalo Bill's Congress of Rough Riders of the World." A large crowd of spectators watches  the parade. The men in the crowd wear derby hats while the women wear hats  adorned with flowers. The young boys wear caps and knickers.
    "Salsbury Collection Buffalo Bill's Wild West Show Rehearsal Pictures 1901" typed on first page of album.; Photographer's stamp "Photographed by John C. Hemment, 108 Fulton St., New York" on back of photoprint; "Parade" and "1901" handwritten on back of print.; Photoprint has "173" handwritten in lower left side and on back.; Photoprint has orange discoloration and is faded.; Title supplied by cataloger.; Vintage photographic print.; R7001058501""" ] ;
        bf:partOf [ a pcdm:Collection ;
                rdfs:label """Salsbury collection, Buffalo Bill's Wild West Show.; Salsbury collection, Buffalo Bill's Wild West Show, album 8.
    Image File: ZZR700105850
    
    http://photoswest.org/cgi-bin/imager?00105850+NS-850""" ] ;
        bf:subject [ a bf:Topic ;
                rdf:value "Wild west shows--1880-1920.; Bands--1900-1910.; Parades & processions--1900-1910.; Buffalo Bill, 1846-1917.; Buffalo Bill's Wild West Show." ] ;
        bf:title [ a bf:InstanceTitle ;
                bf:mainTitle "Wild West Show parade" ] .
    
        

Ingesting a Comma-separated-value (csv) File

  1. The RowIngester Class located in the csv module takes a row from a csv.DictReader and ingests into BIBFRAME 2.0. Since the default RDF Rules file is empty, we will need to create all of the rules for each column in our csv input. Download a sample csv file here.
    Open your text editor and paste in the following @prefix namespaces.
    
    @prefix bc: <http://knowledgelinks.io/ns/bibcat/> .
    @prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
    @prefix kds: <http://knowledgelinks.io/ns/data-structures/> .
    @prefix kdr: <http://knowledgelinks.io/ns/data-resources/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    @prefix relators: <http://id.loc.gov/vocabulary/relators/> .
    @prefix m21: <http://knowledgelinks.io/ns/marc21/> .
    @prefix schema: <http://schema.org/> .
    @prefix loc: <http://id.loc.gov/authorities/> .
        
  2. Add a rule to map values in title column to the bf:InstanceTitle
    
    bc:csv-Title a kds:PropertyLinker ;
        kds:srcPropKey "title" ;
        kds:destPropUri bf:mainTitle;
        kds:destClassUri bf:InstanceTitle;
        kds:linkedRange bf:title;
        kds:linkedClass bf:Instance . 
    
        
  3. Add a rule for the author column. We will use two new predicates, the kds:delimiterProp and the kds:hasIndividualNodes. The kds:delimiterProp takes a character that will break up the csv cell value into separate values. The kds:hasIndividualNodes indicates to the ingester that the each value is a blank node and not different objects associated with the same RDF subject and predicate.
    
    bc:csv-author a kds:PropertyLinker ;
        kds:srcPropKey "author" ;
        kds:hasIndividualNodes "true" ;
        kds:destClassUri bf:Person ;
        kds:destPropUri rdfs:label ;
        kds:linkedRange relators:cre ;
        kds:linkedClass bf:Instance .
        
  4. Add the final two rules for the barcode and subjects columns. First the barcode RDF rule:
    
    bc:csv-barcode a kds:PropertyLinker;
        kds:srcPropKey "barcode" ;
        kds:destPropUri rdf:value ;
        kds:destClassUri bf:Barcode ;
        kds:linkedRange bf:barcode ;
        kds:linkedClass bf:Item .
        
    And the subjects RDF rule with a kds:delimiterProp and kds:hasIndividualNodes triples
    
    bc:csv-subjects a kds:PropertyLinker ;
        kds:srcPropKey "subjects" ;
        kds:delimiterProp ";" ;
        kds:hasIndividualNodes "true" ; 
        kds:destClassUri bf:Topic ;
        kds:destPropUri rdf:value ;
        kds:linkedRange bf:subject ;
        kds:linkedClass bf:Instance .
        
  5. Save your RDF Turtle Rules file as custom/cc-csv.ttl.
  6. Import csv
    >>> import csv
    And the RowIngester Class
    >>> from bibcat.ingesters.csv import RowIngester
  7. Create an instance of RowIngester Class including the cc-csv.ttl Rules file with the rules_ttl keyword parameter
    >>> row_ingester = RowIngester(rules_ttl='cc-csv.ttl')
  8. Create an instance of the DictReader using the sample csv file as the file object
    >>> csv_reader = csv.DictReader(open("input/cc_sample.csv"))
    Retrieve, save, and display the first row
    >>> first_row = next(csv_reader)
    >>> from pprint import pprint
    >>> pprint(first_row)
    {'author': 'Gilson, Etienne, 1884-1978.',
     'barcode': '33027001257140',
     'subjects': 'Augustine, Saint, Bishop of Hippo.;God',
     'title': 'The Christian philosophy of Saint Augustine.'}
        
  9. Transform the first_row with the row_ingester.transform method
    >>> row_ingester.transform(first_row)
  10. Display the row_ingester.graph in Turtle format
    >>> print(row_ingester.graph.serialize(format='turtle').decode())
    @prefix bc: <http://knowledgelinks.io/ns/bibcat/> .
    @prefix bf: <http://id.loc.gov/ontologies/bibframe/> .
    @prefix kds: <http://knowledgelinks.io/ns/data-structures/> .
    @prefix loc: <http://id.loc.gov/authorities/> .
    @prefix m21: <http://knowledgelinks.io/ns/marc21/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @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 schema: <http://schema.org/> .
    @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
    @prefix void: <http://rdfs.org/ns/void#> .
    @prefix xml: <http://www.w3.org/XML/1998/namespace> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <http://bibcat.org/42f53fd0-01ff-11e7-8b2f-a8667f19014b> a bf:Item ;
        bf:barcode [ a bf:Barcode ;
                rdf:value "33027001257140" ] ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T23:55:51.062608" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:itemOf <http://bibcat.org/41caa9ba-01ff-11e7-bfa4-a8667f19014b> .
    
    <http://bibcat.org/41caa9ba-01ff-11e7-bfa4-a8667f19014b> a bf:Instance ;
        bf:generationProcess [ a bf:GenerationProcess ;
                bf:generationDate "2017-03-05T23:55:50.974360" ;
                rdf:value "Generated by BIBCAT version 1.7.5 from KnowledgeLinks.io"@en ] ;
        bf:subject [ a bf:Topic ;
                rdf:value "God" ],
            [ a bf:Topic ;
                rdf:value "Augustine, Saint, Bishop of Hippo." ] ;
        bf:title [ a bf:InstanceTitle ;
                bf:mainTitle "The Christian philosophy of Saint Augustine." ] ;
        relators:cre [ a bf:Person ;
                rdfs:label "Gilson, Etienne, 1884-1978." ] .
    
        

Used in …

Plains2Peaks.org - DPLA Service Hub for Colorado/Wyoming
Blazegraph Triplestore, RDF Framework, BIBCAT

A State Library of Colorado sponsored effort to aggregate the metadata from across different libraries and museums in Colorado and Wyoming and provide a JSON-LD DPLA Map v4 feed to DP.LA.

Source Code Repository Live Application