@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
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './mergeRelatorTermFields.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/mergeRelatorTermFields:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/mergeRelatorTermFields: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');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './multiple-subfield-0.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/multiple-subfield-0:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/multiple-subfield-0: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/normalize-dashes.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
//import createDebugLogger from 'debug';
|
|
2
1
|
import clone from 'clone';
|
|
3
|
-
import {fieldToString,
|
|
2
|
+
import {fieldToString, isContentSubfieldCode, nvdebug} from './utils.js';
|
|
3
|
+
|
|
4
|
+
import createDebugLogger from 'debug';
|
|
5
|
+
|
|
6
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:normaliza-dashes');
|
|
7
|
+
//const debugData = debug.extend('data');
|
|
8
|
+
const debugDev = debug.extend('dev');
|
|
9
|
+
|
|
4
10
|
|
|
5
11
|
// Author(s): Nicholas Volk
|
|
6
12
|
export default function () {
|
|
@@ -11,7 +17,7 @@ export default function () {
|
|
|
11
17
|
};
|
|
12
18
|
|
|
13
19
|
function fix(record) {
|
|
14
|
-
nvdebug(`FIX ME
|
|
20
|
+
nvdebug(`FIX ME`, debugDev);
|
|
15
21
|
record.fields.forEach(field => {
|
|
16
22
|
fixDashes(field);
|
|
17
23
|
});
|
|
@@ -23,7 +29,7 @@ export default function () {
|
|
|
23
29
|
function validate(record) {
|
|
24
30
|
const res = {message: []};
|
|
25
31
|
|
|
26
|
-
nvdebug(`VALIDATE ME
|
|
32
|
+
nvdebug(`VALIDATE ME`, debugDev);
|
|
27
33
|
record.fields?.forEach(field => {
|
|
28
34
|
validateField(field, res);
|
|
29
35
|
});
|
|
@@ -34,7 +40,7 @@ export default function () {
|
|
|
34
40
|
|
|
35
41
|
function validateField(field, res) {
|
|
36
42
|
const orig = fieldToString(field);
|
|
37
|
-
nvdebug(` VALIDATE FIELD '${orig}'
|
|
43
|
+
nvdebug(` VALIDATE FIELD '${orig}'`, debugDev);
|
|
38
44
|
|
|
39
45
|
const normalizedField = fixDashes(clone(field));
|
|
40
46
|
const mod = fieldToString(normalizedField);
|
|
@@ -52,14 +58,14 @@ function fixDashes(field) {
|
|
|
52
58
|
return field;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
nvdebug(`Dashing ${fieldToString(field)}
|
|
61
|
+
nvdebug(`Dashing ${fieldToString(field)}`, debugDev);
|
|
56
62
|
|
|
57
63
|
field.subfields.forEach(sf => subfieldFixDashes(sf));
|
|
58
64
|
|
|
59
65
|
return field;
|
|
60
66
|
|
|
61
67
|
function subfieldFixDashes(subfield) {
|
|
62
|
-
if (
|
|
68
|
+
if (!isContentSubfieldCode(subfield.code, field.tag)) {
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
71
|
// Normalize dashes U+2010 ... U+2015 to '-':
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './normalize-dashes.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/normalize-dashes:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/normalize-dashes: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,17 +1,10 @@
|
|
|
1
1
|
// Relocated from melinda-marc-record-merge-reducers (and renamed)
|
|
2
|
-
//import createDebugLogger from 'debug';
|
|
3
2
|
import clone from 'clone';
|
|
4
|
-
import {fieldToString} from './utils.js';
|
|
5
|
-
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:normalize-identifiers');
|
|
3
|
+
import {fieldToString, /*nvdebug*/} from './utils.js';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
func(message);
|
|
11
|
-
}
|
|
12
|
-
console.info(message); // eslint-disable-line no-console
|
|
13
|
-
}
|
|
14
|
-
*/
|
|
5
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:normalize-identifiers');
|
|
6
|
+
//const debugData = debug.extend('data');
|
|
7
|
+
//const debugDev = debug.extend('dev');
|
|
15
8
|
|
|
16
9
|
export default function () {
|
|
17
10
|
|
|
@@ -32,9 +25,9 @@ export default function () {
|
|
|
32
25
|
}
|
|
33
26
|
*/
|
|
34
27
|
|
|
35
|
-
//nvdebug(`NORMALIZE CONTROL NUMBER FIX`,
|
|
28
|
+
//nvdebug(`NORMALIZE CONTROL NUMBER FIX`, debugDev);
|
|
36
29
|
record.fields.forEach(field => {
|
|
37
|
-
//nvdebug(` NORMALIZE CONTROL NUMBER FIX ${fieldToString(field)}`,
|
|
30
|
+
//nvdebug(` NORMALIZE CONTROL NUMBER FIX ${fieldToString(field)}`, debugDev);
|
|
38
31
|
|
|
39
32
|
fieldNormalizeControlNumbers(field);
|
|
40
33
|
//validateField(field, true, message);
|
|
@@ -46,7 +39,7 @@ export default function () {
|
|
|
46
39
|
|
|
47
40
|
function validate(record) {
|
|
48
41
|
const res = {message: []};
|
|
49
|
-
//nvdebug(`NORMALIZE CONTROL NUMBER VALIDATE`,
|
|
42
|
+
//nvdebug(`NORMALIZE CONTROL NUMBER VALIDATE`, debugDev);
|
|
50
43
|
// Actual parsing of all fields
|
|
51
44
|
/*
|
|
52
45
|
if (!record.fields) {
|
|
@@ -55,7 +48,7 @@ export default function () {
|
|
|
55
48
|
*/
|
|
56
49
|
|
|
57
50
|
record.fields.forEach(field => {
|
|
58
|
-
//nvdebug(` NORMALIZE CONTROL NUMBER VALIDATE ${fieldToString(field)}`,
|
|
51
|
+
//nvdebug(` NORMALIZE CONTROL NUMBER VALIDATE ${fieldToString(field)}`, debugDev);
|
|
59
52
|
validateField(field, res);
|
|
60
53
|
});
|
|
61
54
|
|
|
@@ -126,8 +119,8 @@ function normalizeNineDigitIDs(value, targetFormat = 'ALEPH_INTERNAL') {
|
|
|
126
119
|
const currPrefix = value.slice(0, -9);
|
|
127
120
|
|
|
128
121
|
if (currPrefix in mappings) {
|
|
129
|
-
//nvdebug(`${currPrefix}, TF:${targetFormat}
|
|
130
|
-
//nvdebug(`${JSON.stringify(mappings[currPrefix])}
|
|
122
|
+
//nvdebug(`${currPrefix}, TF:${targetFormat}...`, debugDev);
|
|
123
|
+
//nvdebug(`${JSON.stringify(mappings[currPrefix])}`, debugDev);
|
|
131
124
|
return `${mappings[currPrefix][targetFormat]}${nineDigitTail}`;
|
|
132
125
|
}
|
|
133
126
|
return value;
|
|
@@ -167,7 +160,7 @@ export function normalizeControlSubfieldValue(value = '', targetFormat = 'ALEPH_
|
|
|
167
160
|
|
|
168
161
|
//export function normalizableSubfieldPrefix(tag, sf) {
|
|
169
162
|
export function normalizeAs(tag, subfieldCode) {
|
|
170
|
-
//nvdebug(`nAs ${tag}, ${subfieldCode}
|
|
163
|
+
//nvdebug(`nAs ${tag}, ${subfieldCode}`, debugDev);
|
|
171
164
|
if (subfieldCode === '0' || subfieldCode === '1' || subfieldCode === 'w') {
|
|
172
165
|
return 'ALEPH_INTERNAL';
|
|
173
166
|
}
|
|
@@ -189,7 +182,7 @@ export function fieldNormalizeControlNumbers(field) {
|
|
|
189
182
|
field.subfields.forEach(sf => {
|
|
190
183
|
const targetFormat = normalizeAs(field.tag, sf.code);
|
|
191
184
|
if (targetFormat !== undefined) {
|
|
192
|
-
//nvdebug(`NORMALIZE SUBFIELD $${sf.code} IN FIELD: '${fieldToString(field)}' TO ${targetFormat}
|
|
185
|
+
//nvdebug(`NORMALIZE SUBFIELD $${sf.code} IN FIELD: '${fieldToString(field)}' TO ${targetFormat}`, debugDev);
|
|
193
186
|
sf.value = normalizeControlSubfieldValue(sf.value, targetFormat);
|
|
194
187
|
return;
|
|
195
188
|
}
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './normalize-identifiers.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/normalize-identifiers:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/normalize-identifiers: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');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './normalize-qualifying-information.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/normalize-qualifying-information:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/normalize-qualifying-information: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,12 +1,15 @@
|
|
|
1
1
|
//import createDebugLogger from 'debug';
|
|
2
2
|
import clone from 'clone';
|
|
3
3
|
import {convert as nongenericNormalization} from './unicode-decomposition.js';
|
|
4
|
-
import {fieldToString} from './utils.js';
|
|
4
|
+
import {fieldToString /*, nvdebug */} from './utils.js';
|
|
5
5
|
|
|
6
6
|
// Note that https://github.com/NatLibFi/marc-record-validators-melinda/blob/master/src/unicode-decomposition.js contains
|
|
7
7
|
// similar functionalities. It's less generic and lacks diacritic removal but has it advantages as well.
|
|
8
8
|
|
|
9
9
|
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/normalize-utf-diacritics');
|
|
10
|
+
//const debugData = debug.extend('data');
|
|
11
|
+
//const debugDev = debug.extend('dev');
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
// See also https://github.com/NatLibFi/marc-record-validators-melinda/blob/master/src/unicode-decomposition.js .
|
|
12
15
|
// It uses a list of convertable characters whilst this uses a generic stuff as well.
|
|
@@ -111,13 +114,13 @@ export function fieldFixComposition(field) {
|
|
|
111
114
|
return field;
|
|
112
115
|
}
|
|
113
116
|
//const originalValue = fieldToString(field);
|
|
114
|
-
//nvdebug(`fFC: '${originalValue}'`,
|
|
117
|
+
//nvdebug(`fFC: '${originalValue}'`, debugDev);
|
|
115
118
|
field.subfields.forEach((subfield, index) => {
|
|
116
119
|
field.subfields[index].value = fixComposition(subfield.value);
|
|
117
120
|
});
|
|
118
121
|
//const newValue = fieldToString(field);
|
|
119
122
|
//if (originalValue !== newValue) {
|
|
120
|
-
//
|
|
123
|
+
// nvdebug(`FIXCOMP: '${originalValue}' => '${newValue}'`, debugDev);
|
|
121
124
|
//}
|
|
122
125
|
return field;
|
|
123
126
|
}
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './normalize-utf8-diacritics.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/normalize-utf8-diacritics:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/normalize-utf8-diacritics: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');
|
|
@@ -8,26 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import clone from 'clone';
|
|
10
10
|
import {fieldStripPunctuation} from './punctuation2.js';
|
|
11
|
-
import {fieldToString,
|
|
11
|
+
import {fieldToString, isContentSubfieldCode} from './utils.js';
|
|
12
12
|
|
|
13
13
|
import {fieldNormalizeControlNumbers/*, normalizeControlSubfieldValue*/} from './normalize-identifiers.js';
|
|
14
14
|
import createDebugLogger from 'debug';
|
|
15
15
|
import {normalizePartData, subfieldContainsPartData} from './normalizeSubfieldValueForComparison.js';
|
|
16
|
+
import {isEnnakkotietoSubfield} from './prepublicationUtils.js';
|
|
17
|
+
import {getSynonym} from './merge-fields/worldKnowledge.js';
|
|
16
18
|
|
|
17
19
|
const debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:normalizeFieldForComparison');
|
|
18
20
|
//const debugData = debug.extend('data');
|
|
19
21
|
const debugDev = debug.extend('dev');
|
|
20
22
|
|
|
21
|
-
export function isEnnakkotietoSubfieldG(subfield) {
|
|
22
|
-
if (valuelessSubfield(subfield)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
if (subfield.code !== 'g') {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return subfield.value.match(/^ENNAKKOTIETO\.?$/gui);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
23
|
function debugFieldComparison(oldField, newField) { // NB: Debug-only function!
|
|
32
24
|
/*
|
|
33
25
|
// We may drop certain subfields:
|
|
@@ -60,7 +52,7 @@ function containsHumanName(tag = '???', subfieldCode = undefined) {
|
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
function containsCorporateName(tag = '???', subfieldCode = undefined) {
|
|
63
|
-
// NB! This set is for bibs! Auth has
|
|
55
|
+
// NB! This set is for bibs! Auth has 410... What else...
|
|
64
56
|
if (['110', '610', '710', '810'].includes(tag)) {
|
|
65
57
|
if (subfieldCode === undefined || subfieldCode === 'a') {
|
|
66
58
|
return true;
|
|
@@ -72,15 +64,15 @@ function containsCorporateName(tag = '???', subfieldCode = undefined) {
|
|
|
72
64
|
|
|
73
65
|
function skipAllSubfieldNormalizations(value, subfieldCode, tag) {
|
|
74
66
|
|
|
75
|
-
if (
|
|
67
|
+
if (isEnnakkotietoSubfield({'code': subfieldCode, value})) {
|
|
76
68
|
return true;
|
|
77
69
|
}
|
|
78
70
|
|
|
79
|
-
if (tag === '035' && ['a', 'z'].includes(subfieldCode)) {
|
|
71
|
+
if (tag === '035' && ['a', 'z'].includes(subfieldCode)) {
|
|
80
72
|
return true;
|
|
81
73
|
}
|
|
82
74
|
|
|
83
|
-
if (
|
|
75
|
+
if (!isContentSubfieldCode(subfieldCode, tag)) {
|
|
84
76
|
return true;
|
|
85
77
|
}
|
|
86
78
|
return false;
|
|
@@ -145,6 +137,23 @@ function fieldLowercase(field) {
|
|
|
145
137
|
}
|
|
146
138
|
}
|
|
147
139
|
|
|
140
|
+
function normalize300SubfieldA(field) {
|
|
141
|
+
if (field.tag !== '300') {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
field.subfields.forEach(sf => normalizePages(sf));
|
|
145
|
+
|
|
146
|
+
function normalizePages(subfield) {
|
|
147
|
+
if (valuelessSubfield(subfield)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (subfield.code !== 'a') {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
subfield.value = subfield.value.replace(/(?:\b(?:pages?|pp\.|Seite|sida|sidor|sivu|sivua)\b|\bs$)/g, 's.');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
148
157
|
|
|
149
158
|
function hack490SubfieldA(field) {
|
|
150
159
|
if (field.tag !== '490') {
|
|
@@ -193,7 +202,7 @@ function normalizeISBN(field) {
|
|
|
193
202
|
return;
|
|
194
203
|
}
|
|
195
204
|
|
|
196
|
-
//nvdebug(`ISBN-field? ${fieldToString(field)}
|
|
205
|
+
//nvdebug(`ISBN-field? ${fieldToString(field)}`, debugDev);
|
|
197
206
|
const relevantSubfields = field.subfields.filter(sf => tagAndSubfieldCodeReferToIsbn(field.tag, sf.code) && looksLikeIsbn(sf.value));
|
|
198
207
|
relevantSubfields.forEach(sf => normalizeIsbnSubfield(sf));
|
|
199
208
|
|
|
@@ -201,7 +210,7 @@ function normalizeISBN(field) {
|
|
|
201
210
|
if (valuelessSubfield(sf)) {
|
|
202
211
|
return;
|
|
203
212
|
}
|
|
204
|
-
//nvdebug(` ISBN-subfield? ${subfieldToString(sf)}
|
|
213
|
+
//nvdebug(` ISBN-subfield? ${subfieldToString(sf)}`, debugDev);
|
|
205
214
|
sf.value = sf.value.replace(/-/ug, '');
|
|
206
215
|
sf.value = sf.value.replace(/x/u, 'X');
|
|
207
216
|
}
|
|
@@ -210,6 +219,7 @@ function normalizeISBN(field) {
|
|
|
210
219
|
|
|
211
220
|
function fieldSpecificHacks(field) {
|
|
212
221
|
normalizeISBN(field); // 020$a, not $z!
|
|
222
|
+
normalize300SubfieldA(field);
|
|
213
223
|
hack490SubfieldA(field);
|
|
214
224
|
}
|
|
215
225
|
|
|
@@ -244,17 +254,20 @@ function removeDecomposedDiacritics(value = '') {
|
|
|
244
254
|
|
|
245
255
|
function normalizeSubfieldValue(value, subfieldCode, tag) {
|
|
246
256
|
// NB! For comparison of values only
|
|
247
|
-
/*
|
|
257
|
+
/* beslint-disable */
|
|
258
|
+
value = removeCharsThatDontCarryMeaning(value, tag, subfieldCode);
|
|
259
|
+
value = getSynonym(tag, subfieldCode, value); // Must be done before punc stripping and lowercasing...
|
|
248
260
|
value = subfieldValueLowercase(value, subfieldCode, tag);
|
|
249
261
|
|
|
262
|
+
|
|
250
263
|
// Normalize: s. = sivut = pp.
|
|
251
264
|
value = normalizePartData(value, subfieldCode, tag);
|
|
252
|
-
value = value.replace(/^\[([^[\]]+)\]/gu, '$1');
|
|
265
|
+
value = value.replace(/^\[([^[\]]+)\]/gu, '$1');
|
|
253
266
|
|
|
254
267
|
if (['130', '730'].includes(tag) && subfieldCode === 'a') {
|
|
255
268
|
value = value.replace(' : ', ', '); // "Halloween ends (elokuva, 2022)" vs "Halloween ends (elokuva : 2023)"
|
|
256
269
|
}
|
|
257
|
-
/*
|
|
270
|
+
/* beslint-enable */
|
|
258
271
|
|
|
259
272
|
// Not going to do these in the foreseeable future, but keeping them here for discussion:
|
|
260
273
|
// Possible normalizations include but are not limited to:
|
|
@@ -311,7 +324,8 @@ function normalizeField(field) {
|
|
|
311
324
|
export function cloneAndNormalizeFieldForComparison(field) {
|
|
312
325
|
// NB! This new field is for comparison purposes only.
|
|
313
326
|
// Some of the normalizations might be considered a bit overkill for other purposes.
|
|
314
|
-
const clonedField = clone(field)
|
|
327
|
+
const clonedField = cloneAndRemovePunctuation(field); // was only clone(field)
|
|
328
|
+
|
|
315
329
|
if (fieldSkipNormalization(field)) {
|
|
316
330
|
return clonedField;
|
|
317
331
|
}
|
|
@@ -319,8 +333,11 @@ export function cloneAndNormalizeFieldForComparison(field) {
|
|
|
319
333
|
if (valuelessSubfield(sf)) {
|
|
320
334
|
return;
|
|
321
335
|
}
|
|
336
|
+
|
|
322
337
|
sf.value = normalizeSubfieldValue(sf.value, sf.code, field.tag);
|
|
323
|
-
sf.value =
|
|
338
|
+
//sf.value = normalizeForSamenessCheck(field.tag, sf.code, sf.value);
|
|
339
|
+
|
|
340
|
+
|
|
324
341
|
});
|
|
325
342
|
|
|
326
343
|
normalizeField(clonedField);
|
|
@@ -105,8 +105,8 @@ export function partsAgree(value1, value2, tag, subfieldCode) {
|
|
|
105
105
|
}
|
|
106
106
|
const [partType1, partYear1, partNumber1] = splitAndNormalizePartData(value1);
|
|
107
107
|
const [partType2, partYear2, partNumber2] = splitAndNormalizePartData(value2);
|
|
108
|
-
//nvdebug(`P1: ${partType1} | ${partYear1} | ${partNumber1}
|
|
109
|
-
//nvdebug(`P2: ${partType2} | ${partYear2} | ${partNumber2}
|
|
108
|
+
//nvdebug(`P1: ${partType1} | ${partYear1} | ${partNumber1}`, debugDev);
|
|
109
|
+
//nvdebug(`P2: ${partType2} | ${partYear2} | ${partNumber2}`, debugDev);
|
|
110
110
|
if (partNumber1 !== partNumber2) {
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
@@ -203,7 +203,7 @@ export function removeWorsePrepubField594s(record) {
|
|
|
203
203
|
|
|
204
204
|
|
|
205
205
|
export function isEnnakkotietoSubfield(subfield) {
|
|
206
|
-
if (
|
|
206
|
+
if (!['g', '9', '7'].includes(subfield.code)) {
|
|
207
207
|
return false;
|
|
208
208
|
}
|
|
209
209
|
// Length <= 13 allows punctuation, but does not require it:
|
package/src/punctuation.test.js
CHANGED
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './punctuation/index.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/punctuation:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/punctuation: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');
|