Class: Kiba::Extend::Transforms::Marc::ExtractPersonNameData

Inherits:
ExtractBaseNameData show all
Defined in:
lib/kiba/extend/transforms/marc/extract_person_name_data.rb

Overview

Extract :marcid and person name data (name, role term, role code, source field tag) from fields containing structured name data

Examples:

# =001  008001024-5
# =100  1\$6880-03$aGlinka, M. I.$q(Mikhail Ivanovich),$d1804-1857,$ecomposer.$4cmp
# =700  1\$aBrussilovsky, Alexandre,$eperformer # no 880
# =700  12$aFoo.$tTitle.
# =880  1\$6100-03$aGlinka VERN,$ecomposer.$4cmp
rec = get_marc_record(index: 9)
xform = Marc::ExtractPersonNameData.new
results = []
xform.process(rec){ |row| results << row }
expect(results.length).to eq(13)
first = {
  :sourcefield=>"700", :name=>"Brussilovsky, Alexandre",
  :nametype=>"person", :role_code=>"", :role_term=>"performer",
  :marcid=>"008001024-5"
}
uniform = {
  :sourcefield=>"700", :name=>"Foo", :nametype=>"person",
  :role_code=>"", :role_term=>"uniform title name",
  :marcid=>"008001024-5"
}
last = {
  :sourcefield=>"100", :name=>"Glinka VERN", :nametype=>"person",
  :role_code=>"cmp", :role_term=>"composer", :marcid=>"008001024-5"
}
expect(results[0]).to eq(first)
expect(results.find { |res| res[:name] == "Foo" }).to eq(uniform)
expect(results[-1]).to eq(last)

Since:

  • 4.0.0

Instance Method Summary collapse

Methods inherited from ExtractBaseNameData

#process

Methods included from FieldLinkable

#select_fields

Constructor Details

#initialize(name_type: "person", name_fields: Kiba::Extend::Marc.person_data_tags, name_subfields: Kiba::Extend::Marc.person_name_part_subfields, role_code_subfields: Kiba::Extend::Marc.person_role_code_subfields, role_term_subfields: Kiba::Extend::Marc.person_role_term_subfields) ⇒ ExtractPersonNameData

Returns a new instance of ExtractPersonNameData.

Parameters:

  • name_type (String) (defaults to: "person")

    to insert into name_type_target field

  • name_fields (Array<String>) (defaults to: Kiba::Extend::Marc.person_data_tags)

    MARC fields from which name data will be extracted

  • name_subfields (Array<String>) (defaults to: Kiba::Extend::Marc.person_name_part_subfields)

    subfields to extract as part of name value.

  • role_code_subfields (Array<String>) (defaults to: Kiba::Extend::Marc.person_role_code_subfields)

    subfields to extract as role code value

  • role_term_subfields (Array<String>) (defaults to: Kiba::Extend::Marc.person_role_term_subfields)

    subfields to extract as role term value

Since:

  • 4.0.0



54
55
56
57
58
59
60
61
62
63
# File 'lib/kiba/extend/transforms/marc/extract_person_name_data.rb', line 54

def initialize(name_type: "person",
  name_fields: Kiba::Extend::Marc.person_data_tags,
  name_subfields:
  Kiba::Extend::Marc.person_name_part_subfields,
  role_code_subfields:
  Kiba::Extend::Marc.person_role_code_subfields,
  role_term_subfields:
  Kiba::Extend::Marc.person_role_term_subfields)
  super
end