@natlibfi/melinda-record-matching 2.2.0-alpha.2 → 2.2.1-alpha.1
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/CODEOWNERS +10 -0
- package/.github/dependabot.yml +40 -0
- package/.github/workflows/melinda-node-tests.yml +70 -0
- package/package.json +13 -13
- package/src/candidate-search/index.js +11 -8
- package/src/candidate-search/query-list/bib.js +2 -2
- package/src/index.js +70 -29
- package/src/match-detection/features/bib/authors.js +1 -1
- package/src/match-detection/features/bib/standard-identifier-factory.js +2 -1
- package/src/match-detection/index.js +29 -19
- package/src/match-detection/index.spec.js +17 -3
- package/src/matching-utils.js +1 -1
- package/dist/candidate-search/candidate-search-utils.js +0 -58
- package/dist/candidate-search/candidate-search-utils.js.map +0 -1
- package/dist/candidate-search/index.js +0 -273
- package/dist/candidate-search/index.js.map +0 -1
- package/dist/candidate-search/index.spec.js +0 -161
- package/dist/candidate-search/index.spec.js.map +0 -1
- package/dist/candidate-search/query-list/bib.js +0 -252
- package/dist/candidate-search/query-list/bib.js.map +0 -1
- package/dist/candidate-search/query-list/bib.spec.js +0 -72
- package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
- package/dist/candidate-search/query-list/index.js +0 -67
- package/dist/candidate-search/query-list/index.js.map +0 -1
- package/dist/index.js +0 -508
- package/dist/index.js.map +0 -1
- package/dist/index.spec.js +0 -133
- package/dist/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/all-source-ids.js +0 -122
- package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
- package/dist/match-detection/features/bib/authors.js +0 -117
- package/dist/match-detection/features/bib/authors.js.map +0 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +0 -42
- package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
- package/dist/match-detection/features/bib/host-component.js +0 -42
- package/dist/match-detection/features/bib/host-component.js.map +0 -1
- package/dist/match-detection/features/bib/index.js +0 -104
- package/dist/match-detection/features/bib/index.js.map +0 -1
- package/dist/match-detection/features/bib/index.spec.js +0 -97
- package/dist/match-detection/features/bib/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/isbn.js +0 -55
- package/dist/match-detection/features/bib/isbn.js.map +0 -1
- package/dist/match-detection/features/bib/issn.js +0 -55
- package/dist/match-detection/features/bib/issn.js.map +0 -1
- package/dist/match-detection/features/bib/language.js +0 -113
- package/dist/match-detection/features/bib/language.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-id.js +0 -52
- package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -100
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +0 -55
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time.js +0 -47
- package/dist/match-detection/features/bib/publication-time.js.map +0 -1
- package/dist/match-detection/features/bib/record-type.js +0 -42
- package/dist/match-detection/features/bib/record-type.js.map +0 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -125
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/title.js +0 -91
- package/dist/match-detection/features/bib/title.js.map +0 -1
- package/dist/match-detection/features/index.js +0 -15
- package/dist/match-detection/features/index.js.map +0 -1
- package/dist/match-detection/index.js +0 -178
- package/dist/match-detection/index.js.map +0 -1
- package/dist/match-detection/index.spec.js +0 -81
- package/dist/match-detection/index.spec.js.map +0 -1
- package/dist/matching-utils.js +0 -95
- package/dist/matching-utils.js.map +0 -1
package/dist/matching-utils.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getMelindaIdsF035 = getMelindaIdsF035;
|
|
7
|
-
exports.getSubfieldValues = getSubfieldValues;
|
|
8
|
-
exports.validateSidFieldSubfieldCounts = validateSidFieldSubfieldCounts;
|
|
9
|
-
|
|
10
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
17
|
-
*
|
|
18
|
-
* Melinda record matching modules for Javascript
|
|
19
|
-
*
|
|
20
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
21
|
-
*
|
|
22
|
-
* This file is part of melinda-record-matching-js
|
|
23
|
-
*
|
|
24
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
25
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
26
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
27
|
-
* License, or (at your option) any later version.
|
|
28
|
-
*
|
|
29
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
30
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
31
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
32
|
-
* GNU Lesser General Public License for more details.
|
|
33
|
-
*
|
|
34
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
35
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
36
|
-
*
|
|
37
|
-
* @licend The above is the entire license notice
|
|
38
|
-
* for the JavaScript code in this file.
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:utils');
|
|
42
|
-
const debugData = debug.extend('data'); // eslint-disable-next-line max-statements
|
|
43
|
-
|
|
44
|
-
function getMelindaIdsF035(record) {
|
|
45
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:melinda-id');
|
|
46
|
-
const debugData = debug.extend('data');
|
|
47
|
-
const f035s = record.getFields('035');
|
|
48
|
-
|
|
49
|
-
if (f035s.length < 1) {
|
|
50
|
-
debug(`No f035s found.`);
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));
|
|
55
|
-
const f035MelindaIds = [...new Set(allF035MelindaIds)];
|
|
56
|
-
debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);
|
|
57
|
-
debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);
|
|
58
|
-
debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);
|
|
59
|
-
return f035MelindaIds;
|
|
60
|
-
|
|
61
|
-
function toMelindaIds({
|
|
62
|
-
subfields
|
|
63
|
-
}) {
|
|
64
|
-
const melindaIdRegExp = /^(?<prefix>\(FI-MELINDA\)|FCC)(?<id>\d{9})$/u;
|
|
65
|
-
return subfields.filter(sub => ['a', 'z'].includes(sub.code)).filter(sub => melindaIdRegExp.test(sub.value)).map(({
|
|
66
|
-
value
|
|
67
|
-
}) => value.replace(melindaIdRegExp, '$<id>'));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function validateSidFieldSubfieldCounts(field) {
|
|
72
|
-
// Valid SID-fields have just one $c and one $b
|
|
73
|
-
debugData(`Validating SID field ${JSON.stringify(field)}`);
|
|
74
|
-
const countC = countSubfields(field, 'c');
|
|
75
|
-
const countB = countSubfields(field, 'b');
|
|
76
|
-
debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);
|
|
77
|
-
return countC === 1 && countB === 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function countSubfields(field, subfieldCode) {
|
|
81
|
-
// debug(`Counting subfields ${subfieldCode}`);
|
|
82
|
-
return field.subfields.filter(({
|
|
83
|
-
code
|
|
84
|
-
}) => code === subfieldCode).length;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getSubfieldValues(field, subfieldCode) {
|
|
88
|
-
debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);
|
|
89
|
-
return field.subfields.filter(({
|
|
90
|
-
code
|
|
91
|
-
}) => code === subfieldCode).map(({
|
|
92
|
-
value
|
|
93
|
-
}) => value);
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=matching-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matching-utils.js"],"names":["debug","debugData","extend","getMelindaIdsF035","record","f035s","getFields","length","allF035MelindaIds","concat","map","toMelindaIds","f035MelindaIds","Set","JSON","stringify","subfields","melindaIdRegExp","filter","sub","includes","code","test","value","replace","validateSidFieldSubfieldCounts","field","countC","countSubfields","countB","subfieldCode","getSubfieldValues"],"mappings":";;;;;;;;;AA4BA;;;;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,MAAMA,KAAK,GAAG,oBAAkB,yCAAlB,CAAd;AACA,MAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB,C,CAEA;;AACO,SAASC,iBAAT,CAA2BC,MAA3B,EAAmC;AAExC,QAAMJ,KAAK,GAAG,oBAAkB,8CAAlB,CAAd;AACA,QAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;AAEA,QAAMG,KAAK,GAAGD,MAAM,CAACE,SAAP,CAAiB,KAAjB,CAAd;;AAEA,MAAID,KAAK,CAACE,MAAN,GAAe,CAAnB,EAAsB;AACpBP,IAAAA,KAAK,CAAE,iBAAF,CAAL;AACA,WAAO,EAAP;AACD;;AAED,QAAMQ,iBAAiB,GAAG,GAAGC,MAAH,CAAU,GAAGJ,KAAK,CAACK,GAAN,CAAUC,YAAV,CAAb,CAA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AE,EAAvF,CAAL;AAEA,SAAOF,MAAM,KAAK,CAAX,IAAgBE,MAAM,KAAK,CAAlC;AACD;;AAED,SAASD,cAAT,CAAwBF,KAAxB,EAA+BI,YAA/B,EAA6C;AAC3C;AACA,SAAOJ,KAAK,CAACV,SAAN,CAAgBE,MAAhB,CAAuB,CAAC;AAACG,IAAAA;AAAD,GAAD,KAAYA,IAAI,KAAKS,YAA5C,EAA0DvB,MAAjE;AACD;;AAEM,SAASwB,iBAAT,CAA2BL,KAA3B,EAAkCI,YAAlC,EAAgD;AACrD7B,EAAAA,SAAS,CAAE,oBAAmB6B,YAAa,SAAQhB,IAAI,CAACC,SAAL,CAAeW,KAAf,CAAsB,EAAhE,CAAT;AACA,SAAOA,KAAK,CAACV,SAAN,CAAgBE,MAAhB,CAAuB,CAAC;AAACG,IAAAA;AAAD,GAAD,KAAYA,IAAI,KAAKS,YAA5C,EAA0DpB,GAA1D,CAA8D,CAAC;AAACa,IAAAA;AAAD,GAAD,KAAaA,KAA3E,CAAP;AACD","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:utils');\nconst debugData = debug.extend('data');\n\n// eslint-disable-next-line max-statements\nexport function getMelindaIdsF035(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:melinda-id');\n const debugData = debug.extend('data');\n\n const f035s = record.getFields('035');\n\n if (f035s.length < 1) {\n debug(`No f035s found.`);\n return [];\n }\n\n const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));\n const f035MelindaIds = [...new Set(allF035MelindaIds)];\n\n debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);\n debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);\n debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);\n\n return f035MelindaIds;\n\n function toMelindaIds({subfields}) {\n const melindaIdRegExp = /^(?<prefix>\\(FI-MELINDA\\)|FCC)(?<id>\\d{9})$/u;\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code))\n .filter(sub => melindaIdRegExp.test(sub.value))\n .map(({value}) => value.replace(melindaIdRegExp, '$<id>'));\n\n }\n}\n\nexport function validateSidFieldSubfieldCounts(field) {\n // Valid SID-fields have just one $c and one $b\n debugData(`Validating SID field ${JSON.stringify(field)}`);\n const countC = countSubfields(field, 'c');\n const countB = countSubfields(field, 'b');\n debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);\n\n return countC === 1 && countB === 1;\n}\n\nfunction countSubfields(field, subfieldCode) {\n // debug(`Counting subfields ${subfieldCode}`);\n return field.subfields.filter(({code}) => code === subfieldCode).length;\n}\n\nexport function getSubfieldValues(field, subfieldCode) {\n debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);\n return field.subfields.filter(({code}) => code === subfieldCode).map(({value}) => value);\n}\n\n"],"file":"matching-utils.js"}
|