LD4L::WorksRDF

Build Status Coverage Status Gem Version Dependency Status

The primary purpose of this gem is the extraction of basic display metadata from rdf triples for use in a user interface. It is assumed that if detailed metadata is required, the user will be redirected back to the original source.

This is a catch all gem to process metadata coming from library works. It can process marcxml and rdf+mxl of selected ontologies. It is expected that it will grow and be refined to be more robust and flexible over time as more ontologies are identified and various interpretations of ontologies is accounted for in the processing code.

Installation

Temporarily install gem from github until it is released.

gem 'ld4l-works_rdf', :git => '[email protected]:ld4l/works_rdf.git', :branch => 'master'

And then execute:

$ bundle

Usage

Caveat: This rails engine is part of the LD4L Project and is being used in that context. There is no guarantee that the code will work in a usable way outside of its use in LD4L Use Cases.

Examples

*Common setup for all examples

require 'ld4l/works_rdf'

If the ontology is unknown, you can try all known methods by calling the generic metadata extraction service.

 = LD4L::WorksRDF::AttemptGenericMetadataExtraction.call(uri)

If the URI is known to return marcxml, use the following service.

 = LD4L::WorksRDF::GetMetadataFromMarcxmlURI.call(uri)

If the URI is known to return schema.org ontology as interpreted by oclc, use the following service.

 = LD4L::WorksRDF::GetMetadataFromOclcURI.call(uri)

If the URI is known to return bibo ontology as interpreted by vivo, use the following service.

 = LD4L::WorksRDF::GetMetadataFromVivoURI.call(uri)

Configuration

Example configuration and usage for base_uri and default localname_minter

LD4L::WorksRDF.reset
LD4L::WorksRDF.configure do |config|
  config.base_uri = "http://example.org/"
end

w = LD4L::WorksRDF::GenericWork.new(ActiveTriples::LocalName::Minter.generate_local_name(
              LD4L::WorksRDF::GenericWork, 10, {:prefix=>'w'} ))

puts w.dump :ttl

w = LD4L::WorksRDF::GenericWork.new(ActiveTriples::LocalName::Minter.generate_local_name(
              LD4L::WorksRDF::GenericWork, 10, {:prefix=>'w'},
              &LD4L::WorksRDF.configuration.localname_minter ))

puts w.dump :ttl

NOTE: If base_uri is not used, you need to restart your interactive environment (e.g. irb, pry). Once the GenericWork class is instantiated the first time, the base_uri for the class is set. If you ran through the main Examples, the base_uri was set to the default base_uri.

Example triples created for a generic work with configured base_uri and default minter

<http://example.org/w45c9c85b-25af-4c52-96a4-cf0d8b70a768> a <http://schema.org/schema:Book> .

Example configuration and usage for base_uri and configured localname_minter

LD4L::WorksRDF.configure do |config|
  config.base_uri = "http://example.org/"
  config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
end

w = LD4L::WorksRDF::GenericWork.new(ActiveTriples::LocalName::Minter.generate_local_name(
              LD4L::WorksRDF::GenericWork, 10, 'w',
              &LD4L::WorksRDF.configuration.localname_minter ))

puts w.dump :ttl

NOTE: If base_uri is not used, you need to restart your interactive environment (e.g. irb, pry). Once the GenericWork class is instantiated the first time, the base_uri for the class is set. If you ran through the main Examples, the base_uri was set to the default base_uri.

Example triples created for a person with configured base_uri and configured minter.

<http://example.org/w_configured_6498ba05-8b21-4e8c-b9d4-a6d5d2180966> a <http://schema.org/schema:Book> .

Models

The LD4L::WorksRDF gem provides model definitions using the ActiveTriples framework extension of ruby-rdf/rdf. The following models are provided:

  1. LD4L::WorksRDF::GenericWork - Reads triples into a graph without setting any properties.
  2. LD4L::WorksRDF::BibframeWork - Implements a work from the Bibframe ontology
  3. LD4L::WorksRDF::BibframeInstance - Implements an instance from the Bibframe ontology
  4. LD4L::WorksRDF::Bibframe* - Other supporting classes from Bibframe ontology
  5. LD4L::WorksRDF::BiboBook - Implements a BIBO Book
  6. LD4L::WorksRDF::BiboDocument - Implements a BIBO Document
  7. LD4L::WorksRDF::VivoBook - Implements VIVO extensions to BIBO Book
  8. LD4L::WorksRDF::Vivo* - Other supporting classes from the VIVO ontology
  9. LD4L::WorksRDF::SchemaBook - Implements a book from the schema ontology
  10. LD4L::WorksRDF::Schema* - Other supporting classes from the schema ontology
  11. LD4L::WorksRDF::OclcSchemaBook - Implements OCLC extensions to the schema Book

Ontologies

The listed ontologies are used to represent the primary metadata about the annotations. Other ontologies may also be used that aren't listed.

Known Uses

LD4L Virtual Collection engine

Contributing

  1. Fork it ( https://github.com/[my-github-username]/ld4l-works_rdf/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request