Class: Krikri::Enrichments::DcmiTypeMap
- Inherits:
-
Object
- Object
- Krikri::Enrichments::DcmiTypeMap
- Includes:
- Audumbla::FieldEnrichment
- Defined in:
- lib/krikri/enrichments/dcmi_type_map.rb
Overview
Maps string values to DCMI Type vocabulary terms.
Mapping is performed by comparing a hash of string keys to the pre-enriched value, using White Similarity comparisons to determine the closest match. If a suitable match is found, a DLPA::MAP::Controlled::DCMIType object is built from the appropriate hash value and set as the new value.
This enrichment ignores strings without a DCMI Type match.
Constant Summary collapse
- DEFAULT_MAP =
{ 'image' => RDF::DCMITYPE.Image, 'photograph' => RDF::DCMITYPE.Image, 'sample book' => RDF::DCMITYPE.Image, 'specimen' => RDF::DCMITYPE.Image, 'textile' => RDF::DCMITYPE.Image, 'frame' => RDF::DCMITYPE.Image, 'costume' => RDF::DCMITYPE.Image, 'statue' => RDF::DCMITYPE.Image, 'sculpture' => RDF::DCMITYPE.Image, 'container' => RDF::DCMITYPE.Image, 'jewelry' => RDF::DCMITYPE.Image, 'furnishing' => RDF::DCMITYPE.Image, 'furniture' => RDF::DCMITYPE.Image, 'drawing' => RDF::DCMITYPE.Image, 'print' => RDF::DCMITYPE.Image, 'painting' => RDF::DCMITYPE.Image, 'illumination' => RDF::DCMITYPE.Image, 'poster' => RDF::DCMITYPE.Image, 'appliance' => RDF::DCMITYPE.Image, 'tool' => RDF::DCMITYPE.Image, 'electronic component' => RDF::DCMITYPE.Image, 'postcard' => RDF::DCMITYPE.Image, 'equipment' => RDF::DCMITYPE.Image, 'cartographic' => RDF::DCMITYPE.Image, 'notated music' => RDF::DCMITYPE.Image, 'mixed material' => RDF::DCMITYPE.Image, 'text' => RDF::DCMITYPE.Text, 'book' => RDF::DCMITYPE.Text, 'publication' => RDF::DCMITYPE.Text, 'magazine' => RDF::DCMITYPE.Text, 'journal' => RDF::DCMITYPE.Text, 'correspondence' => RDF::DCMITYPE.Text, 'writing' => RDF::DCMITYPE.Text, 'written' => RDF::DCMITYPE.Text, 'manuscript' => RDF::DCMITYPE.Text, 'online text' => RDF::DCMITYPE.Text, 'audio' => RDF::DCMITYPE.Sound, 'sound' => RDF::DCMITYPE.Sound, 'oral history recording' => RDF::DCMITYPE.Sound, 'finding aid' => RDF::DCMITYPE.Collection, 'online collection' => RDF::DCMITYPE.Collection, 'electronic resource' => RDF::DCMITYPE.InteractiveResource, 'video game' => RDF::DCMITYPE.InteractiveResource, 'online exhibit' => RDF::DCMITYPE.InteractiveResource, 'moving image' => RDF::DCMITYPE.MovingImage, 'movingimage' => RDF::DCMITYPE.MovingImage, 'motion picture' => RDF::DCMITYPE.MovingImage, 'film' => RDF::DCMITYPE.MovingImage, 'video' => RDF::DCMITYPE.MovingImage, 'object' => RDF::DCMITYPE.PhysicalObject }
Instance Method Summary collapse
-
#enrich_value(value) ⇒ DPLA::MAP::Controlled::DCMIType?
The matching DCMI Type term.
-
#initialize(map = nil) ⇒ DcmiTypeMap
constructor
A new instance of DcmiTypeMap.
Constructor Details
#initialize(map = nil) ⇒ DcmiTypeMap
Returns a new instance of DcmiTypeMap.
82 83 84 |
# File 'lib/krikri/enrichments/dcmi_type_map.rb', line 82 def initialize(map = nil) @map = map || DEFAULT_MAP end |
Instance Method Details
#enrich_value(value) ⇒ DPLA::MAP::Controlled::DCMIType?
Returns the matching DCMI Type term. ‘nil` if no matches are found.
91 92 93 94 95 96 97 98 99 |
# File 'lib/krikri/enrichments/dcmi_type_map.rb', line 91 def enrich_value(value) return value unless value.is_a? String match = @map.fetch(value.downcase) { most_similar(value) } return value if match.nil? dcmi = DPLA::MAP::Controlled::DCMIType.new(match) dcmi.prefLabel = match.label dcmi end |