@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 5.0.0-alpha.2

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.
Files changed (123) hide show
  1. package/.github/workflows/melinda-node-tests.yml +13 -9
  2. package/LICENSE.txt +21 -165
  3. package/README.md +2 -2
  4. package/dist/candidate-search/candidate-search-utils.js +6 -43
  5. package/dist/candidate-search/candidate-search-utils.js.map +7 -1
  6. package/dist/candidate-search/choose-queries.js +75 -0
  7. package/dist/candidate-search/choose-queries.js.map +7 -0
  8. package/dist/candidate-search/index.js +89 -225
  9. package/dist/candidate-search/index.js.map +7 -1
  10. package/dist/candidate-search/index.test.js +92 -0
  11. package/dist/candidate-search/index.test.js.map +7 -0
  12. package/dist/candidate-search/query-list/bib.js +141 -320
  13. package/dist/candidate-search/query-list/bib.js.map +7 -1
  14. package/dist/candidate-search/query-list/bib.test.js +34 -0
  15. package/dist/candidate-search/query-list/bib.test.js.map +7 -0
  16. package/dist/candidate-search/query-list/component.js +87 -0
  17. package/dist/candidate-search/query-list/component.js.map +7 -0
  18. package/dist/candidate-search/query-list/index.js +39 -52
  19. package/dist/candidate-search/query-list/index.js.map +7 -1
  20. package/dist/cli.js +138 -0
  21. package/dist/cli.js.map +7 -0
  22. package/dist/index.js +87 -462
  23. package/dist/index.js.map +7 -1
  24. package/dist/index.test.js +69 -0
  25. package/dist/index.test.js.map +7 -0
  26. package/dist/match-detection/features/bib/all-source-ids.js +20 -91
  27. package/dist/match-detection/features/bib/all-source-ids.js.map +7 -1
  28. package/dist/match-detection/features/bib/authors.js +20 -76
  29. package/dist/match-detection/features/bib/authors.js.map +7 -1
  30. package/dist/match-detection/features/bib/bibliographic-level.js +4 -40
  31. package/dist/match-detection/features/bib/bibliographic-level.js.map +7 -1
  32. package/dist/match-detection/features/bib/host-component.js +5 -41
  33. package/dist/match-detection/features/bib/host-component.js.map +7 -1
  34. package/dist/match-detection/features/bib/index.js +17 -119
  35. package/dist/match-detection/features/bib/index.js.map +7 -1
  36. package/dist/match-detection/features/bib/index.test.js +40 -0
  37. package/dist/match-detection/features/bib/index.test.js.map +7 -0
  38. package/dist/match-detection/features/bib/isbn.js +13 -69
  39. package/dist/match-detection/features/bib/isbn.js.map +7 -1
  40. package/dist/match-detection/features/bib/issn.js +5 -50
  41. package/dist/match-detection/features/bib/issn.js.map +7 -1
  42. package/dist/match-detection/features/bib/language.js +25 -86
  43. package/dist/match-detection/features/bib/language.js.map +7 -1
  44. package/dist/match-detection/features/bib/media-type.js +12 -64
  45. package/dist/match-detection/features/bib/media-type.js.map +7 -1
  46. package/dist/match-detection/features/bib/melinda-id.js +5 -47
  47. package/dist/match-detection/features/bib/melinda-id.js.map +7 -1
  48. package/dist/match-detection/features/bib/melinda-identifier-factory.js +16 -67
  49. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +7 -1
  50. package/dist/match-detection/features/bib/other-standard-identifier.js +5 -51
  51. package/dist/match-detection/features/bib/other-standard-identifier.js.map +7 -1
  52. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +49 -189
  53. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +7 -1
  54. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +10 -53
  55. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +7 -1
  56. package/dist/match-detection/features/bib/publication-time.js +8 -46
  57. package/dist/match-detection/features/bib/publication-time.js.map +7 -1
  58. package/dist/match-detection/features/bib/record-type.js +4 -43
  59. package/dist/match-detection/features/bib/record-type.js.map +7 -1
  60. package/dist/match-detection/features/bib/standard-identifier-factory.js +47 -163
  61. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +7 -1
  62. package/dist/match-detection/features/bib/title-version-original.js +11 -53
  63. package/dist/match-detection/features/bib/title-version-original.js.map +7 -1
  64. package/dist/match-detection/features/bib/title.js +20 -72
  65. package/dist/match-detection/features/bib/title.js.map +7 -1
  66. package/dist/match-detection/features/index.js +3 -11
  67. package/dist/match-detection/features/index.js.map +7 -1
  68. package/dist/match-detection/index.js +35 -150
  69. package/dist/match-detection/index.js.map +7 -1
  70. package/dist/match-detection/index.test.js +44 -0
  71. package/dist/match-detection/index.test.js.map +7 -0
  72. package/dist/matching-utils.js +38 -102
  73. package/dist/matching-utils.js.map +7 -1
  74. package/eslint.config.js +52 -0
  75. package/example.env +4 -0
  76. package/package.json +29 -78
  77. package/src/candidate-search/candidate-search-utils.js +1 -28
  78. package/src/candidate-search/choose-queries.js +93 -0
  79. package/src/candidate-search/index.js +85 -119
  80. package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
  81. package/src/candidate-search/query-list/bib.js +54 -55
  82. package/src/candidate-search/query-list/bib.test.js +38 -0
  83. package/src/candidate-search/query-list/component.js +127 -0
  84. package/src/candidate-search/query-list/index.js +31 -35
  85. package/src/cli.js +177 -0
  86. package/src/index.js +27 -68
  87. package/src/{index.spec.js → index.test.js} +11 -42
  88. package/src/match-detection/features/bib/all-source-ids.js +2 -29
  89. package/src/match-detection/features/bib/authors.js +5 -30
  90. package/src/match-detection/features/bib/bibliographic-level.js +0 -27
  91. package/src/match-detection/features/bib/host-component.js +0 -27
  92. package/src/match-detection/features/bib/index.js +16 -43
  93. package/src/match-detection/features/bib/index.test.js +52 -0
  94. package/src/match-detection/features/bib/isbn.js +2 -29
  95. package/src/match-detection/features/bib/issn.js +1 -28
  96. package/src/match-detection/features/bib/language.js +5 -32
  97. package/src/match-detection/features/bib/media-type.js +2 -28
  98. package/src/match-detection/features/bib/melinda-id.js +1 -28
  99. package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
  100. package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
  101. package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
  102. package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
  103. package/src/match-detection/features/bib/publication-time.js +2 -28
  104. package/src/match-detection/features/bib/record-type.js +0 -27
  105. package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
  106. package/src/match-detection/features/bib/title-version-original.js +2 -28
  107. package/src/match-detection/features/bib/title.js +6 -34
  108. package/src/match-detection/features/index.js +1 -28
  109. package/src/match-detection/index.js +1 -28
  110. package/src/match-detection/{index.spec.js → index.test.js} +9 -35
  111. package/src/matching-utils.js +8 -37
  112. package/dist/candidate-search/index.spec.js +0 -144
  113. package/dist/candidate-search/index.spec.js.map +0 -1
  114. package/dist/candidate-search/query-list/bib.spec.js +0 -64
  115. package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
  116. package/dist/index.spec.js +0 -127
  117. package/dist/index.spec.js.map +0 -1
  118. package/dist/match-detection/features/bib/index.spec.js +0 -93
  119. package/dist/match-detection/features/bib/index.spec.js.map +0 -1
  120. package/dist/match-detection/index.spec.js +0 -91
  121. package/dist/match-detection/index.spec.js.map +0 -1
  122. package/src/candidate-search/query-list/bib.spec.js +0 -54
  123. package/src/match-detection/features/bib/index.spec.js +0 -78
@@ -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(`{$label} No actual values found`);
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
- a.f001 === b.f001) {
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
- b.f035MelindaIds.some(id => id === a.f001)) {
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
- a.f035MelindaIds.some(id => id === b.f001)) {
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
- a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {
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
 
@@ -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
-
29
- import {testStringOrNumber} from '../../../matching-utils';
1
+
30
2
  import createDebugLogger from 'debug';
3
+ import {testStringOrNumber} from '../../../matching-utils.js';
31
4
 
32
5
  // We should also get copyright time and copyright/publication times from 26x
33
6
  // We should also get publishing time type from f008
@@ -40,13 +13,13 @@ export default () => ({
40
13
  const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';
41
14
 
42
15
  const f008Values = extractF008Values(record);
43
- debug(`${label} f008: ${JSON.stringify(f008Values)}`);
16
+ debug(`${label}: f008: ${JSON.stringify(f008Values)}`);
44
17
 
45
18
  const f26xValues = extractF26xValues(record);
46
- debug(`${label} f26x: ${JSON.stringify(f26xValues)}`);
19
+ debug(`${label}: f26x: ${JSON.stringify(f26xValues)}`);
47
20
 
48
21
  const f500Values = extractF500Years(record);
49
- debug(`${label} f500: ${JSON.stringify(f500Values)}`);
22
+ debug(`${label}: f500: ${JSON.stringify(f500Values)}`);
50
23
 
51
24
  // We should get copyrightYear from f008Date2 to copyrightYears when f008YearType = 'r'
52
25
  // Is the original year (f008Date2) in f008YearType === 'r' comparable to copyrightYear?
@@ -150,7 +123,7 @@ export default () => ({
150
123
  .flat()
151
124
  .filter(({code}) => code === 'a')
152
125
  .map(({value}) => value);
153
- //.filter(value => value.test(reprintRegex));
126
+ //.filter(value => value.test(reprintRegex));
154
127
 
155
128
  debug(`f500 reprint field contents: ${JSON.stringify(reprintFieldContents)}`);
156
129
 
@@ -199,7 +172,7 @@ export default () => ({
199
172
  // Handle consequent years as a match
200
173
  // see publication-time for a version that does not handle consequent years as a match
201
174
  if (!(isNaN(firstANumber) || isNaN(firstBNumber)) &&
202
- (firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber)) {
175
+ (firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber)) {
203
176
  return 0.1;
204
177
  }
205
178
 
@@ -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
- import {testStringOrNumber} from '../../../matching-utils';
30
2
  import createDebugLogger from 'debug';
3
+ import {testStringOrNumber} from '../../../matching-utils.js';
31
4
 
32
5
  // We should also get copyright time and copyright/publication times from 26x
33
6
 
@@ -1,32 +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-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
1
 
29
- import {testStringOrNumber} from '../../../matching-utils';
2
+
3
+ import {testStringOrNumber} from '../../../matching-utils.js';
30
4
 
31
5
  // We should also get copyright time and copyright/publication times from 26x
32
6
  // see publication-time-allow-cons-years for a version allowing consequent years to match
@@ -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
  // we could handle the case of books/notes
30
3
  // Recordtype: LDR/06 - Type of Record
@@ -1,34 +1,7 @@
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
- */
29
2
 
30
3
  import createDebugLogger from 'debug';
31
- import {extractSubfieldsFromField, uniqueSubfields} from '../../../matching-utils';
4
+ import {extractSubfieldsFromField, uniqueSubfields} from '../../../matching-utils.js';
32
5
 
33
6
  // Note about validity of standardIdentifiers:
34
7
  // We have three types of invalid standardIdentifiers:
@@ -1,33 +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
2
  import createDebugLogger from 'debug';
30
- import {LevenshteinDistance as leven} from 'natural';
3
+ import naturalPkg from 'natural';
4
+ const {LevenshteinDistance: leven} = naturalPkg;
31
5
 
32
6
  export default ({treshold = 10} = {}) => ({
33
7
  name: 'titleVersionOriginal',