@natlibfi/marc-record-validators-melinda 12.1.0-alpha.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/melinda-node-tests-and-publish.yml +17 -17
- package/README.md +1 -1
- package/dist/addMissingField041.js +6 -3
- package/dist/addMissingField041.js.map +2 -2
- package/dist/addMissingField336.js +7 -4
- package/dist/addMissingField336.js.map +2 -2
- package/dist/addMissingField337.js +6 -3
- package/dist/addMissingField337.js.map +2 -2
- package/dist/addMissingField338.js +8 -5
- package/dist/addMissingField338.js.map +2 -2
- package/dist/cyrillux-usemarcon-replacement.js +5 -2
- package/dist/cyrillux-usemarcon-replacement.js.map +2 -2
- package/dist/cyrillux.js +24 -18
- package/dist/cyrillux.js.map +2 -2
- package/dist/dataProvenanceUtils.js +19 -0
- package/dist/dataProvenanceUtils.js.map +7 -0
- package/dist/disambiguateSeriesStatements.js +2 -1
- package/dist/disambiguateSeriesStatements.js.map +2 -2
- package/dist/disambiguateSeriesStatements.test.js +1 -7
- package/dist/disambiguateSeriesStatements.test.js.map +2 -2
- package/dist/drop-terms.js +123 -0
- package/dist/drop-terms.js.map +7 -0
- package/dist/drop-terms.test.js +56 -0
- package/dist/drop-terms.test.js.map +7 -0
- package/dist/field-008-18-34-character-groups.test.js +1 -7
- package/dist/field-008-18-34-character-groups.test.js.map +2 -2
- package/dist/field-505-separators.test.js +1 -7
- package/dist/field-505-separators.test.js.map +2 -2
- package/dist/field-521-fix.test.js +1 -7
- package/dist/field-521-fix.test.js.map +2 -2
- package/dist/fix-33X.js +7 -4
- package/dist/fix-33X.js.map +2 -2
- package/dist/fix-33X.test.js +1 -1
- package/dist/fix-33X.test.js.map +1 -1
- package/dist/fix-country-codes.js +5 -0
- package/dist/fix-country-codes.js.map +2 -2
- package/dist/fix-country-codes.test.js +1 -7
- package/dist/fix-country-codes.test.js.map +2 -2
- package/dist/fix-language-codes.js +5 -1
- package/dist/fix-language-codes.js.map +2 -2
- package/dist/fix-sami-041.js +109 -0
- package/dist/fix-sami-041.js.map +7 -0
- package/dist/fix-sami-041.test.js +40 -0
- package/dist/fix-sami-041.test.js.map +7 -0
- package/dist/fixRelatorTerms.js +2 -0
- package/dist/fixRelatorTerms.js.map +2 -2
- package/dist/fixRelatorTerms.test.js +1 -7
- package/dist/fixRelatorTerms.test.js.map +2 -2
- package/dist/index.js +18 -4
- package/dist/index.js.map +2 -2
- package/dist/indicator-fixes.js +15 -1
- package/dist/indicator-fixes.js.map +2 -2
- package/dist/indicator-fixes.test.js +1 -7
- package/dist/indicator-fixes.test.js.map +2 -2
- package/dist/item-language.js +41 -39
- package/dist/item-language.js.map +2 -2
- package/dist/item-language.test.js +3 -3
- package/dist/item-language.test.js.map +2 -2
- package/dist/melindaCustomMergeFields.js +31 -0
- package/dist/melindaCustomMergeFields.js.map +2 -2
- package/dist/merge-fields/controlSubfields.js.map +2 -2
- package/dist/merge-fields/counterpartField.js +149 -152
- package/dist/merge-fields/counterpartField.js.map +3 -3
- package/dist/merge-fields/dataProvenance.js +6 -20
- package/dist/merge-fields/dataProvenance.js.map +2 -2
- package/dist/merge-fields/index.js +1 -1
- package/dist/merge-fields/index.js.map +2 -2
- package/dist/merge-fields/mergableIndicator.js +1 -5
- package/dist/merge-fields/mergableIndicator.js.map +2 -2
- package/dist/merge-fields/mergableTag.js +2 -0
- package/dist/merge-fields/mergableTag.js.map +2 -2
- package/dist/merge-fields/mergeConfig.js +2 -0
- package/dist/merge-fields/mergeConfig.js.map +2 -2
- package/dist/merge-fields/mergeConstraints.js +38 -35
- package/dist/merge-fields/mergeConstraints.js.map +3 -3
- package/dist/merge-fields/mergeField.js +4 -3
- package/dist/merge-fields/mergeField.js.map +2 -2
- package/dist/merge-fields/mergeOrAddSubfield.js +8 -7
- package/dist/merge-fields/mergeOrAddSubfield.js.map +2 -2
- package/dist/merge-fields/mergeSubfield.js +5 -1
- package/dist/merge-fields/mergeSubfield.js.map +2 -2
- package/dist/merge-fields/worldKnowledge.js +52 -0
- package/dist/merge-fields/worldKnowledge.js.map +2 -2
- package/dist/merge-fields.test.js +4 -9
- package/dist/merge-fields.test.js.map +2 -2
- package/dist/mergeField500Lisapainokset.test.js +1 -7
- package/dist/mergeField500Lisapainokset.test.js.map +2 -2
- package/dist/mergeRelatorTermFields.js +9 -6
- package/dist/mergeRelatorTermFields.js.map +2 -2
- package/dist/mergeRelatorTermFields.test.js +1 -7
- package/dist/mergeRelatorTermFields.test.js.map +2 -2
- package/dist/multiple-subfield-0.test.js +1 -7
- package/dist/multiple-subfield-0.test.js.map +2 -2
- package/dist/normalize-dashes.js +9 -6
- package/dist/normalize-dashes.js.map +2 -2
- package/dist/normalize-dashes.test.js +1 -7
- package/dist/normalize-dashes.test.js.map +2 -2
- package/dist/normalize-identifiers.js.map +2 -2
- package/dist/normalize-identifiers.test.js +1 -7
- package/dist/normalize-identifiers.test.js.map +2 -2
- package/dist/normalize-qualifying-information.test.js +1 -7
- package/dist/normalize-qualifying-information.test.js.map +2 -2
- package/dist/normalize-utf8-diacritics.js.map +2 -2
- package/dist/normalize-utf8-diacritics.test.js +1 -7
- package/dist/normalize-utf8-diacritics.test.js.map +2 -2
- package/dist/normalizeFieldForComparison.js +24 -14
- package/dist/normalizeFieldForComparison.js.map +2 -2
- package/dist/normalizeSubfieldValueForComparison.js.map +1 -1
- package/dist/prepublicationUtils.js +1 -1
- package/dist/prepublicationUtils.js.map +2 -2
- package/dist/punctuation.test.js +1 -7
- package/dist/punctuation.test.js.map +2 -2
- package/dist/punctuation2.js +15 -12
- package/dist/punctuation2.js.map +2 -2
- package/dist/punctuation2.test.js +1 -7
- package/dist/punctuation2.test.js.map +2 -2
- package/dist/reindexSubfield6OccurenceNumbers.js +11 -10
- package/dist/reindexSubfield6OccurenceNumbers.js.map +2 -2
- package/dist/reindexSubfield6OccurenceNumbers.test.js +1 -7
- package/dist/reindexSubfield6OccurenceNumbers.test.js.map +2 -2
- package/dist/remove-041-zxx.js +56 -0
- package/dist/remove-041-zxx.js.map +7 -0
- package/dist/remove-041-zxx.test.js +40 -0
- package/dist/remove-041-zxx.test.js.map +7 -0
- package/dist/removeDuplicateDataFields.js +4 -26
- package/dist/removeDuplicateDataFields.js.map +2 -2
- package/dist/removeDuplicateDataFields.test.js +1 -7
- package/dist/removeDuplicateDataFields.test.js.map +2 -2
- package/dist/removeInferiorDataFields.js +82 -45
- package/dist/removeInferiorDataFields.js.map +3 -3
- package/dist/removeInferiorDataFields.test.js +5 -9
- package/dist/removeInferiorDataFields.test.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.js +4 -5
- package/dist/resolveOrphanedSubfield6s.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.test.js +1 -7
- package/dist/resolveOrphanedSubfield6s.test.js.map +2 -2
- package/dist/sanitize-vocabulary-source-codes.test.js +1 -7
- package/dist/sanitize-vocabulary-source-codes.test.js.map +2 -2
- package/dist/sortFields.js +16 -1
- package/dist/sortFields.js.map +2 -2
- package/dist/sortFields.test.js +1 -7
- package/dist/sortFields.test.js.map +2 -2
- package/dist/sortRelatorTerms.test.js +1 -7
- package/dist/sortRelatorTerms.test.js.map +2 -2
- package/dist/sortSubfields.js +27 -21
- package/dist/sortSubfields.js.map +2 -2
- package/dist/sortSubfields.test.js +1 -7
- package/dist/sortSubfields.test.js.map +2 -2
- package/dist/stripPunctuation.js +7 -3
- package/dist/stripPunctuation.js.map +2 -2
- package/dist/stripPunctuation.test.js +1 -7
- package/dist/stripPunctuation.test.js.map +2 -2
- package/dist/subfield6Utils.js +2 -12
- package/dist/subfield6Utils.js.map +2 -2
- package/dist/subfield8Utils.js +0 -5
- package/dist/subfield8Utils.js.map +2 -2
- package/dist/subfieldValueNormalizations.test.js +1 -7
- package/dist/subfieldValueNormalizations.test.js.map +2 -2
- package/dist/sync-007-and-300.test.js +1 -7
- package/dist/sync-007-and-300.test.js.map +2 -2
- package/dist/sync-language.js +103 -0
- package/dist/sync-language.js.map +7 -0
- package/dist/sync-language.test.js +40 -0
- package/dist/sync-language.test.js.map +7 -0
- package/dist/translate-terms.js +124 -87
- package/dist/translate-terms.js.map +3 -3
- package/dist/translate-terms.test.js +5 -8
- package/dist/translate-terms.test.js.map +2 -2
- package/dist/typeOfDate-008.js +3 -1
- package/dist/typeOfDate-008.js.map +2 -2
- package/dist/update-field-540.js.map +2 -2
- package/dist/update-field-540.test.js +1 -7
- package/dist/update-field-540.test.js.map +2 -2
- package/dist/urn.js +13 -12
- package/dist/urn.js.map +2 -2
- package/dist/urn.test.js +1 -7
- package/dist/urn.test.js.map +2 -2
- package/dist/utils.js +29 -3
- package/dist/utils.js.map +2 -2
- package/package.json +20 -27
- package/src/addMissingField041.js +8 -4
- package/src/addMissingField336.js +10 -5
- package/src/addMissingField337.js +9 -5
- package/src/addMissingField338.js +11 -6
- package/src/cyrillux-usemarcon-replacement.js +9 -5
- package/src/cyrillux.js +34 -23
- package/src/dataProvenanceUtils.js +21 -0
- package/src/disambiguateSeriesStatements.js +4 -1
- package/src/disambiguateSeriesStatements.test.js +3 -8
- package/src/drop-terms.js +164 -0
- package/src/drop-terms.test.js +81 -0
- package/src/field-008-18-34-character-groups.test.js +3 -8
- package/src/field-505-separators.test.js +3 -8
- package/src/field-521-fix.test.js +3 -8
- package/src/fix-33X.js +10 -6
- package/src/fix-33X.test.js +1 -1
- package/src/fix-country-codes.js +7 -3
- package/src/fix-country-codes.test.js +3 -8
- package/src/fix-language-codes.js +8 -4
- package/src/fix-sami-041.js +147 -0
- package/src/fix-sami-041.test.js +52 -0
- package/src/fixRelatorTerms.js +5 -0
- package/src/fixRelatorTerms.test.js +3 -8
- package/src/index.js +20 -7
- package/src/indicator-fixes.js +22 -7
- package/src/indicator-fixes.test.js +3 -8
- package/src/item-language.js +49 -42
- package/src/item-language.test.js +3 -3
- package/src/melindaCustomMergeFields.js +31 -0
- package/src/merge-fields/controlSubfields.js +0 -1
- package/src/merge-fields/counterpartField.js +191 -290
- package/src/merge-fields/dataProvenance.js +8 -25
- package/src/merge-fields/index.js +1 -1
- package/src/merge-fields/mergableIndicator.js +4 -5
- package/src/merge-fields/mergableTag.js +2 -0
- package/src/merge-fields/mergeConfig.js +2 -1
- package/src/merge-fields/mergeConstraints.js +41 -36
- package/src/merge-fields/mergeField.js +4 -7
- package/src/merge-fields/mergeOrAddSubfield.js +8 -7
- package/src/merge-fields/mergeSubfield.js +11 -2
- package/src/merge-fields/worldKnowledge.js +77 -3
- package/src/merge-fields.test.js +5 -10
- package/src/mergeField500Lisapainokset.test.js +3 -8
- package/src/mergeRelatorTermFields.js +12 -11
- package/src/mergeRelatorTermFields.test.js +3 -8
- package/src/multiple-subfield-0.test.js +3 -8
- package/src/normalize-dashes.js +13 -7
- package/src/normalize-dashes.test.js +3 -8
- package/src/normalize-identifiers.js +12 -19
- package/src/normalize-identifiers.test.js +3 -8
- package/src/normalize-qualifying-information.test.js +3 -8
- package/src/normalize-utf8-diacritics.js +6 -3
- package/src/normalize-utf8-diacritics.test.js +3 -8
- package/src/normalizeFieldForComparison.js +39 -22
- package/src/normalizeSubfieldValueForComparison.js +2 -2
- package/src/prepublicationUtils.js +1 -1
- package/src/punctuation.test.js +3 -8
- package/src/punctuation2.js +44 -40
- package/src/punctuation2.test.js +3 -8
- package/src/reindexSubfield6OccurenceNumbers.js +13 -11
- package/src/reindexSubfield6OccurenceNumbers.test.js +3 -8
- package/src/remove-041-zxx.js +85 -0
- package/src/remove-041-zxx.test.js +52 -0
- package/src/removeDuplicateDataFields.js +30 -28
- package/src/removeDuplicateDataFields.test.js +3 -8
- package/src/removeInferiorDataFields.js +126 -71
- package/src/removeInferiorDataFields.test.js +7 -10
- package/src/resolveOrphanedSubfield6s.js +7 -5
- package/src/resolveOrphanedSubfield6s.test.js +3 -8
- package/src/sanitize-vocabulary-source-codes.test.js +3 -8
- package/src/sortFields.js +20 -1
- package/src/sortFields.test.js +3 -8
- package/src/sortRelatorTerms.test.js +3 -8
- package/src/sortSubfields.js +31 -25
- package/src/sortSubfields.test.js +3 -8
- package/src/stripPunctuation.js +10 -5
- package/src/stripPunctuation.test.js +3 -8
- package/src/subfield6Utils.js +31 -33
- package/src/subfield8Utils.js +10 -7
- package/src/subfieldValueNormalizations.test.js +3 -8
- package/src/sync-007-and-300.test.js +3 -8
- package/src/sync-language.js +148 -0
- package/src/sync-language.test.js +52 -0
- package/src/translate-terms.js +168 -109
- package/src/translate-terms.test.js +12 -16
- package/src/typeOfDate-008.js +4 -1
- package/src/update-field-540.js +7 -5
- package/src/update-field-540.test.js +3 -8
- package/src/urn.js +17 -13
- package/src/urn.test.js +3 -8
- package/src/utils.js +39 -12
- package/test-fixtures/cyrillux/f02b/expectedResult.json +23 -0
- package/test-fixtures/cyrillux/f02b/metadata.json +11 -0
- package/test-fixtures/cyrillux/f02b/record.json +14 -0
- package/test-fixtures/cyrillux/f14/expectedResult.json +32 -0
- package/test-fixtures/cyrillux/f14/metadata.json +10 -0
- package/test-fixtures/cyrillux/f14/record.json +14 -0
- package/test-fixtures/drop-terms/01/expectedResult.json +31 -0
- package/test-fixtures/drop-terms/01/metadata.json +6 -0
- package/test-fixtures/drop-terms/01/record.json +35 -0
- package/test-fixtures/drop-terms/02/expectedResult.json +7 -0
- package/test-fixtures/drop-terms/02/metadata.json +6 -0
- package/test-fixtures/drop-terms/02/record.json +40 -0
- package/test-fixtures/drop-terms/03/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/03/metadata.json +18 -0
- package/test-fixtures/drop-terms/03/record.json +39 -0
- package/test-fixtures/drop-terms/04/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/04/metadata.json +19 -0
- package/test-fixtures/drop-terms/04/record.json +24 -0
- package/test-fixtures/fix-language-codes/02/metadata.json +1 -1
- package/test-fixtures/fix-relator-terms/f02/metadata.json +1 -1
- package/test-fixtures/fix-relator-terms/f04/expectedResult.json +18 -0
- package/test-fixtures/fix-relator-terms/f04/metadata.json +5 -0
- package/test-fixtures/fix-relator-terms/f04/record.json +20 -0
- package/test-fixtures/fix-sami-041/01/expectedResult.json +6 -0
- package/test-fixtures/fix-sami-041/01/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/01/record.json +14 -0
- package/test-fixtures/fix-sami-041/02/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/02/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/02/record.json +8 -0
- package/test-fixtures/fix-sami-041/03/expectedResult.json +5 -0
- package/test-fixtures/fix-sami-041/03/metadata.json +5 -0
- package/test-fixtures/fix-sami-041/03/record.json +8 -0
- package/test-fixtures/fix-sami-041/04/expectedResult.json +7 -0
- package/test-fixtures/fix-sami-041/04/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/04/record.json +10 -0
- package/test-fixtures/fix-sami-041/05/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/05/metadata.json +6 -0
- package/test-fixtures/fix-sami-041/05/record.json +8 -0
- package/test-fixtures/fix-sami-041/06/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/06/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/06/record.json +9 -0
- package/test-fixtures/indicator-fixes/11/expectedResult.json +10 -0
- package/test-fixtures/indicator-fixes/11/metadata.json +4 -0
- package/test-fixtures/indicator-fixes/11/record.json +10 -0
- package/test-fixtures/merge-fields/f042_01/expectedResult.json +12 -0
- package/test-fixtures/merge-fields/f042_01/metadata.json +6 -0
- package/test-fixtures/merge-fields/f042_01/record.json +13 -0
- package/test-fixtures/merge-fields/f05/metadata.json +1 -1
- package/test-fixtures/merge-fields/f06/expectedResult.json +42 -0
- package/test-fixtures/merge-fields/f06/metadata.json +6 -0
- package/test-fixtures/merge-fields/f06/record.json +41 -0
- package/test-fixtures/merge-fields/f07/expectedResult.json +18 -0
- package/test-fixtures/merge-fields/f07/metadata.json +6 -0
- package/test-fixtures/merge-fields/f07/record.json +18 -0
- package/test-fixtures/merge-fields/f08/expectedResult.json +12 -0
- package/test-fixtures/merge-fields/f08/metadata.json +7 -0
- package/test-fixtures/merge-fields/f08/record.json +10 -0
- package/test-fixtures/merge-fields/f09/expectedResult.json +14 -0
- package/test-fixtures/merge-fields/f09/metadata.json +6 -0
- package/test-fixtures/merge-fields/f09/record.json +14 -0
- package/test-fixtures/merge-fields/f10/expectedResult.json +25 -0
- package/test-fixtures/merge-fields/f10/metadata.json +6 -0
- package/test-fixtures/merge-fields/f10/record.json +25 -0
- package/test-fixtures/merge-fields/f11/expectedResult.json +40 -0
- package/test-fixtures/merge-fields/f11/metadata.json +7 -0
- package/test-fixtures/merge-fields/f11/record.json +50 -0
- package/test-fixtures/merge-fields/f12/expectedResult.json +17 -0
- package/test-fixtures/merge-fields/f12/metadata.json +6 -0
- package/test-fixtures/merge-fields/f12/record.json +25 -0
- package/test-fixtures/merge-fields/f13/expectedResult.json +18 -0
- package/test-fixtures/merge-fields/f13/metadata.json +6 -0
- package/test-fixtures/merge-fields/f13/record.json +28 -0
- package/test-fixtures/merge-fields/f14/expectedResult.json +25 -0
- package/test-fixtures/merge-fields/f14/metadata.json +6 -0
- package/test-fixtures/merge-fields/f14/record.json +25 -0
- package/test-fixtures/merge-fields/f15/expectedResult.json +8 -0
- package/test-fixtures/merge-fields/f15/metadata.json +6 -0
- package/test-fixtures/merge-fields/f15/record.json +9 -0
- package/test-fixtures/merge-fields/f16/expectedResult.json +12 -0
- package/test-fixtures/merge-fields/f16/metadata.json +7 -0
- package/test-fixtures/merge-fields/f16/record.json +13 -0
- package/test-fixtures/merge-fields/f300_01/expectedResult.json +9 -0
- package/test-fixtures/merge-fields/f300_01/metadata.json +6 -0
- package/test-fixtures/merge-fields/f300_01/record.json +8 -0
- package/test-fixtures/merge-fields/f300_02/expectedResult.json +13 -0
- package/test-fixtures/merge-fields/f300_02/metadata.json +6 -0
- package/test-fixtures/merge-fields/f300_02/record.json +16 -0
- package/test-fixtures/merge-fields/f300_03/expectedResult.json +13 -0
- package/test-fixtures/merge-fields/f300_03/metadata.json +6 -0
- package/test-fixtures/merge-fields/f300_03/record.json +16 -0
- package/test-fixtures/merge-fields/f490_01/expectedResult.json +13 -0
- package/test-fixtures/merge-fields/f490_01/metadata.json +6 -0
- package/test-fixtures/merge-fields/f490_01/record.json +16 -0
- package/test-fixtures/remove-041-zxx/01/expectedResult.json +5 -0
- package/test-fixtures/remove-041-zxx/01/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/01/record.json +10 -0
- package/test-fixtures/remove-041-zxx/02/expectedResult.json +7 -0
- package/test-fixtures/remove-041-zxx/02/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/02/record.json +9 -0
- package/test-fixtures/remove-041-zxx/11/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/11/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/11/record.json +9 -0
- package/test-fixtures/remove-041-zxx/12/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/12/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/12/record.json +9 -0
- package/test-fixtures/remove-inferior-datafields/f17/expectedResult.json +11 -0
- package/test-fixtures/remove-inferior-datafields/f17/metadata.json +5 -0
- package/test-fixtures/remove-inferior-datafields/f17/record.json +15 -0
- package/test-fixtures/remove-inferior-datafields/f18/expectedResult.json +13 -0
- package/test-fixtures/remove-inferior-datafields/f18/metadata.json +5 -0
- package/test-fixtures/remove-inferior-datafields/f18/record.json +18 -0
- package/test-fixtures/remove-inferior-datafields/f19/expectedResult.json +17 -0
- package/test-fixtures/remove-inferior-datafields/f19/metadata.json +5 -0
- package/test-fixtures/remove-inferior-datafields/f19/record.json +18 -0
- package/test-fixtures/remove-inferior-datafields/f20/expectedResult.json +15 -0
- package/test-fixtures/remove-inferior-datafields/f20/metadata.json +5 -0
- package/test-fixtures/remove-inferior-datafields/f20/record.json +29 -0
- package/test-fixtures/sort-fields/15/input.json +9 -0
- package/test-fixtures/sort-fields/15/metadata.json +5 -0
- package/test-fixtures/sort-fields/15/result.json +10 -0
- package/test-fixtures/sync-language/01/expectedResult.json +5 -0
- package/test-fixtures/sync-language/01/metadata.json +5 -0
- package/test-fixtures/sync-language/01/record.json +7 -0
- package/test-fixtures/sync-language/02/expectedResult.json +6 -0
- package/test-fixtures/sync-language/02/metadata.json +5 -0
- package/test-fixtures/sync-language/02/record.json +10 -0
- package/test-fixtures/sync-language/03/expectedResult.json +6 -0
- package/test-fixtures/sync-language/03/metadata.json +5 -0
- package/test-fixtures/sync-language/03/record.json +6 -0
- package/test-fixtures/sync-language/10/expectedResult.json +10 -0
- package/test-fixtures/sync-language/10/metadata.json +5 -0
- package/test-fixtures/sync-language/10/record.json +8 -0
- package/test-fixtures/sync-language/11/expectedResult.json +10 -0
- package/test-fixtures/sync-language/11/metadata.json +5 -0
- package/test-fixtures/sync-language/11/record.json +7 -0
- package/test-fixtures/sync-language/12/expectedResult.json +9 -0
- package/test-fixtures/sync-language/12/metadata.json +6 -0
- package/test-fixtures/sync-language/12/record.json +6 -0
- package/test-fixtures/sync-language/13/expectedResult.json +10 -0
- package/test-fixtures/sync-language/13/metadata.json +5 -0
- package/test-fixtures/sync-language/13/record.json +8 -0
- package/test-fixtures/sync-language/14/expectedResult.json +9 -0
- package/test-fixtures/sync-language/14/metadata.json +5 -0
- package/test-fixtures/sync-language/14/record.json +7 -0
- package/test-fixtures/sync-language/15/expectedResult.json +9 -0
- package/test-fixtures/sync-language/15/metadata.json +5 -0
- package/test-fixtures/sync-language/15/record.json +7 -0
- package/test-fixtures/translate-terms/05/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/05/metadata.json +7 -0
- package/test-fixtures/translate-terms/05/record.json +11 -0
- package/test-fixtures/translate-terms/06/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/06/metadata.json +7 -0
- package/test-fixtures/translate-terms/06/record.json +11 -0
- package/test-fixtures/translate-terms-data.js +23 -0
package/src/fix-33X.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import createDebugLogger from 'debug';
|
|
2
2
|
import clone from 'clone';
|
|
3
3
|
import {fieldToString, getCatalogingLanguage, nvdebug} from './utils.js';
|
|
4
4
|
import {map336CodeToTerm, map337CodeToTerm, map338CodeToTerm} from './field33XUtils.js';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:fix-33X');
|
|
7
|
+
//const debugData = debug.extend('data');
|
|
8
|
+
const debugDev = debug.extend('dev');
|
|
7
9
|
|
|
10
|
+
const description = 'Fix non-RDA 33X field(s)';
|
|
8
11
|
|
|
9
12
|
const map336 = {
|
|
10
13
|
'Bild (kartografisk ; att vidra)': 'crt',
|
|
@@ -366,6 +369,7 @@ const map338 = {
|
|
|
366
369
|
|
|
367
370
|
// const multimediaRegexp = /multimedia/ui;
|
|
368
371
|
|
|
372
|
+
// eslint-disable-next-line max-lines-per-function
|
|
369
373
|
export default function () {
|
|
370
374
|
|
|
371
375
|
return {
|
|
@@ -373,11 +377,11 @@ export default function () {
|
|
|
373
377
|
};
|
|
374
378
|
|
|
375
379
|
function fix(record) {
|
|
376
|
-
nvdebug(`FIX ${description}
|
|
380
|
+
nvdebug(`FIX ${description}...`, debugDev);
|
|
377
381
|
const catLang = getCatalogingLanguage(record) || 'fin';
|
|
378
382
|
const fields = getRelevantFields(record);
|
|
379
383
|
fields.forEach(f => fixField(f, catLang));
|
|
380
|
-
nvdebug(` GOT ${fields.length}
|
|
384
|
+
nvdebug(` GOT ${fields.length}...`, debugDev);
|
|
381
385
|
// FFS: we actually need newFields array here! Videogame, for example, might be
|
|
382
386
|
// 336 ## ‡a kaksiulotteinen liikkuva kuva ‡b tdi ‡2 rdacontent
|
|
383
387
|
// 336 ## ‡a tietokoneohjelma ‡b cop ‡2 rdacontent
|
|
@@ -387,7 +391,7 @@ export default function () {
|
|
|
387
391
|
}
|
|
388
392
|
|
|
389
393
|
function validate(record) {
|
|
390
|
-
nvdebug(`VALIDATE ${description}
|
|
394
|
+
nvdebug(`VALIDATE ${description}...`, debugDev); // NOT READY YET
|
|
391
395
|
const catLang = getCatalogingLanguage(record) || 'fin';
|
|
392
396
|
const fields = getRelevantFields(record);
|
|
393
397
|
if (fields.length === 0) {
|
|
@@ -414,7 +418,7 @@ export default function () {
|
|
|
414
418
|
|
|
415
419
|
|
|
416
420
|
function mapTermToCode(term, tag) {
|
|
417
|
-
nvdebug(`TERM/${tag}: '${term}'
|
|
421
|
+
nvdebug(`TERM/${tag}: '${term}'`, debugDev);
|
|
418
422
|
if (tag === '336' && term in map336) {
|
|
419
423
|
return map336[term];
|
|
420
424
|
}
|
package/src/fix-33X.test.js
CHANGED
|
@@ -22,7 +22,7 @@ generateTests({
|
|
|
22
22
|
async function testValidatorFactory() {
|
|
23
23
|
const validator = await validatorFactory();
|
|
24
24
|
|
|
25
|
-
assert.equal(typeof validator, '
|
|
25
|
+
assert.equal(typeof validator, 'object');
|
|
26
26
|
assert.equal(typeof validator.description, 'string');
|
|
27
27
|
assert.equal(typeof validator.validate, 'function');
|
|
28
28
|
assert.equal(typeof validator.fix, 'function');
|
package/src/fix-country-codes.js
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Author(s): Nicholas Volk
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import createDebugLogger from 'debug';
|
|
8
|
+
import {nvdebug} from './utils.js';
|
|
9
|
+
|
|
10
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:fix-country-codes');
|
|
11
|
+
//const debugData = debug.extend('data');
|
|
12
|
+
const debugDev = debug.extend('dev');
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
export default function () {
|
|
@@ -16,7 +20,7 @@ export default function () {
|
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
function fix(record) {
|
|
19
|
-
|
|
23
|
+
nvdebug(`FIX ME:`, debugDev);
|
|
20
24
|
const res = {message: [], fix: [], valid: true};
|
|
21
25
|
|
|
22
26
|
const [field008] = record.get('008');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './fix-country-codes.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix-country-codes:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix-country-codes:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
const record = new MarcRecord(getFixture('record.json'));
|
|
40
35
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import clone from 'clone';
|
|
2
|
-
import {fieldToString} from './utils.js';
|
|
2
|
+
import {fieldToString, nvdebug} from './utils.js';
|
|
3
|
+
import createDebugLogger from 'debug';
|
|
4
|
+
|
|
3
5
|
// Fix language codes in 008/35-37 and 041 (does not sync them)
|
|
4
6
|
//
|
|
5
7
|
// Author(s): Nicholas Volk
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:fix-language-codes');
|
|
10
|
+
//const debugData = debug.extend('data');
|
|
11
|
+
const debugDev = debug.extend('dev');
|
|
9
12
|
|
|
10
13
|
const description = 'Fix language codes';
|
|
11
14
|
|
|
15
|
+
// eslint-disable-next-line max-lines-per-function
|
|
12
16
|
export default function () {
|
|
13
17
|
|
|
14
18
|
return {description, validate, fix};
|
|
15
19
|
|
|
16
20
|
function fix(record) {
|
|
17
|
-
|
|
21
|
+
nvdebug(`FIX ME`, debugDev);
|
|
18
22
|
const res = {message: [], fix: [], valid: true};
|
|
19
23
|
|
|
20
24
|
const [field008] = record.get('008');
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Author(s): Nicholas Volk
|
|
2
|
+
|
|
3
|
+
import createDebugLogger from 'debug';
|
|
4
|
+
import clone from 'clone';
|
|
5
|
+
|
|
6
|
+
import {fieldToString, nvdebug} from './utils.js';
|
|
7
|
+
|
|
8
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:fix-sami-041');
|
|
9
|
+
//const debugData = debug.extend('data');
|
|
10
|
+
const debugDev = debug.extend('dev');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line max-lines-per-function
|
|
14
|
+
export default function () {
|
|
15
|
+
/* 'sma': eteläsaame, 'sme': pohjoissaame, 'smj': luulajansaame, 'smn': inarinsaame, 'sms': koltansaame */
|
|
16
|
+
const samiLanguages = ['sma', 'sme', 'smj', 'smn', 'sms'];
|
|
17
|
+
const subfieldCodesUsingSmi = ['a', 'd'];
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
description: 'Add corresponding \'smi\' subfield before a specific sami language subfields and update 008/35-37, if needed',
|
|
21
|
+
validate, fix
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function getRelevantSubfieldCodes(record) { // Maybe this should be an exportable utility function...
|
|
25
|
+
if (record && record.leader && record.leader[6]) {
|
|
26
|
+
nvdebug(` LDR/06 is '${record.leader[6]}'`, debugDev);
|
|
27
|
+
// We should test this properly...
|
|
28
|
+
if (['i', 'j'].includes(record.leader[6])) { // Check type of record: sound recordings use 'd'
|
|
29
|
+
return ['d'];
|
|
30
|
+
}
|
|
31
|
+
return ['a'];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return ['a', 'd']; // Både-och
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function fix(record, validateMode = false) {
|
|
39
|
+
nvdebug(`Start ${validateMode ? 'validator' : 'fixer'}`, debugDev);
|
|
40
|
+
const relevantSubfieldCodes = getRelevantSubfieldCodes(record);
|
|
41
|
+
nvdebug(` Relevant subfield codes are '${relevantSubfieldCodes.join("', '")}'`, debugDev);
|
|
42
|
+
const relevantFields = record.fields.filter(f => isRelevantField(f, relevantSubfieldCodes)).map(f => validateMode ? clone(f) : f); // NV! relevant fields are cloned in validation mode!
|
|
43
|
+
// Nothing to do:
|
|
44
|
+
if (relevantFields.length === 0) {
|
|
45
|
+
nvdebug(` No relevant f041 fields found`, debugDev);
|
|
46
|
+
if (validateMode) {
|
|
47
|
+
return {message: [], valid: true};
|
|
48
|
+
}
|
|
49
|
+
return {message: [], fix: [], valid: true};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const relevantFieldsAsStrings = relevantFields.map(f => fieldToString(f)); // get original values
|
|
53
|
+
|
|
54
|
+
relevantFields.forEach(f => processField(f, relevantSubfieldCodes));
|
|
55
|
+
const modFieldsAsStrings = relevantFields.map(f => fieldToString(f));
|
|
56
|
+
const report = [...updateAndReport008(), ...createReport(relevantFieldsAsStrings, modFieldsAsStrings)];
|
|
57
|
+
|
|
58
|
+
if (validateMode) {
|
|
59
|
+
return {'message': report, 'valid': false};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {message: [], fix: report, valid: true};
|
|
63
|
+
|
|
64
|
+
function updateAndReport008() { // Update 008/35-37 if necessary + report it
|
|
65
|
+
const [f008] = record.get('008').map(f => validateMode ? clone(f) : f);
|
|
66
|
+
|
|
67
|
+
if (!f008) {
|
|
68
|
+
nvdebug(' WARNING: no f008 found'), debugDev;
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
const currLang = f008.value.substr(35, 3);
|
|
72
|
+
if (!samiLanguages.includes(currLang)) { // NB! If original 008/35-37 was not a sami language, we don't change anything!
|
|
73
|
+
nvdebug(` Existing 008/35-37 '${currLang}' is not a sami language. No need to update 008/35-37`, debugDev);
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const origValue = f008.value;
|
|
77
|
+
const firstRelevantSubfield = relevantFields[0].subfields.find(sf => relevantSubfieldCodes.includes(sf.code));
|
|
78
|
+
if (firstRelevantSubfield.value !== 'smi') {
|
|
79
|
+
nvdebug(` First relevant subfield is '\$${firstRelevantSubfield.code} ${firstRelevantSubfield.value}'. No need to update 008/35-37`, debugDev);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
f008.value = `${f008.value.substr(0, 35)}smi${f008.value.substr(38)}`;
|
|
83
|
+
nvdebug(` Update 008/35-37: '${currLang}' => 'smi'`, debugDev);
|
|
84
|
+
return createReport([origValue], [f008.value]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function processField(f) {
|
|
88
|
+
f.subfields = processSubfields(f.subfields, []);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function processSubfields(incomingSubfields, outgoingSubfields = []) {
|
|
92
|
+
const [currSubfield, ...otherSubfields] = incomingSubfields;
|
|
93
|
+
if (!currSubfield) {
|
|
94
|
+
return outgoingSubfields;
|
|
95
|
+
}
|
|
96
|
+
if (!isRelevantSamiSubfield(currSubfield, [...outgoingSubfields, ...otherSubfields])) {
|
|
97
|
+
return processSubfields(otherSubfields, [...outgoingSubfields, currSubfield]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const smiSubfield = {
|
|
101
|
+
code: currSubfield.code,
|
|
102
|
+
value: 'smi'
|
|
103
|
+
};
|
|
104
|
+
nvdebug(` f041: Add '\$${currSubfield.code} smi' before '${currSubfield.value}'`, debugDev);
|
|
105
|
+
|
|
106
|
+
return processSubfields(otherSubfields, [...outgoingSubfields, smiSubfield, currSubfield]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isRelevantField(f) {
|
|
110
|
+
if (f.tag !== '041' || !f.subfields || f.subfields.some(sf => sf.code === '2')) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return f.subfields.some(sf => isRelevantSamiSubfield(sf, f.subfields)); // it's ok to pass sf in f.subfields also
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isRelevantSamiSubfield(sf, otherSubfields) {
|
|
117
|
+
// NB! preceding 'smi' is added to all $a and $d fields, regardless of the LDR/06 value! (However, copying 041$a/d -> 008/35-37 depends on LDR/06)
|
|
118
|
+
if (!subfieldCodesUsingSmi.includes(sf.code) || !samiLanguages.includes(sf.value)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (otherSubfields.some(sf2 => sf2.code === sf.code && sf2.value === 'smi')) { // fail if 'smi' already exists
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
//debug(` '\${sf.code} ${sf.value}' requires preceding 'smi'`);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function createReport(origArray, modArray) {
|
|
130
|
+
return origArray.map((entry, index) => createEntry(entry, index));
|
|
131
|
+
|
|
132
|
+
function createEntry(item, index) {
|
|
133
|
+
return `'${item}' => '${modArray[index]}'`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function validate(record) {
|
|
138
|
+
return fix(record, true);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
//import createDebugLogger from 'debug';
|
|
3
|
+
|
|
4
|
+
import validatorFactory from './fix-sami-041.js';
|
|
5
|
+
|
|
6
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
7
|
+
import {READERS} from '@natlibfi/fixura';
|
|
8
|
+
import generateTests from '@natlibfi/fixugen';
|
|
9
|
+
|
|
10
|
+
generateTests({
|
|
11
|
+
callback,
|
|
12
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'fix-sami-041'],
|
|
13
|
+
useMetadataFile: true,
|
|
14
|
+
recurse: false,
|
|
15
|
+
fixura: {
|
|
16
|
+
reader: READERS.JSON
|
|
17
|
+
},
|
|
18
|
+
hooks: {
|
|
19
|
+
before: async () => {
|
|
20
|
+
testValidatorFactory();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/drop-terms:test');
|
|
26
|
+
|
|
27
|
+
async function testValidatorFactory() {
|
|
28
|
+
const validator = await validatorFactory();
|
|
29
|
+
|
|
30
|
+
assert.equal(typeof validator, 'object');
|
|
31
|
+
assert.equal(typeof validator.description, 'string');
|
|
32
|
+
assert.equal(typeof validator.validate, 'function');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function callback({getFixture, fix = false}) {
|
|
36
|
+
const validator = await validatorFactory();
|
|
37
|
+
const record = new MarcRecord(getFixture('record.json'));
|
|
38
|
+
const expectedResult = getFixture('expectedResult.json');
|
|
39
|
+
//const expectedResult = new MarcRecord(getFixture('expectedResult.json'));
|
|
40
|
+
// console.log(expectedResult); // eslint-disable-line
|
|
41
|
+
|
|
42
|
+
if (!fix) {
|
|
43
|
+
const result = await validator.validate(record);
|
|
44
|
+
assert.deepEqual(result, expectedResult);
|
|
45
|
+
const originalRecord = new MarcRecord(getFixture('record.json'));
|
|
46
|
+
assert.deepEqual(record, originalRecord); // The record should now change in validation-only
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await validator.fix(record);
|
|
51
|
+
assert.deepEqual(record, new MarcRecord(expectedResult));
|
|
52
|
+
}
|
package/src/fixRelatorTerms.js
CHANGED
|
@@ -69,6 +69,9 @@ export default () => (base, source) => {
|
|
|
69
69
|
// https://wiki.helsinki.fi/display/MARC21svenska/Funktions-+och+relationskoder+-+alfabetiskt+efter+funktion
|
|
70
70
|
// New, better source: https://id.kb.se/find?q=relator&_sort=_sortKeyByLang.en
|
|
71
71
|
|
|
72
|
+
// NOTE: There are problematic relatorterms that do not diffrentiate between agent+work vs agent+ekspression relation
|
|
73
|
+
// ie. teoksen haastattelija vs haastattelija (ekspressio)
|
|
74
|
+
// current solution ignores them and handles just "plain" relator terms
|
|
72
75
|
|
|
73
76
|
// NB! How to handle German sex-based Verfasser/Verfasserin pairs?
|
|
74
77
|
const relatorTerms = [
|
|
@@ -80,6 +83,8 @@ const relatorTerms = [
|
|
|
80
83
|
{'code': 'drt', 'eng': 'director', 'fin': 'ohjaaja', 'swe': 'regissör'},
|
|
81
84
|
{'code': 'edt', 'eng': 'editor', 'fin': 'toimittaja', 'swe': 'redaktör'},
|
|
82
85
|
{'code': 'ill', 'eng': 'illustrator', 'fin': 'kuvittaja', 'swe': 'illustratör'},
|
|
86
|
+
{'code': 'ive', 'eng': 'interviewee', 'fin': 'haastateltava', 'swe': 'intervjuobjekt'},
|
|
87
|
+
{'code': 'ivr', 'eng': 'interviewer', 'fin': 'haastattelija', 'swe': 'intervjuare'},
|
|
83
88
|
{'code': 'lyr', 'eng': 'lyricist', 'fin': 'sanoittaja', 'swe': 'sångtext'},
|
|
84
89
|
{'code': 'nrt', 'eng': 'narrator', 'fin': 'kertoja', 'swe': 'berättare'}, // berättare/inläsare
|
|
85
90
|
{'code': 'pbl', 'eng': 'publisher', 'fin': 'julkaisija', 'swe': 'utgivare'},
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './fixRelatorTerms.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fixRelatorTerms:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fixRelatorTerms:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
package/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import Fix33X from './fix-33X.js';
|
|
|
21
21
|
import FixCountryCodes from './fix-country-codes.js';
|
|
22
22
|
import FixLanguageCodes from './fix-language-codes.js';
|
|
23
23
|
import FixRelatorTerms from './fixRelatorTerms.js';
|
|
24
|
+
import FixSami041 from './fix-sami-041.js';
|
|
24
25
|
import FixedFields from './fixed-fields.js';
|
|
25
26
|
import IdenticalFields from './identical-fields.js';
|
|
26
27
|
import IndicatorFixes from './indicator-fixes.js';
|
|
@@ -39,6 +40,7 @@ import NormalizeUTF8Diacritics from './normalize-utf8-diacritics.js';
|
|
|
39
40
|
import Punctuation from './punctuation/index.js';
|
|
40
41
|
import Punctuation2 from './punctuation2.js';
|
|
41
42
|
import ReindexSubfield6OccurenceNumbers from './reindexSubfield6OccurenceNumbers.js';
|
|
43
|
+
import Remove041zxx from './remove-041-zxx.js';
|
|
42
44
|
import RemoveDuplicateDataFields from './removeDuplicateDataFields.js';
|
|
43
45
|
import RemoveInferiorDataFields from './removeInferiorDataFields.js';
|
|
44
46
|
import ResolvableExtReferences from './resolvable-ext-references-melinda.js';
|
|
@@ -52,6 +54,7 @@ import SortTags from './sort-tags.js';
|
|
|
52
54
|
import SubfieldValueNormalizations from './subfieldValueNormalizations.js';
|
|
53
55
|
import SubfieldExclusion from './subfield-exclusion.js';
|
|
54
56
|
import Sync007And300 from './sync-007-and-300.js';
|
|
57
|
+
import SyncLanguage from './sync-language.js';
|
|
55
58
|
import TranslateTerms from './translate-terms.js';
|
|
56
59
|
import TypeOfDateF008 from './typeOfDate-008.js';
|
|
57
60
|
import UnicodeDecomposition from './unicode-decomposition.js';
|
|
@@ -62,9 +65,9 @@ import {getCounterpart} from './merge-fields/counterpartField.js';
|
|
|
62
65
|
|
|
63
66
|
import {postprocessRecords} from './merge-fields/mergeOrAddPostprocess.js';
|
|
64
67
|
import {mergeField} from './merge-fields/mergeField.js';
|
|
65
|
-
import {fieldGetOccurrenceNumberPairs, fieldGetUnambiguousOccurrenceNumber, fieldToNormalizedString, fieldsToNormalizedString, get6s,
|
|
66
|
-
isValidSubfield6,
|
|
67
|
-
|
|
68
|
+
import {fieldGetOccurrenceNumberPairs, fieldGetUnambiguousOccurrenceNumber, fieldHasValidSubfield6, fieldToNormalizedString, fieldsToNormalizedString, get6s,
|
|
69
|
+
isSubfield6Pair, isValidSubfield6, intToOccurrenceNumberString,
|
|
70
|
+
recordGetMaxSubfield6OccurrenceNumberAsInteger, resetSubfield6Tag, subfield6ResetOccurrenceNumber, subfield6GetOccurrenceNumber,
|
|
68
71
|
subfield6GetOccurrenceNumberAsInteger} from './subfield6Utils.js';
|
|
69
72
|
|
|
70
73
|
import {getSubfield8LinkingNumber, isValidSubfield8, recordGetAllSubfield8LinkingNumbers, recordGetFieldsWithSubfield8LinkingNumber} from './subfield8Utils.js';
|
|
@@ -72,14 +75,14 @@ import {getSubfield8LinkingNumber, isValidSubfield8, recordGetAllSubfield8Linkin
|
|
|
72
75
|
import {recordFixRelatorTerms} from './fixRelatorTerms.js';
|
|
73
76
|
import {fieldTrimSubfieldValues} from './normalizeFieldForComparison.js';
|
|
74
77
|
import {baseHasEqualOrHigherEncodingLevel, deleteAllPrepublicationNotesFromField500InNonPubRecord, encodingLevelIsBetterThanPrepublication, getEncodingLevel, isEnnakkotietoField, isEnnakkotietoSubfield} from './prepublicationUtils.js';
|
|
75
|
-
import {melindaFieldSpecs} from '
|
|
78
|
+
import {melindaFieldSpecs} from './melindaCustomMergeFields.js';
|
|
76
79
|
|
|
77
80
|
import {cloneAndRemovePunctuation} from './normalizeFieldForComparison.js';
|
|
78
81
|
import {removeWorsePrepubField500s, removeWorsePrepubField594s} from './prepublicationUtils.js';
|
|
79
82
|
import {fieldFixPunctuation} from './punctuation2.js';
|
|
80
83
|
import {recordResetSubfield6OccurrenceNumbers} from './reindexSubfield6OccurenceNumbers.js';
|
|
81
84
|
import {sortAdjacentSubfields} from './sortSubfields.js';
|
|
82
|
-
import {fieldsToString} from './utils.js';
|
|
85
|
+
import {fieldHasSubfield, fieldToString, fieldsToString, isContentSubfieldCode, tagIsRepeatable} from './utils.js';
|
|
83
86
|
|
|
84
87
|
export {
|
|
85
88
|
AccessRights,
|
|
@@ -105,11 +108,13 @@ export {
|
|
|
105
108
|
FixCountryCodes,
|
|
106
109
|
FixLanguageCodes,
|
|
107
110
|
FixRelatorTerms,
|
|
111
|
+
FixSami041,
|
|
108
112
|
FixedFields,
|
|
109
113
|
IdenticalFields,
|
|
110
114
|
IndicatorFixes,
|
|
111
115
|
IsbnIssn,
|
|
112
116
|
ItemLanguage,
|
|
117
|
+
|
|
113
118
|
MergeField500Lisapainokset,
|
|
114
119
|
MergeRelatorTermFields,
|
|
115
120
|
Modernize502, //
|
|
@@ -123,6 +128,7 @@ export {
|
|
|
123
128
|
Punctuation2,
|
|
124
129
|
ResolveOrphanedSubfield6s, // Do this before reindexing! (thus I'm not sticking with alphabetical order here)
|
|
125
130
|
ReindexSubfield6OccurenceNumbers,
|
|
131
|
+
Remove041zxx,
|
|
126
132
|
RemoveDuplicateDataFields,
|
|
127
133
|
RemoveInferiorDataFields,
|
|
128
134
|
ResolvableExtReferences,
|
|
@@ -133,8 +139,9 @@ export {
|
|
|
133
139
|
SubfieldExclusion,
|
|
134
140
|
SubfieldValueNormalizations,
|
|
135
141
|
Sync007And300,
|
|
136
|
-
|
|
142
|
+
SyncLanguage,
|
|
137
143
|
TranslateTerms,
|
|
144
|
+
TypeOfDateF008,
|
|
138
145
|
UnicodeDecomposition,
|
|
139
146
|
UpdateField540,
|
|
140
147
|
Urn,
|
|
@@ -146,15 +153,19 @@ export {
|
|
|
146
153
|
// 1. generic low level stuff
|
|
147
154
|
getEncodingLevel,
|
|
148
155
|
|
|
149
|
-
// 2. text normalizations (eg. for similarity comparisons, field merge)
|
|
156
|
+
// 2. text normalizations + other generic utils (eg. for similarity comparisons, field merge)
|
|
150
157
|
cloneAndRemovePunctuation,
|
|
151
158
|
fieldFixPunctuation,
|
|
159
|
+
fieldHasSubfield,
|
|
152
160
|
fieldToNormalizedString,
|
|
161
|
+
fieldToString,
|
|
153
162
|
fieldTrimSubfieldValues,
|
|
154
163
|
fieldsToNormalizedString,
|
|
155
164
|
fieldsToString,
|
|
165
|
+
isContentSubfieldCode,
|
|
156
166
|
recordFixRelatorTerms,
|
|
157
167
|
sortAdjacentSubfields,
|
|
168
|
+
tagIsRepeatable,
|
|
158
169
|
|
|
159
170
|
// 3. prepublication stuff
|
|
160
171
|
baseHasEqualOrHigherEncodingLevel,
|
|
@@ -169,7 +180,9 @@ export {
|
|
|
169
180
|
fieldGetOccurrenceNumberPairs,
|
|
170
181
|
get6s,
|
|
171
182
|
fieldGetUnambiguousOccurrenceNumber,
|
|
183
|
+
fieldHasValidSubfield6,
|
|
172
184
|
intToOccurrenceNumberString,
|
|
185
|
+
isSubfield6Pair,
|
|
173
186
|
isValidSubfield6,
|
|
174
187
|
recordGetMaxSubfield6OccurrenceNumberAsInteger,
|
|
175
188
|
recordResetSubfield6OccurrenceNumbers,
|
package/src/indicator-fixes.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// Relocated from melinda-marc-record-merge-reducers (and renamed)
|
|
2
|
-
//import createDebugLogger from 'debug';
|
|
3
|
-
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:normalizeIdentifiers');
|
|
4
2
|
|
|
5
|
-
import
|
|
3
|
+
import createDebugLogger from 'debug';
|
|
4
|
+
import {fieldToString, nvdebug} from './utils.js';
|
|
6
5
|
|
|
7
6
|
|
|
7
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:indicator-fixes');
|
|
8
|
+
const debugData = debug.extend('data');
|
|
9
|
+
//const debugDev = debug.extend('dev');
|
|
10
|
+
|
|
8
11
|
export default function () {
|
|
9
12
|
|
|
10
13
|
return {
|
|
@@ -31,7 +34,7 @@ export default function () {
|
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
function validateRecord(record, res) {
|
|
34
|
-
|
|
37
|
+
nvdebug(record, debugData);
|
|
35
38
|
const clonedFields = JSON.parse(JSON.stringify(record.fields));
|
|
36
39
|
recordNormalizeIndicators(record);
|
|
37
40
|
|
|
@@ -41,11 +44,11 @@ export default function () {
|
|
|
41
44
|
const origFieldAsString = fieldToString(clonedFields[index]);
|
|
42
45
|
//const clonedFieldAsString = fieldToString(field);
|
|
43
46
|
if (clonedFields[index].ind1 !== field.ind1) {
|
|
44
|
-
//nvdebug(`FIX IND1: '${clonedFields[index].ind1}' => '${field.ind1}': ${clonedFieldAsString}
|
|
47
|
+
//nvdebug(`FIX IND1: '${clonedFields[index].ind1}' => '${field.ind1}': ${clonedFieldAsString}`, debugDev);
|
|
45
48
|
res.message.push(`Expected IND1 for '${origFieldAsString}' is '${field.ind1}'`);
|
|
46
49
|
}
|
|
47
50
|
if (clonedFields[index].ind2 !== field.ind2) {
|
|
48
|
-
//nvdebug(`FIX IND2: '${clonedFields[index].ind2}' => '${field.ind2}': ${clonedFieldAsString}
|
|
51
|
+
//nvdebug(`FIX IND2: '${clonedFields[index].ind2}' => '${field.ind2}': ${clonedFieldAsString}`, debugDev);
|
|
49
52
|
res.message.push(`Expected IND2 for '${origFieldAsString}' is '${field.ind2}'`);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -79,7 +82,7 @@ function valueBeginsWithDeterminer(value, cands) {
|
|
|
79
82
|
function determineNonFilingIndicatorValue(field, languages = undefined) {
|
|
80
83
|
const subfieldA = field.subfields.find(sf => sf.code === 'a');
|
|
81
84
|
if (!subfieldA) {
|
|
82
|
-
// nvdebug(' Subfield $a miss!');
|
|
85
|
+
// nvdebug(' Subfield $a miss!', debugDev);
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -241,6 +244,17 @@ function getLanguages(record) {
|
|
|
241
244
|
|
|
242
245
|
}
|
|
243
246
|
|
|
247
|
+
function translated041Indicator1(field){
|
|
248
|
+
if (field.tag !== '041' || !field.subfields) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (field.ind1 !== '1' && field.subfields.some(sf => ['h', 'k', 'm', 'n'].includes(sf.code))) {
|
|
252
|
+
field.ind1 = '1';
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
244
258
|
function recordNormalizeIndicators(record) {
|
|
245
259
|
recordNormalize490(record);
|
|
246
260
|
|
|
@@ -252,6 +266,7 @@ function recordNormalizeIndicators(record) {
|
|
|
252
266
|
}
|
|
253
267
|
|
|
254
268
|
function fieldNormalizeIndicators(field, record, languages) {
|
|
269
|
+
translated041Indicator1(field);
|
|
255
270
|
normalize084Indicator1(field);
|
|
256
271
|
normalize245Indicator1(field, record);
|
|
257
272
|
noDisplayConstantGenerated520Indicator1(field);
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './indicator-fixes.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -17,7 +17,7 @@ generateTests({
|
|
|
17
17
|
before: () => testValidatorFactory()
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/indicator-fixes:test');
|
|
20
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/indicator-fixes:test');
|
|
21
21
|
|
|
22
22
|
async function testValidatorFactory() {
|
|
23
23
|
const validator = await validatorFactory();
|
|
@@ -27,12 +27,7 @@ async function testValidatorFactory() {
|
|
|
27
27
|
assert.equal(typeof validator.validate, 'function');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async function callback({getFixture,
|
|
31
|
-
if (enabled === false) {
|
|
32
|
-
debug('TEST SKIPPED!');
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
30
|
+
async function callback({getFixture, fix = false}) {
|
|
36
31
|
const validator = await validatorFactory();
|
|
37
32
|
const record = new MarcRecord(getFixture('record.json'));
|
|
38
33
|
const expectedResult = getFixture('expectedResult.json');
|