Module: Stanford::Mods::Searchworks
- Included in:
- Record
- Defined in:
- lib/stanford-mods/concerns/searchworks.rb
Instance Method Summary collapse
-
#catkey ⇒ String
Value with the catkey in it, or nil if none exists.
-
#format_main ⇒ Array[String]
select one or more format values from the controlled vocabulary per JVine Summer 2014 searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format_main_ssim&rows=0&facet.sort=index github.com/sul-dlss/stanford-mods/issues/66 - For geodata, the resource type should be only Map and not include Software, multimedia.
-
#sw_genre ⇒ Array[String]
Values for the genre facet in SearchWorks.
-
#sw_language_facet ⇒ Object
include langagues known to SearchWorks; try to error correct when possible (e.g. when ISO-639 disagrees with MARC standard).
Instance Method Details
#catkey ⇒ String
Returns value with the catkey in it, or nil if none exists.
118 119 120 121 122 |
# File 'lib/stanford-mods/concerns/searchworks.rb', line 118 def catkey catkey = term_values([:record_info, :recordIdentifier]) catkey.first&.tr('a', '') # remove prefix from SUL catkeys end |
#format_main ⇒ Array[String]
select one or more format values from the controlled vocabulary per JVine Summer 2014
http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format_main_ssim&rows=0&facet.sort=index
github.com/sul-dlss/stanford-mods/issues/66 - For geodata, the resource type should be only Map and not include Software, multimedia.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/stanford-mods/concerns/searchworks.rb', line 47 def format_main types = typeOfResource return [] unless types val = [] genres = term_values(:genre) || [] issuance = term_values([:origin_info, :issuance]) || [] frequency = term_values([:origin_info, :frequency]) || [] val << 'Dataset' if genres.include?('dataset') || genres.include?('Dataset') val << 'Archive/Manuscript' if types.any? { |t| t.manuscript == 'yes' } val.concat(types.flat_map do |type| case type.text when 'cartographic' 'Map' when 'mixed material' 'Archive/Manuscript' when 'moving image' 'Video' when 'notated music' 'Music score' when 'software, multimedia' 'Software/Multimedia' unless types.map(&:text).include?('cartographic') || (genres.include?('dataset') || genres.include?('Dataset')) when 'sound recording-musical' 'Music recording' when 'sound recording-nonmusical', 'sound recording' 'Sound recording' when 'still image' 'Image' when 'text' is_periodical = issuance.include?('continuing') || issuance.include?('serial') || frequency.any? { |x| !x.empty? } is_archived_website = genres.any? { |x| x.casecmp('archived website') == 0 } if is_periodical || is_archived_website [ ('Journal/Periodical' if is_periodical), ('Archived website' if is_archived_website) ].compact else 'Book' end when 'three dimensional object' 'Object' end end) val.compact.uniq end |
#sw_genre ⇒ Array[String]
Returns values for the genre facet in SearchWorks.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/stanford-mods/concerns/searchworks.rb', line 98 def sw_genre genres = term_values(:genre) return [] unless genres val = genres.map(&:to_s) thesis_pub = ['thesis', 'Thesis'] val << 'Thesis/Dissertation' if (genres & thesis_pub).any? conf_pub = ['conference publication', 'Conference publication', 'Conference Publication'] gov_pub = ['government publication', 'Government publication', 'Government Publication'] tech_rpt = ['technical report', 'Technical report', 'Technical Report'] val << 'Conference proceedings' if (genres & conf_pub).any? val << 'Government document' if (genres & gov_pub).any? val << 'Technical report' if (genres & tech_rpt).any? val.uniq end |
#sw_language_facet ⇒ Object
include langagues known to SearchWorks; try to error correct when possible (e.g. when ISO-639 disagrees with MARC standard)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/stanford-mods/concerns/searchworks.rb', line 8 def sw_language_facet mods_ng_xml.language.flat_map do |n| # get languageTerm codes and add their translations to the result result = n.code_term.flat_map do |ct| if ct..to_s =~ /^iso639/ vals = ct.text.split(/[,|\ ]/).reject { |x| x.strip.empty? } vals.select { |v| ISO_639.find(v.strip) }.map do |v| iso639_val = ISO_639.find(v.strip).english_name if SEARCHWORKS_LANGUAGES.has_value?(iso639_val) iso639_val else SEARCHWORKS_LANGUAGES[v.strip] end end else vals = ct.text.split(/[,|\ ]/).reject { |x| x.strip.empty? } vals.map do |v| SEARCHWORKS_LANGUAGES[v.strip] end end end # add languageTerm text values result.concat(n.text_term.map { |tt| tt.text.strip }.select { |val| !val.empty? && SEARCHWORKS_LANGUAGES.has_value?(val) }) # add language values that aren't in languageTerm subelement result << n.text if n.languageTerm.empty? && SEARCHWORKS_LANGUAGES.has_value?(n.text) result end.uniq end |