-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Field f984 override [MRA-744] (#66) ; Dependency & Maintenance updates (
#68) * Mra 744 (#66) Implement field 984 override (MRA-744) * Bump the development-dependencies group with 2 updates (#67) Bumps the development-dependencies group with 2 updates: [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) and [chai](https://github.com/chaijs/chai). * Node-tests: v16.x -> v19.x * Bump the production-dependencies group with 2 updates (#71) Bumps the production-dependencies group with 2 updates: [@natlibfi/marc-record](https://github.com/natlibfi/marc-record-js) and [@natlibfi/melinda-commons](https://github.com/natlibfi/melinda-commons-js). * Bump the development-dependencies group with 1 update (#70) Bumps the development-dependencies group with 1 update: [nodemon](https://github.com/remy/nodemon). * 2.1.0-alpha.3
- Loading branch information
Showing
26 changed files
with
485 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* | ||
* @licstart The following is the entire license notice for the JavaScript code in this file. | ||
* | ||
* Melinda record match validator modules for Javascript | ||
* | ||
* Copyright (C) 2024 University Of Helsinki (The National Library Of Finland) | ||
* | ||
* This file is part of melinda-record-match-validator | ||
* | ||
* melinda-record-match-validator program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* melinda-record-match-validator is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @licend The above is the entire license notice | ||
* for the JavaScript code in this file. | ||
* | ||
*/ | ||
|
||
// Implements MRA-744 | ||
export function check984({record1, record2}) { | ||
const score1 = score984(record1); | ||
const score2 = score984(record2); | ||
// Should we use more generic score1 > score2? Does not having a 260/264 field imply badness? | ||
// Currently | ||
if (score1 > score2) { | ||
return 'A'; | ||
} | ||
if (score2 > score1) { | ||
return 'B'; | ||
} | ||
return true; | ||
|
||
function score984(currRecord) { | ||
const fields984 = currRecord.fields.filter(f => f.tag === '984'); | ||
|
||
if (fields984.some(f => isPreferred(f))) { | ||
return 1; | ||
} | ||
if (fields984.some(f => isSnubbed(f))) { | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
function isPreferred(field) { | ||
if (field.tag !== '984') { | ||
return false; | ||
} | ||
return field.subfields.some(sf => sf.code === 'a' && sf.value === 'ALWAYS-PREFER-IN-MERGE'); | ||
} | ||
|
||
function isSnubbed(field) { | ||
if (field.tag !== '984') { | ||
return false; | ||
} | ||
return field.subfields.some(sf => sf.code === 'a' && sf.value === 'NEVER-PREFER-IN-MERGE'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"action": "merge", | ||
"preference": { | ||
"name": "A won CAT test (preference only)", | ||
"value": "A" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"leader": "01092cas a22003494i 4500", | ||
"fields" : [ | ||
{ "tag": "001", "value": "001275158" }, | ||
{ "tag": "003", "value": "FI-MELINDA" }, | ||
{ "tag": "005", "value": "20201104004608.0" }, | ||
{ "tag": "008", "value": "010101c19879999nr |||p| ||||||||||0eng|c" }, | ||
{ "tag": "245", "ind1": "0", "ind2": "0", "subfields" : [ | ||
{ "code": "a", "value": "African dental journal /" }, | ||
{ "code": "c", "value": "Federation of African Dental Associations, FADA." } | ||
]}, | ||
{ "tag": "984", "ind1": " ", "ind2": " ", "subfields" : [{"code": "a", "value": "ALWAYS-PREFER-IN-MERGE"}]}, | ||
{ "tag": "CAT", "ind1": " ", "ind2": " ", "subfields" : [ | ||
{ "code": "a", "value": "CONV-ISBD" }, | ||
{ "code": "b" }, | ||
{ "code": "c", "value": "20120402" }, | ||
{ "code": "l", "value": "FIN01" }, | ||
{ "code": "h", "value": "0819" } | ||
]}, | ||
{ "tag": "CAT", "ind1": " ", "ind2": " ", "subfields" : [ | ||
{ "code": "a", "value": "LOAD-HELKA" }, | ||
{ "code": "b" }, | ||
{ "code": "c", "value": "20140520" }, | ||
{ "code": "l", "value": "FIN01" }, | ||
{ "code": "h", "value": "0018" } | ||
]}, | ||
{ "tag": "CAT", "ind1": " ", "ind2": " ", "subfields" : [ | ||
{ "code": "a", "value": "LOAD-HELKA" }, | ||
{ "code": "b" }, | ||
{ "code": "c", "value": "20140609" }, | ||
{ "code": "l", "value": "FIN01" }, | ||
{ "code": "h", "value": "2320" } | ||
]}, | ||
{ "tag": "CAT", "ind1": " ", "ind2": " ", "subfields" : [ | ||
{ "code": "a", "value": "CONV-RDA" }, | ||
{ "code": "b" }, | ||
{ "code": "c", "value": "20160319" }, | ||
{ "code": "l", "value": "FIN01" }, | ||
{ "code": "h", "value": "0822" } | ||
]}, | ||
{ "tag": "CAT", "ind1": " ", "ind2": " ", "subfields" : [ | ||
{ "code": "a", "value": "KVP1008" }, | ||
{ "code": "b", "value": "30" }, | ||
{ "code": "c", "value": "20201104" }, | ||
{ "code": "l", "value": "FIN01" }, | ||
{ "code": "h", "value": "0046" } | ||
]} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"leader": "01092cas a22003494i 4500", | ||
"fields" : [ | ||
{ "tag": "001", "value": "001275158" }, | ||
{ "tag": "003", "value": "FI-MELINDA" }, | ||
{ "tag": "005", "value": "20201104004608.0" }, | ||
{ "tag": "008", "value": "010101c19879999nr |||p| ||||||||||0eng|c" }, | ||
{ "tag": "245", "ind1": "0", "ind2": "0", "subfields" : [ | ||
{ "code": "a", "value": "African dental journal /" }, | ||
{ "code": "c", "value": "Federation of African Dental Associations, FADA." } | ||
]}, | ||
{ "tag": "984", "ind1": " ", "ind2": " ", "subfields" : [{"code": "a", "value": "ALWAYS-PREFER-IN-MERGE"}]} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"description": "Record with (non-load/import/conversion) CATs wins. Two 984$a ALWAYS-PREFER-IN-MERGE cancel each other out", | ||
"enabled": true, | ||
"only": false, | ||
"skip": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"action": "merge", | ||
"preference": { | ||
"name": "A won CAT test (preference only)", | ||
"value": "A" | ||
} | ||
} |
Oops, something went wrong.