research_metadata_announcement

Metadata extraction from the Pure Research Information System and transformation of the metadata into an announcement.


Keywords
extraction, metadata, research, transformations
License
MIT
Install
gem install research_metadata_announcement -v 0.5.2

Documentation

ResearchMetadataAnnouncement

Metadata extraction from the Pure Research Information System and transformation of the metadata into an announcement.

Status

Gem Version Build Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'research_metadata_announcement'

And then execute:

$ bundle

Or install it yourself as:

$ gem install research_metadata_announcement

Usage

Configuration

Create a hash for passing to a transformer.

# Pure host with authentication.
config = {
  url:      ENV['PURE_URL'],
  username: ENV['PURE_USERNAME'],
  password: ENV['PURE_PASSWORD'],
}
# Pure host without authentication.
config = {
  url: ENV['PURE_URL']
}

Transformation

Create a metadata transformer for a Pure dataset.

transformer = ResearchMetadataAnnouncement::Transformer::Dataset.new config

Give it a Pure identifier and get an announcement.

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'

Optionally, use the :composition keyword argument to pass in an array of components (duplicates are ignored). The order of the components determines the order of the metadata in the announcement.

Possible components:

:new, :title, :keywords, :hashtags, :uri

Ideally, an announcement will be obtained using all the requested components, with the following exceptions:

  • If the composition includes :keywords or :hashtags and the resource does not have any descriptors, the metadata is simply omitted.

  • If the composition includes :uri, the resource must have a URI for an announcement to be returned.

  • If, after :title truncation/removal, the length still exceeds the optional :max_length keyword argument, an announcement will not be returned.

If the composition includes :new, a phrase based upon the resource type is generated e.g. New dataset. However, this gem does not determine whether the resource is deemed to be new.

Each example uses a different resource for illustrative purposes.

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
#=> "New publication. Can poly-parameter linear-free energy relationships (pp-LFERs) improve modelling bioaccumulation in fish? #partitioncoefficients #pplfer. dx.doi.org/10.1016/j.chemosphere.2017.10.007."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', max_length: 140
#=> "New publication. The Parting of Burroughs and... #americancounterculture #arthurrimbaud. dx.doi.org/10.1179/1477570013Z.00000000045."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :hashtags] # resource has no descriptors
#=> "New publication. Deductive and inductive data collection for agent-based modelling."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :keywords, :uri]
#=> "New publication. Torsion pairs in a triangulated category generated by a spherical object. Auslander–Reiten theory, Calabi–Yau triangulated category. dx.doi.org/10.1016/j.jalgebra.2015.09.011."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :uri]
#=> "New dataset. Operating Nanobeams in a Quantum Fluid. dx.doi.org/10.17635/lancaster/researchdata/139."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :title]
#=> "dx.doi.org/10.17635/lancaster/researchdata/29. Herpes simplex virus 1 (HSV-1) evolution."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:keywords, :uri]
#=> "smart cities, sustainability. dx.doi.org/10.17635/lancaster/researchdata/35."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:hashtags, :uri]
#=> "#treatedhypertension #microvascularbloodflow. dx.doi.org/10.17635/lancaster/researchdata/148."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :keywords]
#=> "dx.doi.org/10.17635/lancaster/researchdata/134. metagenomics, deep sequencing."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :hashtags], max_descriptors: 4
#=> "dx.doi.org/10.17635/lancaster/researchdata/111. #influenza #nasopharynx #virology #virus."