Class: Kiba::Extend::Transforms::Split::PublicationStatement
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Split::PublicationStatement
- Defined in:
- lib/kiba/extend/transforms/split/publication_statement.rb
Overview
Splits string value of given field into new :pubplace
, :publisher
,
:pubdate
, :manplace
, :manufacturer
, and :mandate
fields.
Fieldnames can be overridden.
Splitting is based on expected ISBD punctuation used in the MARC 260 field.
This transform does the best it can, but depends on fiddly punctuation standards that are not always followed, and which are sometimes ambiguous when MARC subfield coding is not present. It is intended for use in preparing data for client review and cleanup.
Algorithm/assumptions:
- Terminal period is removed from field value pre-processing
- If field value starts with a digit, the whole field value is treated as a date
- If field value contains a
:
or;
, followed by the patterncomma followed by non-comma characters and one or more digits
, then everything including and following that pattern is treated as the date value - If a field value contains
:
or;
, we treat the first segment of the value as place - If a field value does not contain
:
or;
, and does not begin with a digit, we treat the whole field value as publisher - Any part of the field value in parentheses is extracted separately and checked for whether it follows the above patterns. If so, it is run through processing as manufacturing data, and the non-parenthetical data is run through the processing as publication data. If parenthetical data does not match one of the patterns, it gets included as part of publication place, name, or date field
Usage in jobs
transform Split::PublicationStatement, source: :pubstmt
transform Split::PublicationStatement,
source: :pubstmt,
fieldname_overrides: {manufacturer: :printer, mandate: :printdate},
delim: '%'
Constant Summary collapse
- DEFAULT_FIELDNAMES =
%i[pubplace publisher pubdate manplace manufacturer mandate]
Instance Method Summary collapse
-
#initialize(source:, fieldname_overrides: nil, delim: Kiba::Extend.delim) ⇒ PublicationStatement
constructor
A new instance of PublicationStatement.
-
#process(row) ⇒ Hash{ Symbol => String, nil }
Constructor Details
#initialize(source:, fieldname_overrides: nil, delim: Kiba::Extend.delim) ⇒ PublicationStatement
Returns a new instance of PublicationStatement.
152 153 154 155 156 157 158 |
# File 'lib/kiba/extend/transforms/split/publication_statement.rb', line 152 def initialize(source:, fieldname_overrides: nil, delim: Kiba::Extend.delim) @source = source @fieldnames = setup_fieldnames(fieldname_overrides) @delim = delim end |
Instance Method Details
#process(row) ⇒ Hash{ Symbol => String, nil }
162 163 164 165 166 167 168 |
# File 'lib/kiba/extend/transforms/split/publication_statement.rb', line 162 def process(row) add_all_fields(row) val = row[source] return row if val.blank? extract_handler(row, scanner: initial_clean(val)) end |