Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "uniform title name" as role term to name fields having $t #199

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ These changes are merged into the `main` branch, but have not been released. Aft

=== Changed

* MARC name extraction transforms now supply "uniform title name" as a role term in fields having a $t value. This change supports the fact that some applications may not wish to treat these values as standalone names, and this makes it possible to filter out these values.

=== Deleted

=== Deprecated/Will break in a future version
Expand Down
12 changes: 6 additions & 6 deletions lib/kiba/extend/transforms/marc/extract_base_name_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ class ExtractBaseNameData
# @param role_term_subfields [Array<String>] subfields to extract as
# role term value
# @param delim [String] used when joining multiple values in a field
def initialize(name_type:,
# rubocop:todo Layout/LineLength
name_fields:, name_subfields:, role_code_subfields:, role_term_subfields:, id_target: Kiba::Extend::Marc.id_target_field,
# rubocop:enable Layout/LineLength
def initialize(name_type:, name_fields:, name_subfields:,
role_code_subfields:, role_term_subfields:,
id_target: Kiba::Extend::Marc.id_target_field,
name_target: Kiba::Extend::Marc.name_target,
role_term_target: Kiba::Extend::Marc.role_term_target,
role_code_target: Kiba::Extend::Marc.role_code_target,
Expand Down Expand Up @@ -111,10 +110,11 @@ def role_code(field)
end

def role_term(field)
field.subfields
base = field.subfields
.select { |sf| role_term_subfields.any?(sf.code) }
.map { |sf| roletermcleaner.call(sf.value.strip) }
.join(Kiba::Extend.delim)
base << "uniform title name" if field.codes.include?("t")
base.join(Kiba::Extend.delim)
end
end
end
Expand Down
11 changes: 9 additions & 2 deletions lib/kiba/extend/transforms/marc/extract_person_name_data.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# rubocop:todo Layout/LineLength
# rubocop:disable Layout/LineLength

require "marc"

Expand All @@ -15,22 +15,29 @@ module Marc
# # =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(12)
# 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
Expand Down
Loading
Loading