Class: Traject::UMichFormat::BibTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/traject/umich_format/bib_types.rb

Overview

Determine the "types" of material represented by the bib record. The comments below come from the Ex Libris Aleph system and represent the logic used within it to determine types. This file is based on the logic use at the University of Michigan

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bib_format, record) ⇒ BibTypes

Returns a new instance of BibTypes.



14
15
16
17
18
19
20
21
22
# File 'lib/traject/umich_format/bib_types.rb', line 14

def initialize(bib_format, record)
  @bib_format = bib_format
  @record = record
  # Memoize values, since many of them are used several times
  @spec_vals  = Hash.new { |h, spec_string| h[spec_string] = Traject::MarcExtractor.new(spec_string).extract(@record) }

  # Need these a lot -- the sub x and v from any 6XX field
  @xv6XX      = Traject::UMichFormat::XV6XX.new(@record)
end

Class Attribute Details

.pp_regexpObject

Returns the value of attribute pp_regexp.



532
533
534
# File 'lib/traject/umich_format/bib_types.rb', line 532

def pp_regexp
  @pp_regexp
end

Instance Attribute Details

#bib_formatObject (readonly)

Returns the value of attribute bib_format.



12
13
14
# File 'lib/traject/umich_format/bib_types.rb', line 12

def bib_format
  @bib_format
end

#recordObject (readonly)

Returns the value of attribute record.



12
13
14
# File 'lib/traject/umich_format/bib_types.rb', line 12

def record
  @record
end

Instance Method Details

#[](spec_string) ⇒ Array<String>

Provide memoized values for on-the-fly created MarcExtractor objects

Parameters:

  • spec_string (String)

    A Traject::MarcExtractor-compatible spec string

Returns:

  • (Array<String>)

    The strings in the specified subfields/byterange/whatever



56
57
58
# File 'lib/traject/umich_format/bib_types.rb', line 56

def [](spec_string)
  @spec_vals[spec_string]
end

#audio_typesObject

Audio/music ! Recording: Compact disc TYP RC Audio CD LDR F06-01 EQUAL [i,j] FMT F00-02 EQUAL MU 007 F01-01 EQUAL d 007 F12-01 EQUAL e TYP RC Audio CD 8524 j MATCH CD* 8524 b EQUAL MUSIC ! ! Recording: LP record TYP RL Audio LP LDR F06-01 EQUAL [i,j] FMT F00-02 EQUAL MU 007 F01-01 EQUAL d 300 a MATCH SOUND DISC 300 b MATCH 33 1/3 RPM

TYP RL Audio LP 8524 j MATCH LP* 8524 c EQUAL MUSI TYP RL Audio LP 8524 j MATCH LP* 8524 b EQUAL MUSIC ! ! Recording: Music TYP RM Audio (music) LDR F06-01 EQUAL j FMT F00-02 EQUAL MU ! ! Recording: Spoken word TYP RS Audio (spoken word) LDR F06-01 EQUAL i FMT F00-02 EQUAL MU ! ! Recording: Undefined TYP RU Audio LDR F06-01 EQUAL [i,j] FMT F00-02 EQUAL MU



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/traject/umich_format/bib_types.rb', line 149

def audio_types
  ldr6 = record.leader[6]

  types = []

  # Get the 8524* fields
  f8524 = record.fields('852').select{|f| f.indicator1 == '4'}

  # RC
  if %w[i j].include?(ldr6) && (bib_format == 'MU') 
    @record.fields('007').map{|f| f.value}.each do |f|
      if f[1] == 'd' && f[12] == 'e'
        types << 'RC'
        break
      end
    end
  end

  # RC:  007/00 is 's' and 007/01 is 'd' and 007/06 is 'g'
  @record.fields('007').map{|f| f.value}.each do |f|
    if (f[0] == 's') && (f[1] == 'd') && (f[6] == 'g')
      types << 'RC'
      break
    end
  end

  f8524.each do |f|
    if (f['b'].upcase == 'MUSIC') && (f['j'] =~ /\ACD/i)
      types << 'RC'
      break
    end
  end

  # RL

  if  (bib_format == 'MU') && %w[i j].include?(ldr6) && self['007[1]'].include?('d')
    record.fields('300').each do |f|
      str = f.subfields.collect {|s| s.value}.join(' ')
      if (str =~ /DISC/i) && str =~ /33 1\/3 RPM/i
        types << 'RL'
        break
      end
    end
  end


  f8524.each do |f|
    if  (f['j'] =~ /\ALP/i) &&
        ((f['b'].upcase == 'MUSIC') || (f['c'].upcase == 'MUSI'))
      types << 'RL'
      break
    end
  end

  # RM
  types << 'RM' if (ldr6 == 'j') && (bib_format == 'MU')

  # RS
  types << 'RS' if (ldr6 == 'i') && (bib_format == 'MU')

  # RU
  types << 'RU' if %w[i j].include?(ldr6) && (bib_format == 'MU')

  types.uniq!
  return types
end

#biography_typesObject

TYP BI Biography 6#### xv MATCH biography TYP BI Biography 6#### xv MATCH diaries TYP BI Biography 008 F34-01 EQUAL [a,b,c] TYP BI Biography 006 F17-01 EQUAL [a,b,c]



507
508
509
510
511
512
513
514
515
# File 'lib/traject/umich_format/bib_types.rb', line 507

def biography_types
  return ['BI'] if record['008'] && %w[a b c].include?(record['008'].value[34])
  return ['BI'] if (%w[a b c ] & self['006[17]']).size > 0

  return ['BI'] if @xv6XX.match? /(?:biography|diaries)/i

  # Nope
  return []
end

#boardgame_typesObject



579
580
581
582
583
584
585
# File 'lib/traject/umich_format/bib_types.rb', line 579

def boardgame_types
   return ['BG'] if self['655a'].grep(/\A(board|card) games/i).size > 0 
   return ['BG'] if self['852j'].grep(/\Agame board/i).size > 0
   return ['BG'] if %w[g k o r].include?(record.leader[6]) && (self['008[33]'].include? 'g') 
   return ['BG'] if %w[g k o r].include?(record.leader[6]) && (self['006[16]'].include? 'g') 
  return []
end

#codesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/traject/umich_format/bib_types.rb', line 25

def codes
  codes = []
  codes.concat self.video_types
  codes.concat self.audio_types
  codes.concat self.microform_types
  codes.concat self.musical_score_types
  codes.concat self.map_types
  codes.concat self.serial_types
  codes.concat self.mixed_types
  codes.concat self.software_types
  codes.concat self.statistics_types
  codes.concat self.conference_types
  codes.concat self.biography_types
  codes.concat self.reference_types
  codes.concat self.pp_types
  codes.concat self.videogame_types
  codes.concat self.boardgame_types

  codes.uniq!
  codes.compact!
  
  codes
end

#conference_typesObject

! X (no icon) - Conference TYP XC Conference 008 F29-01 EQUAL 1 TYP XC Conference 111## EXIST TYP XC Conference 711## EXIST TYP XC Conference 811## EXIST TYP XC Conference FMT F00-02 EQUAL CF 006 F00-01 EQUAL [a,s] 006 F12-01 EQUAL 1 TYP XC Conference FMT F00-02 EQUAL MU 008 F30-01 EQUAL c TYP XC Conference FMT F00-02 EQUAL MU 008 F31-01 EQUAL c ! additional types defined for vufind extract TYP XC Conference 6#### xv MATCH congresses



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/traject/umich_format/bib_types.rb', line 405

def conference_types
  # Get the easy stuff done first

  return ['XC'] if  (record['008'] && (record['008'].value[29] == '1')) || record.fields(['111', '711', '811']).size > 0

  if  (bib_format == 'CF')
    @record.fields('006').map{|f| f.value}.each do |f|
      return ['XC'] if  %w[a s].include?(f[0]) && (f[12] == '1')
    end
  end

  if  (bib_format == 'MU') && record['008'] &&
      (record['008'].value[30..31] =~ /c/)
    return ['XC']
  end

  return ['XC'] if @xv6XX.match? /congresses/i

  # Nope.
  return []
end

#journal_typesObject



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/traject/umich_format/bib_types.rb', line 313

def journal_types

  types = []
  # gotta be SE and have a 008
  return types unless (bib_format == 'SE') && record['008']


  # We need lots of chars from the 008
  f8 = record['008'].value

  if  (f8[21] == 'p') &&
      [' ','a','b','c','d','f','g','h','i','s','x','z','|'].include?(f8[22]) &&
      ['0', '|'].include?(f8[29])
    types << 'AJ'
  end

  if  [' ','d','l','m','p','w','|'].include?(f8[21]) &&
      [' ','a','b','c','d','f','g','h','i','s','x','z','|'].include?(f8[22]) &&
      ['a','b','g','m','n','o','p','s','w','x','y',' '].include?(f8[24]) &&
      ['0', '|'].include?(f8[29])
    types << 'AJ'
  end

  types.uniq!
  return types
end

#map_typesObject



271
272
273
274
275
276
277
# File 'lib/traject/umich_format/bib_types.rb', line 271

def map_types
  types = []
  if (bib_format == 'MP') || %w[e f].include?(record.leader[6]) ||  self['007[0]'].include?('a')
    types << 'MN'
  end
  return types
end

#microform_typesObject

TYP WM Microform FMT F00-02 EQUAL MP 008 F29-01 EQUAL [a,b,c] TYP WM Microform FMT F00-02 EQUAL VM 008 F29-01 EQUAL [a,b,c]



235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/traject/umich_format/bib_types.rb', line 235

def microform_types
  return [] unless record['008']
  types = ['WM']
  f8_23 = record['008'].value[23]
  return types if %w[BK MU SE MX].include?(bib_format) && %w[a b c].include?(f8_23)

  f8_29 = record['008'].value[29]
  return types if %w[MP VM].include?(bib_format) &&  %w[a b c].include?(f8_29)

  return types if record['245'] && (record['245']['h'] =~ /micro/i)

  # Nope. Not microform
  return []
end

#mixed_typesObject

! Mixed material: archi-V-e TYP MV Archive FMT F00-02 EQUAL MX TYP MV Archive LDR F08-01 EQUAL a ! ! Mixed material: manuscript TYP MW Manuscript LDR F06-01 EQUAL [d,f,p,t]



355
356
357
358
359
360
# File 'lib/traject/umich_format/bib_types.rb', line 355

def mixed_types
  types = []
  types << 'MV' if (bib_format == 'MX') || (record.leader[8] == 'a')
  types << 'MW' if %w[d f p t].include?(record.leader[6])
  return types
end

#musical_score_typesObject

! Musical Score TYP MS Musical Score LDR F06-01 EQUAL [c,d]



254
255
256
257
258
# File 'lib/traject/umich_format/bib_types.rb', line 254

def musical_score_types
  types = []
  types << 'MS' if %w[c d].include?(record.leader[6])
  return types
end

#newspaper_typesObject



340
341
342
343
344
345
# File 'lib/traject/umich_format/bib_types.rb', line 340

def newspaper_types
  types = []
  types << 'AN' if (bib_format == 'SE') && record['008'] &&
      ((record['008'].value[21] == 'n') || (record['008'].value[22] == 'e'))
  return types
end

#pp_typesObject



549
550
551
552
553
554
555
# File 'lib/traject/umich_format/bib_types.rb', line 549

def pp_types
  if @xv6XX.match? self.class.pp_regexp
    return ['PP']
  else
    return []
  end
end

#reference_typesObject

TYP EN Encyclopedias 6#### xv MATCH encyclopedias TYP EN Encyclopedias 008 F24-01 EQUAL e TYP EN Encyclopedias 006 F07-01 EQUAL e

TYP DI Dictionaries 6#### xv MATCH dictionaries TYP DI Dictionaries 008 F24-01 EQUAL d TYP DI Dictionaries 006 F07-01 EQUAL d

TYP DR Directories 6#### xv MATCH directories TYP DR Directories 008 F24-01 EQUAL r TYP DR Directories 006 F07-01 EQUAL d



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/traject/umich_format/bib_types.rb', line 467

def reference_types
  types = []

  # Will need the 008[24] and 006[7]
  f8_24 =  self['008[24]']
  f6_7 = self['006[7]']



  if (f8_24.include? 'e') || (f6_7.include? 'e')
    types << 'EN'
  end

  if f6_7.include? 'd'
    types << 'DI'
    types << 'DR'
  end

  if f8_24.include? 'd'
    types << 'DI'
  end

  if f8_24.include? 'r'
    types << 'DR'
  end

  types << 'EN' if @xv6XX.match? /encyclopedias/i
  types << 'DI' if @xv6XX.match? /dictionaries/i
  types << 'DR' if @xv6XX.match? /directories/i

  types.uniq!
  return types
end

#serial_typesObject

Wrap it all up in serial_types



303
304
305
306
307
308
309
310
# File 'lib/traject/umich_format/bib_types.rb', line 303

def serial_types
  types = []
  types << 'SX' if %w[b s].include?(record.leader[7])
  types.concat journal_types
  types.concat newspaper_types
  types.uniq!
  return types
end

#software_typesObject

TYP CR CDROM 852## j MATCH cd-rom* TYP CR CDROM 852## j MATCH cdrom* TYP CR CDROM 852## j MATCH cd-rom* TYP CS Software 852## j MATCH software* CR: 007/00 is 'c' and 007/01 is 'o' and 007/04 is 'g'



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/traject/umich_format/bib_types.rb', line 368

def software_types
  types = []
  self['852j'].each do |j|
    if j =~ /\Acd-?rom/i
      types << 'CR'
    end
    if j =~ /\Asoftware/i
      types << 'CS'
    end
  end

  # CR:  007/00 is 'c' and 007/01 is 'o' and 007/04 is 'g'
  @record.fields('007').map{|f| f.value}.each do |f|
    if (f[0] == 'c') && (f[1] == 'o') && (f[4] == 'g')
      types << 'CR'
    end
  end

  types.uniq!
  return types
end

#statistics_typesObject



441
442
443
444
445
446
447
448
449
450
451
# File 'lib/traject/umich_format/bib_types.rb', line 441

def statistics_types

  if bib_format == 'BK'
    return ['XS'] if record['008'] && record['008'].value[24..27] =~ /s/
  end

  return ['XS'] if @xv6XX.match? /\AStatistic/i

  # Nope
  return []
end

#video_typesObject

TYP VB Video (Blu-ray) 538## a MATCH Blu-ray TYP VB Video (Blu-ray) 007 F00-05 MATCH v???s TYP VB Video (Blu-ray) 250## a MATCH Blu-ray TYP VB Video (Blu-ray) 852## j MATCH video-b* TYP VB Video (Blu-ray) 852## j MATCH bd-rom*

TYP VD Video (DVD) 538## a MATCH DVD* TYP VD Video (DVD) 007 F04-01 EQUAL v 007 F00-01 EQUAL v TYP VD Video (DVD) 007 F04-01 EQUAL v 008 F33-01 EQUAL v ! ! Visual material: vHs TYP VH Video (VHS) 538## a MATCH VHS* TYP VH Video (VHS) 007 F04-01 EQUAL b 007 F00-01 EQUAL v TYP VH Video (VHS) 007 F04-01 EQUAL b 008 F33-01 EQUAL v ! ! Visual materials: fiLm/video TYP VL Motion Picture 007 F00-01 EQUAL m TYP VL Motion Picture FMT F00-02 EQUAL VM 008 F33-01 EQUAL m



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/traject/umich_format/bib_types.rb', line 87

def video_types
  types = []

  types << 'VB' if self['538a:250a'].grep(/blu-ray/i).size > 0
  types << 'VB' if self['007[0-5]'].grep(/v...s/i).size > 0
  types << 'VB' if self['852j'].grep(/\A(?:bd-rom|video-b)/i).size > 0

  @record.fields('007').map{|f| f.value}.each do |f|
    if (f[0] == 'v') || self['008[33]'].include?('v')
      types << 'VD' if f[4] == 'v'
      types << 'VH' if f[4] == 'b'
    end
  end


  types << 'VD' if self['538a'].grep(/\Advd(?!\-rom)/i).size > 0

  types << 'VH' if self['538a'].grep(/\AVHS/i).size > 0


  types << 'VL' if self['007[0]'].include?('m')
  types << 'VL' if (self.bib_format == 'VM') && self['008[33]'].include?('m')

  types.uniq!
  return types
end

#videogame_typesObject

TYP VG Video Games FMT F00-02 EQUAL CF 008 F26-01 EQUAL g



562
563
564
565
566
567
568
# File 'lib/traject/umich_format/bib_types.rb', line 562

def videogame_types
  if (bib_format == 'CF') && (self['008[26]'].include? 'g')
    return ['VG']
  else
    return []
  end
end