Skip to content

punctuation2

nvolk edited this page Dec 4, 2023 · 4 revisions

Yet another punctuation besides punctuation and ending punctuation...

This validator/fixer adds functionality to both add and remove intermediate and final puntuation for many fields. This is needed by merge-reducers, as punctuation must first be stripped as part of subfield equality check. Then after merged subfields have been added, this fixer is used the second time to punctuate the modifier field.

Note that this fixer's default function only adds punctuation, and was added when existing code was convert into a validator/fixer. However, the validator/fixer contains two exportable functions: fieldStripPunctuation(field) (for stripping) and fieldFixPunctuation(field) (strip+add). Note that tests for stripping punctuation are implement in wrapper validator stripPunctuation

Usage example: https://github.com/NatLibFi/melinda-marc-record-merge-reducers-js/blob/main/src/reducers/mergeOrAddPostprocess.js

import {fieldFixPunctuation} from '@natlibfi/marc-record-validators-melinda/dist/punctuation2';

fieldFixPunctuation(field);

NB! Ending punctuation is typically done using ending-punctuation even though we could do ending punctuation here as well.

Features:

  • Add punctuation, strip valid punctuation, strip invalid punctuation (educated guesses)
  • Aontrol subfields are skipped. If we have $d $0 $e, $d is punctueated using $d-$e-punctuation rules.