@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 5.0.0-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/workflows/melinda-node-tests.yml +13 -9
- package/LICENSE.txt +21 -165
- package/README.md +2 -2
- package/eslint.config.js +52 -0
- package/example.env +4 -0
- package/package.json +29 -79
- package/src/candidate-search/candidate-search-utils.js +1 -28
- package/src/candidate-search/choose-queries.js +93 -0
- package/src/candidate-search/index.js +85 -119
- package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
- package/src/candidate-search/query-list/bib.js +54 -55
- package/src/candidate-search/query-list/bib.test.js +38 -0
- package/src/candidate-search/query-list/component.js +127 -0
- package/src/candidate-search/query-list/index.js +31 -35
- package/src/cli.js +177 -0
- package/src/index.js +27 -68
- package/src/{index.spec.js → index.test.js} +11 -42
- package/src/match-detection/features/bib/all-source-ids.js +2 -29
- package/src/match-detection/features/bib/authors.js +5 -30
- package/src/match-detection/features/bib/bibliographic-level.js +0 -27
- package/src/match-detection/features/bib/host-component.js +0 -27
- package/src/match-detection/features/bib/index.js +16 -43
- package/src/match-detection/features/bib/index.test.js +52 -0
- package/src/match-detection/features/bib/isbn.js +2 -29
- package/src/match-detection/features/bib/issn.js +1 -28
- package/src/match-detection/features/bib/language.js +5 -32
- package/src/match-detection/features/bib/media-type.js +2 -28
- package/src/match-detection/features/bib/melinda-id.js +1 -28
- package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
- package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
- package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
- package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
- package/src/match-detection/features/bib/publication-time.js +2 -28
- package/src/match-detection/features/bib/record-type.js +0 -27
- package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
- package/src/match-detection/features/bib/title-version-original.js +2 -28
- package/src/match-detection/features/bib/title.js +6 -34
- package/src/match-detection/features/index.js +1 -28
- package/src/match-detection/index.js +1 -28
- package/src/match-detection/{index.spec.js → index.test.js} +9 -35
- package/src/matching-utils.js +8 -37
- package/dist/candidate-search/candidate-search-utils.js +0 -55
- package/dist/candidate-search/candidate-search-utils.js.map +0 -1
- package/dist/candidate-search/index.js +0 -254
- package/dist/candidate-search/index.js.map +0 -1
- package/dist/candidate-search/index.spec.js +0 -144
- package/dist/candidate-search/index.spec.js.map +0 -1
- package/dist/candidate-search/query-list/bib.js +0 -439
- package/dist/candidate-search/query-list/bib.js.map +0 -1
- package/dist/candidate-search/query-list/bib.spec.js +0 -64
- package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
- package/dist/candidate-search/query-list/index.js +0 -66
- package/dist/candidate-search/query-list/index.js.map +0 -1
- package/dist/index.js +0 -579
- package/dist/index.js.map +0 -1
- package/dist/index.spec.js +0 -127
- package/dist/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/all-source-ids.js +0 -119
- package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
- package/dist/match-detection/features/bib/authors.js +0 -113
- 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 -119
- package/dist/match-detection/features/bib/index.js.map +0 -1
- package/dist/match-detection/features/bib/index.spec.js +0 -93
- package/dist/match-detection/features/bib/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/isbn.js +0 -77
- package/dist/match-detection/features/bib/isbn.js.map +0 -1
- package/dist/match-detection/features/bib/issn.js +0 -51
- package/dist/match-detection/features/bib/issn.js.map +0 -1
- package/dist/match-detection/features/bib/language.js +0 -141
- package/dist/match-detection/features/bib/language.js.map +0 -1
- package/dist/match-detection/features/bib/media-type.js +0 -83
- package/dist/match-detection/features/bib/media-type.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-id.js +0 -48
- package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -89
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +0 -52
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -256
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +0 -71
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time.js +0 -48
- package/dist/match-detection/features/bib/publication-time.js.map +0 -1
- package/dist/match-detection/features/bib/record-type.js +0 -45
- package/dist/match-detection/features/bib/record-type.js.map +0 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -215
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/title-version-original.js +0 -79
- package/dist/match-detection/features/bib/title-version-original.js.map +0 -1
- package/dist/match-detection/features/bib/title.js +0 -98
- package/dist/match-detection/features/bib/title.js.map +0 -1
- package/dist/match-detection/features/index.js +0 -11
- package/dist/match-detection/features/index.js.map +0 -1
- package/dist/match-detection/index.js +0 -201
- package/dist/match-detection/index.js.map +0 -1
- package/dist/match-detection/index.spec.js +0 -91
- package/dist/match-detection/index.spec.js.map +0 -1
- package/dist/matching-utils.js +0 -143
- package/dist/matching-utils.js.map +0 -1
- package/src/candidate-search/query-list/bib.spec.js +0 -54
- package/src/match-detection/features/bib/index.spec.js +0 -78
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import {expect} from 'chai';
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import {describe} from 'node:test';
|
|
3
|
+
import createDebugLogger from 'debug';
|
|
30
4
|
import {READERS} from '@natlibfi/fixura';
|
|
31
5
|
import generateTests from '@natlibfi/fixugen-http-client';
|
|
32
6
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
33
|
-
import createMatchInterface, {matchDetection} from '.';
|
|
34
|
-
import createDebugLogger from 'debug';
|
|
7
|
+
import createMatchInterface, {matchDetection} from './index.js';
|
|
35
8
|
|
|
36
9
|
const debug = createDebugLogger('@natlibfi/melinda-record-matching:index:test');
|
|
37
10
|
const debugData = debug.extend('data');
|
|
@@ -39,7 +12,7 @@ const debugData = debug.extend('data');
|
|
|
39
12
|
describe('INDEX', () => {
|
|
40
13
|
generateTests({
|
|
41
14
|
callback,
|
|
42
|
-
path: [
|
|
15
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'index'],
|
|
43
16
|
recurse: false,
|
|
44
17
|
fixura: {
|
|
45
18
|
reader: READERS.JSON
|
|
@@ -58,19 +31,18 @@ describe('INDEX', () => {
|
|
|
58
31
|
const {matches, matchStatus, nonMatches, conversionFailures, candidateCount} = await match({record});
|
|
59
32
|
debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);
|
|
60
33
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
34
|
+
assert.equal(matchStatus.status, expectedMatchStatus);
|
|
35
|
+
assert.equal(matchStatus.stopReason, expectedStopReason);
|
|
36
|
+
assert.equal(candidateCount, expectedCandidateCount);
|
|
64
37
|
|
|
65
38
|
const formattedMatchResult = formatRecordResults(matches);
|
|
66
|
-
|
|
39
|
+
assert.deepStrictEqual(formattedMatchResult, expectedMatches);
|
|
67
40
|
|
|
68
41
|
const formattedNonMatchResult = formatRecordResults(nonMatches);
|
|
69
|
-
|
|
42
|
+
assert.deepStrictEqual(formattedNonMatchResult, expectedNonMatches);
|
|
70
43
|
|
|
71
|
-
// eslint-disable-next-line functional/no-conditional-statements
|
|
72
44
|
if (expectedFailures) {
|
|
73
|
-
|
|
45
|
+
assert.deepStrictEqual(conversionFailures, expectedFailures);
|
|
74
46
|
}
|
|
75
47
|
|
|
76
48
|
function formatOptions() {
|
|
@@ -108,8 +80,5 @@ describe('INDEX', () => {
|
|
|
108
80
|
record: newRecord.toObject()
|
|
109
81
|
};
|
|
110
82
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
83
|
}
|
|
114
|
-
|
|
115
84
|
});
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
2
|
import createDebugLogger from 'debug';
|
|
30
|
-
import {validateSidFieldSubfieldCounts, getSubfieldValues} from '../../../matching-utils';
|
|
3
|
+
import {validateSidFieldSubfieldCounts, getSubfieldValues} from '../../../matching-utils.js';
|
|
31
4
|
|
|
32
5
|
const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');
|
|
33
6
|
const debugData = debug.extend('data');
|
|
@@ -98,7 +71,7 @@ export default () => ({
|
|
|
98
71
|
debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
|
|
99
72
|
|
|
100
73
|
const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&
|
|
101
|
-
|
|
74
|
+
sidA.sourceId === sidB.sourceId));
|
|
102
75
|
debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);
|
|
103
76
|
|
|
104
77
|
const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&
|
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import {LevenshteinDistance as leven} from 'natural';
|
|
30
|
-
import {testStringOrNumber} from '../../../matching-utils';
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import naturalPkg from 'natural';
|
|
4
|
+
const {LevenshteinDistance: leven} = naturalPkg;
|
|
5
|
+
import {testStringOrNumber} from '../../../matching-utils.js';
|
|
31
6
|
|
|
32
7
|
// We should extract also organisational authors (110/710)
|
|
33
8
|
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
2
|
export default () => ({
|
|
30
3
|
name: 'Bibliographic level',
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
2
|
export default () => ({
|
|
30
3
|
name: 'Host/Component record',
|
|
@@ -1,44 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
|
-
export {default as hostComponent} from './host-component';
|
|
30
|
-
export {default as isbn} from './isbn';
|
|
31
|
-
export {default as issn} from './issn';
|
|
32
|
-
export {default as otherStandardIdentifier} from './other-standard-identifier';
|
|
33
|
-
export {default as title} from './title';
|
|
34
|
-
export {default as titleVersionOriginal} from './title-version-original';
|
|
35
|
-
export {default as authors} from './authors';
|
|
36
|
-
export {default as recordType} from './record-type';
|
|
37
|
-
export {default as publicationTime} from './publication-time';
|
|
38
|
-
export {default as publicationTimeAllowConsYears} from './publication-time-allow-cons-years';
|
|
39
|
-
export {default as publicationTimeAllowConsYearsMulti} from './publication-time-allow-cons-years-multi';
|
|
40
|
-
export {default as language} from './language';
|
|
41
|
-
export {default as bibliographicLevel} from './bibliographic-level';
|
|
42
|
-
export {default as melindaId} from './melinda-id';
|
|
43
|
-
export {default as allSourceIds} from './all-source-ids';
|
|
44
|
-
export {default as mediaType} from './media-type';
|
|
2
|
+
export {default as hostComponent} from './host-component.js';
|
|
3
|
+
export {default as isbn} from './isbn.js';
|
|
4
|
+
export {default as issn} from './issn.js';
|
|
5
|
+
export {default as otherStandardIdentifier} from './other-standard-identifier.js';
|
|
6
|
+
export {default as title} from './title.js';
|
|
7
|
+
export {default as titleVersionOriginal} from './title-version-original.js';
|
|
8
|
+
export {default as authors} from './authors.js';
|
|
9
|
+
export {default as recordType} from './record-type.js';
|
|
10
|
+
export {default as publicationTime} from './publication-time.js';
|
|
11
|
+
export {default as publicationTimeAllowConsYears} from './publication-time-allow-cons-years.js';
|
|
12
|
+
export {default as publicationTimeAllowConsYearsMulti} from './publication-time-allow-cons-years-multi.js';
|
|
13
|
+
export {default as language} from './language.js';
|
|
14
|
+
export {default as bibliographicLevel} from './bibliographic-level.js';
|
|
15
|
+
export {default as melindaId} from './melinda-id.js';
|
|
16
|
+
export {default as allSourceIds} from './all-source-ids.js';
|
|
17
|
+
export {default as mediaType} from './media-type.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import {describe} from 'node:test';
|
|
4
|
+
import createDebugLogger from 'debug';
|
|
5
|
+
import generateTests from '@natlibfi/fixugen';
|
|
6
|
+
import {READERS} from '@natlibfi/fixura';
|
|
7
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
8
|
+
import * as features from './index.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');
|
|
12
|
+
const debugData = debug.extend('data');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
describe('match-detection/features/bib/', () => {
|
|
16
|
+
generateTests({
|
|
17
|
+
path: [import.meta.dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],
|
|
18
|
+
useMetadataFile: true,
|
|
19
|
+
fixura: {
|
|
20
|
+
reader: READERS.JSON
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
callback: ({enabled = true, feature, options, type, ...expectations}) => {
|
|
24
|
+
|
|
25
|
+
if (!enabled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
debug(`Testing: ${feature} ${type}`);
|
|
30
|
+
|
|
31
|
+
if (type === 'extract') {
|
|
32
|
+
const {expectedFeatures, inputRecord} = expectations;
|
|
33
|
+
const record = new MarcRecord(inputRecord, {subfieldValues: false});
|
|
34
|
+
debugData(`Record: ${record}`);
|
|
35
|
+
const {extract} = features[feature](options);
|
|
36
|
+
|
|
37
|
+
assert.deepStrictEqual(extract({record}), expectedFeatures);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (type === 'compare') {
|
|
42
|
+
const {featuresA, featuresB, expectedPoints} = expectations;
|
|
43
|
+
const {compare} = features[feature](options);
|
|
44
|
+
|
|
45
|
+
assert.equal(compare(featuresA, featuresB), expectedPoints);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
throw new Error(`Invalid type ${type}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
|
-
import createInterface from './standard-identifier-factory';
|
|
30
|
-
import {parse as isbnParse} from 'isbn3';
|
|
31
2
|
import createDebugLogger from 'debug';
|
|
3
|
+
import {parse as isbnParse} from 'isbn3';
|
|
4
|
+
import createInterface from './standard-identifier-factory.js';
|
|
32
5
|
|
|
33
6
|
const debug = createDebugLogger(`@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers:ISBN`);
|
|
34
7
|
const debugData = debug.extend('data');
|
|
@@ -1,32 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
|
-
import createInterface from './standard-identifier-factory';
|
|
2
|
+
import createInterface from './standard-identifier-factory.js';
|
|
30
3
|
|
|
31
4
|
export default () => {
|
|
32
5
|
const {extract, compare} = createInterface({pattern: /^022$/u, subfieldCodes: ['a', 'z', 'y']});
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
2
|
import createDebugLogger from 'debug';
|
|
30
|
-
import {getMatchCounts} from '../../../matching-utils';
|
|
3
|
+
import {getMatchCounts} from '../../../matching-utils.js';
|
|
31
4
|
|
|
32
5
|
const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:language');
|
|
33
6
|
const debugData = debug.extend('data');
|
|
@@ -39,10 +12,10 @@ export default () => ({
|
|
|
39
12
|
|
|
40
13
|
const value008 = get008Value();
|
|
41
14
|
const values041 = get041Values();
|
|
42
|
-
debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
|
|
15
|
+
debugData(`${label}: 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
|
|
43
16
|
|
|
44
17
|
if (!value008 && values041.length < 1) {
|
|
45
|
-
debugData(
|
|
18
|
+
debugData(`${label}: No actual values found`);
|
|
46
19
|
return [];
|
|
47
20
|
}
|
|
48
21
|
|
|
@@ -53,14 +26,14 @@ export default () => ({
|
|
|
53
26
|
|
|
54
27
|
function get008Value() {
|
|
55
28
|
const value = record.get(/^008$/u)?.[0]?.value || undefined;
|
|
56
|
-
debugData(`${label} 008 value: ${value}`);
|
|
29
|
+
debugData(`${label}: 008 value: ${value}`);
|
|
57
30
|
|
|
58
31
|
if (!value) {
|
|
59
32
|
return undefined;
|
|
60
33
|
}
|
|
61
34
|
|
|
62
35
|
const code = value.slice(35, 38);
|
|
63
|
-
debugData(`${label} 008 code: ${code}`);
|
|
36
|
+
debugData(`${label}: 008 code: ${code}`);
|
|
64
37
|
return isLangCodeForALanguage(code) ? code : undefined;
|
|
65
38
|
}
|
|
66
39
|
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
5
|
-
*
|
|
6
|
-
* Melinda record matching modules for Javascript
|
|
7
|
-
*
|
|
8
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
9
|
-
*
|
|
10
|
-
* This file is part of melinda-record-matching-js
|
|
11
|
-
*
|
|
12
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
13
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
14
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
15
|
-
* License, or (at your option) any later version.
|
|
16
|
-
*
|
|
17
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
18
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
* GNU Lesser General Public License for more details.
|
|
21
|
-
*
|
|
22
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
23
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
*
|
|
25
|
-
* @licend The above is the entire license notice
|
|
26
|
-
* for the JavaScript code in this file.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
2
|
+
|
|
29
3
|
|
|
30
4
|
import createDebugLogger from 'debug';
|
|
31
5
|
|
|
@@ -39,7 +13,7 @@ export default () => ({
|
|
|
39
13
|
debugData(`Record (${label}): ${JSON.stringify(record)}`);
|
|
40
14
|
debugData(`RecordExternal: ${JSON.stringify(recordExternal)}`);
|
|
41
15
|
const values337 = get337Values();
|
|
42
|
-
debug(`${label} 337 $b values: ${JSON.stringify(values337)}`);
|
|
16
|
+
debug(`${label}: 337 $b values: ${JSON.stringify(values337)}`);
|
|
43
17
|
|
|
44
18
|
return values337;
|
|
45
19
|
|
|
@@ -1,32 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
|
-
import createInterface from './melinda-identifier-factory';
|
|
2
|
+
import createInterface from './melinda-identifier-factory.js';
|
|
30
3
|
|
|
31
4
|
export default () => {
|
|
32
5
|
const {extract, compare} = createInterface();
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
2
|
import createDebugLogger from 'debug';
|
|
30
|
-
import {getMelindaIdsF035} from '../../../matching-utils';
|
|
3
|
+
import {getMelindaIdsF035} from '../../../matching-utils.js';
|
|
31
4
|
|
|
32
5
|
// 003+001 FI-MELINDA <melinda-id>
|
|
33
6
|
// 035 $a (FI-MELINDA)<melinda-id>
|
|
@@ -65,25 +38,25 @@ export default () => {
|
|
|
65
38
|
function compare(a, b) {
|
|
66
39
|
|
|
67
40
|
if (a.isMelindaRecord && b.isMelindaRecord &&
|
|
68
|
-
|
|
41
|
+
a.f001 === b.f001) {
|
|
69
42
|
debugData(`Melinda record's A f001 ${a.f001} matches Melinda record's B f001 ${a.f001}`);
|
|
70
43
|
return 1;
|
|
71
44
|
}
|
|
72
45
|
|
|
73
46
|
if (a.isMelindaRecord && typeof b.f035MelindaIds !== 'undefined' &&
|
|
74
|
-
|
|
47
|
+
b.f035MelindaIds.some(id => id === a.f001)) {
|
|
75
48
|
debugData(`Melinda record's A f001 ${a.f001} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
|
|
76
49
|
return 1;
|
|
77
50
|
}
|
|
78
51
|
|
|
79
52
|
if (b.isMelindaRecord && typeof a.f035MelindaIds !== 'undefined' &&
|
|
80
|
-
|
|
53
|
+
a.f035MelindaIds.some(id => id === b.f001)) {
|
|
81
54
|
debugData(`Melinda record's B f001 ${b.f001} matches record A f035 ${JSON.stringify(a.f035MelindaIds)}`);
|
|
82
55
|
return 1;
|
|
83
56
|
}
|
|
84
57
|
|
|
85
58
|
if (typeof a.f035MelindaIds !== 'undefined' && typeof b.f035MelindaIds !== 'undefined' &&
|
|
86
|
-
|
|
59
|
+
a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {
|
|
87
60
|
debugData(`Record A f035 ${JSON.stringify(a.f035MelindaIds)} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
|
|
88
61
|
return 1;
|
|
89
62
|
}
|
|
@@ -1,32 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
1
|
|
|
29
|
-
import createInterface from './standard-identifier-factory';
|
|
2
|
+
import createInterface from './standard-identifier-factory.js';
|
|
30
3
|
|
|
31
4
|
// DEVELOP: we should compare indicators and sf2 for f024
|
|
32
5
|
|