Linked Data Step 2

In Linked Data Step 1 I ended by saying that the next step was to perform reconciliation on selected object metadata terms and to add the resulting links to the object’s RDF output. In fact, looking at the RDF snippets given as examples, you can see that this was already done. The fields I reconciled were dc:creator, dc:subject and dc:spatial. To do this those terms were exported from all the objects contained in one collection and then imported as a project in OpenRefine. Using OpenRefine together with the RDF extension I reconciled these against DBpedia, LCSH (for subjects) and Linked Logainm (for places). The RDF extension allows you to build a skeleton (a template for the RDF output) for exporting to either RDF/XML or TTL. The exported RDF can then be imported to a SPARQL endpoint.

Here, for example, is the generated RDF output for a reconciled subject term, based on the skeleton that I defined:

<rdf:Description rdf:about="https://repository.dri.ie/resource/easter_rising_1916">
        <skos:exactMatch rdf:resource="http://id.loc.gov/authorities/sh85068025#concept"/>
        <skos:prefLabel xml:lang="en">Easter Rising 1916</skos:prefLabel>
        <rdfs:seeAlso rdf:resource="http://dbpedia.org/resource/Easter_Rising"/>
</rdf:Description>

You can see that the subject term value Easter Rising 1916 has been linked to an LCSH subject and a DBpedia entry. Now when you view the RDF format output of an object containing this value, you see the link to the RDF resource instead of the literal:

<https://repository.dri.ie/catalog/3b5918966#id>
dc:subject 
     <https://repository.dri.ie/resource/easter_rising_1916>,

When generating an object’s RDF output, RDF subject URIs are retrieved by the RDF formatter code by issuing a SPARQL query to the SPARQL endpoint.

def sparql_subject(value)
  Rails.cache.fetch(value, expires_in: 48.hours) do
    provider = DRI::Sparql::Provider::Sparql.new
    provider.endpoint = AuthoritiesConfig['data.dri.ie']['endpoint']

    triples = provider.retrieve_data([nil, 'skos:prefLabel', "\"#{value}\"@en"])

    triples.present? ? triples.first[0] : nil
  end
end

This method takes the literal value, e.g. ‘Easter Rising 1916’, and queries for the subject of a triple that has this value as a preferred label. If one is found, this is used in place of the literal value.

The final step then is to take the RDF output for each object in a collection, including the new reconciled URIs and import them into the SPARQL endpoint.