Building Bibliographic RDF Applications and Microservices

Creating a Knowledge Graph

What do we mean when we say "Knowledge Graph"?

One or more RDF graphs that represent an institution's "facts" or information modeled as relationships and entities as IRI

Manually with a Text Editor

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .

<http://intro2libsys.info/code4lib-2017> a schema:EducationEvent ;
    schema:endDate "2017-03-11T26:59:99" ;
    schema:superEvent <http://2017.code4lib.org/> ;
    schema:startDate "2017-03-11T20:00:00" . 



Programmatically with Python & rdflib

  1. (p3-env)> python
  2. Run Python in interactive mode:
    
    >> import rdflib
    >> SCHEMA = rdflib.Namespace("http://schema.org/")
    >> preconference = rdflib.ConjunctiveGraph()
    >> preconference_iri = rdflib.URIRef("http://intro2libsys.info/code4lib-2017")
    >> code4lib_2017 = rdflib.URIRef("http://2017.code4lib.org/")
    >> preconference.add((preconference_iri,
                          rdflib.RDF.type,
                          SCHEMA.EducationEvent))
    >> preconference.add((preconference_iri,
                          SCHEMA.startDate,
                          rdflib.Literal("2017-03-06T20:30:00")))
    >> prefconference.add((prefconference_iri,
                           SCHEMA.superEvent,
                           code4lib_2017))
                

Colorado College Example

Colorado College Logo

Base Knowledge Graph

RDF Applications and microservices use the base knowledge graph composed of colorado-college.ttl , cc-people.ttl, and cc-2016-2017.ttl all managed using Git and Github as part of the ongoing TIGER Catalog project.

Colorado College Knowledge Graph

Used in …

Colorado College

Colorado College ETD

Blazegraph Triplestore, Fedora 3.8, RDF Framework

This application allows seniors at Colorado College to self-submit their thesis along with any accompanying datasets, video, or audio to Colorado College's Fedora-based institutional repository.

Source Code Repository Live Application
  • Associate Theses with departments and people from CC's Knowledge Graph
  • Adds additional triples to configure RDF application in etd-2016-2017.ttl Turtle file
  • Stores associated IRIs of People, Institution, Departments in MODS metadata XML that is saved with the thesis datastreams in Colorado College's legacy Fedora 3.8 repository

Loading Colorado College's Knowledge Graph with Python

  1. (p3-env)> python
  2. Run Python in interactive mode:
    
    >>> import requests
    >>> TRIPLESTORE_URL = 'http://localhost:9999/blazegraph/sparql'
    >>> def setup_etd_knowledgegraph():
      	 cc_path = 'E:/2017/tiger-catalog/custom/'
     	 etd_path = "E:/2017/ccetd/custom/etd-2016-2017.ttl"
    	 for name in ["colorado-college.ttl",
    	 	      "cc-people.ttl",
    		      "cc-2016-2017.ttl"]:
    		 with open("{}/{}".format(cc_path, name), "rb") as fo:
    		    requests.post(TRIPLESTORE_URL,
    				  data=fo.read(),
    				  headers={"Content-Type": "text/turtle"})
    	 with open(etd_path, 'rb') as fo:
    	    requests.post(TRIPLESTORE_URL,
    	                  data=fo.read(),
    			  headers={"Content-Type": "text/turtle"})
    	 print("Finished")
    >>> setup_etd_knowledgegraph()
        Finished