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.
Temporarily install gem from github until it is released.
gem 'ld4l-works_rdf', :git => 'git@github.com:ld4l/works_rdf.git', :branch => 'master'
And then execute:
$ bundle
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.
*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.
item_metadata = LD4L::WorksRDF::AttemptGenericMetadataExtraction.call(uri)
If the URI is known to return marcxml, use the following service.
item_metadata = LD4L::WorksRDF::GetMetadataFromMarcxmlURI.call(uri)
If the URI is known to return schema.org ontology as interpreted by oclc, use the following service.
item_metadata = LD4L::WorksRDF::GetMetadataFromOclcURI.call(uri)
If the URI is known to return bibo ontology as interpreted by vivo, use the following service.
item_metadata = LD4L::WorksRDF::GetMetadataFromVivoURI.call(uri)
####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> .
The LD4L::WorksRDF gem provides model definitions using the ActiveTriples framework extension of ruby-rdf/rdf. The following models are provided:
- LD4L::WorksRDF::GenericWork - Reads triples into a graph without setting any properties.
- LD4L::WorksRDF::BibframeWork - Implements a work from the Bibframe ontology
- LD4L::WorksRDF::BibframeInstance - Implements an instance from the Bibframe ontology
- LD4L::WorksRDF::Bibframe* - Other supporting classes from Bibframe ontology
- LD4L::WorksRDF::BiboBook - Implements a BIBO Book
- LD4L::WorksRDF::BiboDocument - Implements a BIBO Document
- LD4L::WorksRDF::VivoBook - Implements VIVO extensions to BIBO Book
- LD4L::WorksRDF::Vivo* - Other supporting classes from the VIVO ontology
- LD4L::WorksRDF::SchemaBook - Implements a book from the schema ontology
- LD4L::WorksRDF::Schema* - Other supporting classes from the schema ontology
- LD4L::WorksRDF::OclcSchemaBook - Implements OCLC extensions to the schema Book
The listed ontologies are used to represent the primary metadata about the annotations. Other ontologies may also be used that aren't listed.
LD4L Virtual Collection engine
- Fork it ( https://github.com/[my-github-username]/ld4l-works_rdf/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request