Class: PennMARC::Creator
- Defined in:
- lib/pennmarc/helpers/creator.rb
Overview
can there ever be multiple 100 fields? can ǂe and ǂ4 both be used at the same time? seems to result in duplicate values
Do Creator & Author field processing. Main methods pull from 110 and 111 fields. Display methods here no longer return data structures intended for generating “search” links, but some of the split subfield parsing remains from ported methods in case we need to replicate that functionality.
Constant Summary collapse
- TAGS =
Main tags for Author/Creator information
%w[100 110].freeze
- AUX_TAGS =
Aux tags for Author/Creator information, for use in search_aux method
%w[100 110 111 400 410 411 700 710 711 800 810 811].freeze
Class Method Summary collapse
-
.conference_detail_show(record) ⇒ Array<String>
Conference detailed display, intended for record show page.
- .conference_search(record) ⇒ Object
-
.conference_show(record, relator_map: Mappers.relator) ⇒ Array<String>
Conference for display, intended for results display.
- .contributor_show(record, relator_map: Mappers.relator) ⇒ Array<String>
-
.facet(record) ⇒ Array<String>
Author/Creator for faceting.
-
.search(record, relator_map: Mappers.relator) ⇒ Array<String>
Author/Creator search field.
-
.search_aux(record) ⇒ Array<String>
Auxiliary Author/Creator search field.
-
.show(record) ⇒ Array<String>
Author/Creator values for display.
-
.sort(record) ⇒ String
Author/Creator sort.
-
.values(record, relator_map: Mappers.relator) ⇒ Array<String>
All author/creator values for display (like #show, but multivalued?) - no 880 linkage.
Methods included from Util
#datafield_and_linked_alternate, #join_and_squish, #join_subfields, #linked_alternate, #linked_alternate_not_6_or_8, #prefixed_subject_and_alternate, #remove_paren_value_from_subfield_i, #subfield_defined?, #subfield_in?, #subfield_not_in?, #subfield_undefined?, #subfield_value?, #subfield_value_in?, #subfield_value_not_in?, #subfield_values, #subfield_values_for, #substring_after, #substring_before, #translate_relator, #trim_trailing, #valid_subject_genre_source_code?
Class Method Details
.conference_detail_show(record) ⇒ Array<String>
what is ǂi for?
ported from get_conference_values
Conference detailed display, intended for record show page.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/pennmarc/helpers/creator.rb', line 160 def conference_detail_show(record) values = record.fields(%w[111 711]).filter_map do |field| next unless field.indicator2.in? ['', ' '] conf = if subfield_undefined? field, 'i' join_subfields field, &subfield_not_in?(%w[0 4 5 6 8 e j w]) else '' end conf_extra = join_subfields field, &subfield_in?(%w[e j w]) join_and_squish [conf, conf_extra].compact_blank end values + record.fields('880').filter_map do |field| next unless subfield_value_in? field, '6', %w[111 711] next if subfield_defined? field, 'i' conf = join_subfields(field, &subfield_not_in?(%w[0 4 5 6 8 e j w])) conf_extra = join_subfields(field, &subfield_in?(%w[4 e j w])) join_and_squish [conf, conf_extra] end end |
.conference_search(record) ⇒ Object
this supports “Conference” fielded search and may not be needed
see get_conference_search_values
185 |
# File 'lib/pennmarc/helpers/creator.rb', line 185 def conference_search(record); end |
.conference_show(record, relator_map: Mappers.relator) ⇒ Array<String>
ported from get_conference_values
Conference for display, intended for results display
149 150 151 152 153 |
# File 'lib/pennmarc/helpers/creator.rb', line 149 def conference_show(record, relator_map: Mappers.relator) record.fields('111').filter_map do |field| name_from_main_entry field, relator_map end end |
.contributor_show(record, relator_map: Mappers.relator) ⇒ Array<String>
legacy version returns array of hash objects including data for display link
Retrieve contributor values for display from fields 700 and 710 and their linked alternates. Joins subfields ‘a’, ‘b’, ‘c’, ‘d’, ‘j’, and ‘q’. Then appends resulting string with joined subfields ‘e’, ‘u’, ‘3’, and ‘4’. @ param [Hash] relator_map
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/pennmarc/helpers/creator.rb', line 194 def contributor_show(record, relator_map: Mappers.relator) = ['', ' ', '0'] contributors = record.fields(%w[700 710]).filter_map do |field| next unless .member?(field.indicator2) next if subfield_defined? field, 'i' contributor = join_subfields(field, &subfield_in?(%w[a b c d j q])) contributor_append_subfields = %w[e u 3 4] contributor_append = field.filter_map { |subfield| next unless contributor_append_subfields.member?(subfield.code) if subfield.code == '4' ", #{translate_relator(subfield.value, relator_map)}" else " #{subfield.value}" end }.join "#{contributor} #{contributor_append}".squish end contributors + record.fields('880').filter_map do |field| next unless subfield_value_in?(field, '6', %w[700 710]) next if subfield_defined?(field, 'i') contributor = join_subfields(field, &subfield_in?(%w[a b c d j q])) contributor_append = join_subfields(field, &subfield_in?(%w[e u 3])) "#{contributor} #{contributor_append}".squish end end |
.facet(record) ⇒ Array<String>
should trim_punctuation apply to each subfield value, or the joined values? i think the joined values
ported from author_creator_xfacet2_input - is this the best choice? check the copyField declarations - franklin uses author_creator_f
Author/Creator for faceting. Grabs values from a plethora of fields, joins defined subfields, then trims some punctuation (@see trim_punctuation)
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/pennmarc/helpers/creator.rb', line 131 def facet(record) source_map = { 100 => 'abcdjq', 110 => 'abcdjq', 111 => 'abcen', 700 => 'abcdjq', 710 => 'abcdjq', 711 => 'abcen', 800 => 'abcdjq', 810 => 'abcdjq', 811 => 'abcen' } source_map.flat_map do |field_num, subfields| record.fields(field_num.to_s).map do |field| trim_punctuation(join_subfields(field, &subfield_in?(subfields.chars))) end end end |
.search(record, relator_map: Mappers.relator) ⇒ Array<String>
this seems bad - why include relator labels? URIs? punctuation? leaving mostly as-is for now, but this should be reexamined in the relevancy-tuning phase. URIs should def be removed. and shouldn’t indicator1 tell us the order of the name?
ported from get_author_creator_1_search_values
Author/Creator search field. Includes all subfield values (even ǂ0 URIs) from 100 Main Entry–Personal Name and 110 Main Entry–Corporate Name. Maps any relator codes found in ǂ4. To better handle name searches, returns names as both “First Last” and “Last, First” if a comma is found in ǂa. Also indexes any linked values in the 880. Some of the search fields remain incomplete and may need to be further investigated and ported when search result relevancy is considered.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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 |
# File 'lib/pennmarc/helpers/creator.rb', line 29 def search(record, relator_map: Mappers.relator) creator_subfields = %w[a 1 4 6 8] acc = record.fields(TAGS).map do |field| pieces = field.filter_map do |sf| if sf.code == 'a' convert_name_order(sf.value) elsif creator_subfields.exclude?(sf.code) sf.value elsif sf.code == '4' relator = translate_relator(sf.value, relator_map) next if relator.blank? relator end end value = join_and_squish(pieces) if value.end_with?('.', '-') value else "#{value}." end end # a second iteration over the same fields produces name entries with the names not reordered secondary_subfields = %w[4 6 8] acc += record.fields(TAGS).map do |field| pieces = field.filter_map do |sf| if secondary_subfields.exclude?(sf.code) sf.value elsif sf.code == '4' relator = translate_relator(sf.value, relator_map) next if relator.blank? relator end end value = join_and_squish(pieces) if value.end_with?('.', '-') value else "#{value}." end end acc += record.fields(%w[880]).filter_map do |field| next unless field.any? { |sf| sf.code == '6' && sf.value.in?(%w[100 110]) } suba = field.find_all(&subfield_in?(%w[a])).map { |sf| convert_name_order(sf.value) }.first oth = join_and_squish(field.find_all(&subfield_not_in?(%w[6 8 a t])).map(&:value)) join_and_squish [suba, oth] end acc.uniq end |
.search_aux(record) ⇒ Array<String>
port this later
ported from get_author_creator_2_search_values
Auxiliary Author/Creator search field
88 |
# File 'lib/pennmarc/helpers/creator.rb', line 88 def search_aux(record); end |
.show(record) ⇒ Array<String>
ported from get_author_display - used on record show page. porting did not include 4, e or w values, which were part of the link object as ‘append’ values in franklin
Author/Creator values for display
106 107 108 109 110 111 112 |
# File 'lib/pennmarc/helpers/creator.rb', line 106 def show(record) fields = record.fields(TAGS) fields += record.fields('880').select { |field| subfield_value_in?(field, '6', TAGS) } fields.filter_map do |field| join_subfields(field, &subfield_not_in?(%w[0 1 4 6 8 e w])) end end |
.sort(record) ⇒ String
This includes any URI from ǂ0 which could help to disambiguate in sorts, but ǂ1 is excluded…
ported from get_author_creator_sort_values
Author/Creator sort. Does not map and include any relator codes.
119 120 121 122 |
# File 'lib/pennmarc/helpers/creator.rb', line 119 def sort(record) field = record.fields(TAGS).first join_subfields(field, &subfield_not_in?(%w[1 4 6 8 e])) end |
.values(record, relator_map: Mappers.relator) ⇒ Array<String>
ported from get_author_creator_values (indexed as author_creator_a) - shown on results page
All author/creator values for display (like #show, but multivalued?) - no 880 linkage
95 96 97 98 99 |
# File 'lib/pennmarc/helpers/creator.rb', line 95 def values(record, relator_map: Mappers.relator) record.fields(TAGS).map do |field| name_from_main_entry(field, relator_map) end end |