Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve publishers [MET-517] (#120) & Dependency Update (#119) #121

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 20 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "[email protected]:natlibfi/melinda-marc-record-merge-reducers-js.git"
},
"license": "LGPL-3.0+",
"version": "2.0.21",
"version": "2.0.23-alpha.1",
"main": "./dist/index.js",
"engines": {
"node": ">=18"
Expand All @@ -40,7 +40,7 @@
"@natlibfi/marc-record-merge": "^7.0.0",
"@natlibfi/marc-record-validate": "^8.0.3",
"@natlibfi/marc-record-validators-melinda": "^10.15.1",
"@natlibfi/melinda-commons": "^13.0.7",
"@natlibfi/melinda-commons": "^13.0.8",
"debug": "^4.3.4",
"isbn3": "^1.1.43",
"normalize-diacritics": "^4.0.3"
Expand Down
22 changes: 14 additions & 8 deletions src/reducers/counterpartField.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function differentPublisherSubfields(field1, field2) {


export function splitToNameAndQualifier(name) {
const nameOnly = name.replace(/(?: \([^)]+\)| abp?| Kustannus|, kustannusosakeyhtiö| oyj?| ry)$/ugi, '');
const nameOnly = name.replace(/(?: \([^)]+\)| abp?| Kustannus| Kustannus Oy|, kustannusosakeyhtiö| oyj?| ry)$/ugi, '');
if (nameOnly === name) {
return [getBestName(name).toLowerCase(), undefined];
}
Expand Down Expand Up @@ -76,14 +76,20 @@ function corporateNamesAgree(value1, value2, tag, subfieldCode) {
return false;
}

// If both values have qualifiers, they must be equal!
// Note this will reject ", kustannusosakeyhtiö" vs "(yhtiö)" pair
// Also qualifer pair "(foo)" and "(bar)" will result in a failure.
if (qualifier1 !== undefined && qualifier2 !== undefined && qualifier1 !== qualifier2) {
// Should we support "Yhtiö ab" equals "Yhtiö oy"? If so, this is the place. Pretty marginal though
return false;
// If either value does not have a qualifier, they are considered equals:
if (qualifier1 === undefined || qualifier2 === undefined || qualifier1 === qualifier2) {
return true;
}

if (isKustantaja(qualifier1) && isKustantaja(qualifier2)) {
return true;
}

return false;

function isKustantaja(qualifier) {
return qualifier.match(/^(?: Kustannus| Kustannus oy|, kustannusosakeyhtiö)$/iu);
}
return true;
}

function pairableValue(tag, subfieldCode, value1, value2) {
Expand Down
9 changes: 9 additions & 0 deletions test-fixtures/reducers/index/field710_MET502/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
{ "code": "a", "value": "Paristo" },
{ "code": "e", "value": "kustantaja." }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Ateena kustannus," },
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555777" }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Basaari Kustannus Oy," },
{ "code": "e", "value": "kustantaja." }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Qualifier Mismatch (foo)" } ]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "WSOY" } ]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Ntamo" } ]},
Expand Down
10 changes: 10 additions & 0 deletions test-fixtures/reducers/index/field710_MET502/merged.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555889" }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Ateena kustannus," },
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555777" }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Basaari Kustannus," },
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555444" }
]},

{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Qualifier Mismatch (foo)" } ]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Werner Söderström osakeyhtiö." } ]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description":"MET-502: combine differently named orgs (support qualifiers, oy etc.)",
"description":"MET-502 and MET-517: combine differently named orgs (support qualifiers, oy etc.)",
"NB #1": "We need to check&fix ').' removal rules AND other 710 punc rules!",
"only": false,
"skip": false
Expand Down
9 changes: 9 additions & 0 deletions test-fixtures/reducers/index/field710_MET502/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555889" }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Ateena," },
{ "code": "e", "value": "kustantaja." }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [
{ "code": "a", "value": "Basaari Kustannus," },
{ "code": "e", "value": "kustantaja." },
{ "code": "0", "value": "(FI-ASTERI-N)000555444" }
]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Qualifier Mismatch (bar)" } ]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "Werner Söderström osakeyhtiö" } ]},
{ "tag": "710", "ind1": "2", "ind2": " ", "subfields": [ { "code": "a", "value": "ntamo" } ]},
Expand Down