@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.
Files changed (107) 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/eslint.config.js +52 -0
  5. package/example.env +4 -0
  6. package/package.json +29 -79
  7. package/src/candidate-search/candidate-search-utils.js +1 -28
  8. package/src/candidate-search/choose-queries.js +93 -0
  9. package/src/candidate-search/index.js +85 -119
  10. package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
  11. package/src/candidate-search/query-list/bib.js +54 -55
  12. package/src/candidate-search/query-list/bib.test.js +38 -0
  13. package/src/candidate-search/query-list/component.js +127 -0
  14. package/src/candidate-search/query-list/index.js +31 -35
  15. package/src/cli.js +177 -0
  16. package/src/index.js +27 -68
  17. package/src/{index.spec.js → index.test.js} +11 -42
  18. package/src/match-detection/features/bib/all-source-ids.js +2 -29
  19. package/src/match-detection/features/bib/authors.js +5 -30
  20. package/src/match-detection/features/bib/bibliographic-level.js +0 -27
  21. package/src/match-detection/features/bib/host-component.js +0 -27
  22. package/src/match-detection/features/bib/index.js +16 -43
  23. package/src/match-detection/features/bib/index.test.js +52 -0
  24. package/src/match-detection/features/bib/isbn.js +2 -29
  25. package/src/match-detection/features/bib/issn.js +1 -28
  26. package/src/match-detection/features/bib/language.js +5 -32
  27. package/src/match-detection/features/bib/media-type.js +2 -28
  28. package/src/match-detection/features/bib/melinda-id.js +1 -28
  29. package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
  30. package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
  31. package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
  32. package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
  33. package/src/match-detection/features/bib/publication-time.js +2 -28
  34. package/src/match-detection/features/bib/record-type.js +0 -27
  35. package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
  36. package/src/match-detection/features/bib/title-version-original.js +2 -28
  37. package/src/match-detection/features/bib/title.js +6 -34
  38. package/src/match-detection/features/index.js +1 -28
  39. package/src/match-detection/index.js +1 -28
  40. package/src/match-detection/{index.spec.js → index.test.js} +9 -35
  41. package/src/matching-utils.js +8 -37
  42. package/dist/candidate-search/candidate-search-utils.js +0 -55
  43. package/dist/candidate-search/candidate-search-utils.js.map +0 -1
  44. package/dist/candidate-search/index.js +0 -254
  45. package/dist/candidate-search/index.js.map +0 -1
  46. package/dist/candidate-search/index.spec.js +0 -144
  47. package/dist/candidate-search/index.spec.js.map +0 -1
  48. package/dist/candidate-search/query-list/bib.js +0 -439
  49. package/dist/candidate-search/query-list/bib.js.map +0 -1
  50. package/dist/candidate-search/query-list/bib.spec.js +0 -64
  51. package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
  52. package/dist/candidate-search/query-list/index.js +0 -66
  53. package/dist/candidate-search/query-list/index.js.map +0 -1
  54. package/dist/index.js +0 -579
  55. package/dist/index.js.map +0 -1
  56. package/dist/index.spec.js +0 -127
  57. package/dist/index.spec.js.map +0 -1
  58. package/dist/match-detection/features/bib/all-source-ids.js +0 -119
  59. package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
  60. package/dist/match-detection/features/bib/authors.js +0 -113
  61. package/dist/match-detection/features/bib/authors.js.map +0 -1
  62. package/dist/match-detection/features/bib/bibliographic-level.js +0 -42
  63. package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
  64. package/dist/match-detection/features/bib/host-component.js +0 -42
  65. package/dist/match-detection/features/bib/host-component.js.map +0 -1
  66. package/dist/match-detection/features/bib/index.js +0 -119
  67. package/dist/match-detection/features/bib/index.js.map +0 -1
  68. package/dist/match-detection/features/bib/index.spec.js +0 -93
  69. package/dist/match-detection/features/bib/index.spec.js.map +0 -1
  70. package/dist/match-detection/features/bib/isbn.js +0 -77
  71. package/dist/match-detection/features/bib/isbn.js.map +0 -1
  72. package/dist/match-detection/features/bib/issn.js +0 -51
  73. package/dist/match-detection/features/bib/issn.js.map +0 -1
  74. package/dist/match-detection/features/bib/language.js +0 -141
  75. package/dist/match-detection/features/bib/language.js.map +0 -1
  76. package/dist/match-detection/features/bib/media-type.js +0 -83
  77. package/dist/match-detection/features/bib/media-type.js.map +0 -1
  78. package/dist/match-detection/features/bib/melinda-id.js +0 -48
  79. package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
  80. package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -89
  81. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
  82. package/dist/match-detection/features/bib/other-standard-identifier.js +0 -52
  83. package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
  84. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -256
  85. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +0 -1
  86. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +0 -71
  87. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +0 -1
  88. package/dist/match-detection/features/bib/publication-time.js +0 -48
  89. package/dist/match-detection/features/bib/publication-time.js.map +0 -1
  90. package/dist/match-detection/features/bib/record-type.js +0 -45
  91. package/dist/match-detection/features/bib/record-type.js.map +0 -1
  92. package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -215
  93. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
  94. package/dist/match-detection/features/bib/title-version-original.js +0 -79
  95. package/dist/match-detection/features/bib/title-version-original.js.map +0 -1
  96. package/dist/match-detection/features/bib/title.js +0 -98
  97. package/dist/match-detection/features/bib/title.js.map +0 -1
  98. package/dist/match-detection/features/index.js +0 -11
  99. package/dist/match-detection/features/index.js.map +0 -1
  100. package/dist/match-detection/index.js +0 -201
  101. package/dist/match-detection/index.js.map +0 -1
  102. package/dist/match-detection/index.spec.js +0 -91
  103. package/dist/match-detection/index.spec.js.map +0 -1
  104. package/dist/matching-utils.js +0 -143
  105. package/dist/matching-utils.js.map +0 -1
  106. package/src/candidate-search/query-list/bib.spec.js +0 -54
  107. package/src/match-detection/features/bib/index.spec.js +0 -78
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _melindaIdentifierFactory = _interopRequireDefault(require("./melinda-identifier-factory"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Melinda record matching modules for Javascript
14
- *
15
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-record-matching-js
18
- *
19
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Lesser General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-record-matching-js is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Lesser General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Affero General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
- var _default = () => {
37
- const {
38
- extract,
39
- compare
40
- } = (0, _melindaIdentifierFactory.default)();
41
- return {
42
- extract,
43
- compare,
44
- name: 'melinda-id'
45
- };
46
- };
47
- exports.default = _default;
48
- //# sourceMappingURL=melinda-id.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"melinda-id.js","names":["_melindaIdentifierFactory","_interopRequireDefault","require","obj","__esModule","default","_default","extract","compare","createInterface","name","exports"],"sources":["../../../../src/match-detection/features/bib/melinda-id.js"],"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 createInterface from './melinda-identifier-factory';\n\nexport default () => {\n const {extract, compare} = createInterface();\n return {extract, compare, name: 'melinda-id'};\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA5B3D;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;AA1BA,IAAAG,QAAA,GA8BeA,CAAA,KAAM;EACnB,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,iCAAe,EAAC,CAAC;EAC5C,OAAO;IAACF,OAAO;IAAEC,OAAO;IAAEE,IAAI,EAAE;EAAY,CAAC;AAC/C,CAAC;AAAAC,OAAA,CAAAN,OAAA,GAAAC,QAAA"}
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _debug = _interopRequireDefault(require("debug"));
8
- var _matchingUtils = require("../../../matching-utils");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- *
12
- * @licstart The following is the entire license notice for the JavaScript code in this file.
13
- *
14
- * Melinda record matching modules for Javascript
15
- *
16
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
17
- *
18
- * This file is part of melinda-record-matching-js
19
- *
20
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Lesser General Public License as
22
- * published by the Free Software Foundation, either version 3 of the
23
- * License, or (at your option) any later version.
24
- *
25
- * melinda-record-matching-js is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Lesser General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @licend The above is the entire license notice
34
- * for the JavaScript code in this file.
35
- *
36
- */
37
- // 003+001 FI-MELINDA <melinda-id>
38
- // 035 $a (FI-MELINDA)<melinda-id>
39
- // 035 $z (FI-MELINDA)<melinda-id>
40
- // 035 $a FCC<melinda-id>
41
- // 035 $z FCC<melinda-id>
42
- // melinda-id = 001234567
43
- var _default = () => {
44
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/melinda-id');
45
- const debugData = debug.extend('data');
46
- return {
47
- extract,
48
- compare
49
- };
50
- function extract({
51
- record,
52
- recordExternal
53
- }) {
54
- const isMelindaRecord = record.get('003').some(f003 => f003.value === 'FI-MELINDA');
55
- const [f001] = record.get('001').map(field => field.value);
56
- const f035MelindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
57
- if (isMelindaRecord === undefined && f001 === undefined && f035MelindaIds.length < 1) {
58
- debug(`${recordExternal.label} No Melinda-IDs found`);
59
- return {};
60
- }
61
- return {
62
- isMelindaRecord,
63
- f001,
64
- f035MelindaIds
65
- };
66
- }
67
- function compare(a, b) {
68
- if (a.isMelindaRecord && b.isMelindaRecord && a.f001 === b.f001) {
69
- debugData(`Melinda record's A f001 ${a.f001} matches Melinda record's B f001 ${a.f001}`);
70
- return 1;
71
- }
72
- if (a.isMelindaRecord && typeof b.f035MelindaIds !== 'undefined' && b.f035MelindaIds.some(id => id === a.f001)) {
73
- debugData(`Melinda record's A f001 ${a.f001} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
74
- return 1;
75
- }
76
- if (b.isMelindaRecord && typeof a.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(id => id === b.f001)) {
77
- debugData(`Melinda record's B f001 ${b.f001} matches record A f035 ${JSON.stringify(a.f035MelindaIds)}`);
78
- return 1;
79
- }
80
- if (typeof a.f035MelindaIds !== 'undefined' && typeof b.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {
81
- debugData(`Record A f035 ${JSON.stringify(a.f035MelindaIds)} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
82
- return 1;
83
- }
84
- debug(`No matching Melinda-IDs.`);
85
- return 0;
86
- }
87
- };
88
- exports.default = _default;
89
- //# sourceMappingURL=melinda-identifier-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"melinda-identifier-factory.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","_default","debug","createDebugLogger","debugData","extend","extract","compare","record","recordExternal","isMelindaRecord","get","some","f003","value","f001","map","field","f035MelindaIds","getMelindaIdsF035","undefined","length","label","a","b","id","JSON","stringify","idA","idB","exports"],"sources":["../../../../src/match-detection/features/bib/melinda-identifier-factory.js"],"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';\nimport {getMelindaIdsF035} from '../../../matching-utils';\n\n// 003+001 FI-MELINDA <melinda-id>\n// 035 $a (FI-MELINDA)<melinda-id>\n// 035 $z (FI-MELINDA)<melinda-id>\n// 035 $a FCC<melinda-id>\n// 035 $z FCC<melinda-id>\n// melinda-id = 001234567\n\nexport default () => {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/melinda-id');\n const debugData = debug.extend('data');\n\n return {extract, compare};\n\n function extract({record, recordExternal}) {\n\n const isMelindaRecord = record.get('003').some(f003 => f003.value === 'FI-MELINDA');\n const [f001] = record.get('001').map(field => field.value);\n const f035MelindaIds = getMelindaIdsF035(record);\n\n if (\n isMelindaRecord === undefined &&\n f001 === undefined &&\n f035MelindaIds.length < 1) {\n\n debug(`${recordExternal.label} No Melinda-IDs found`);\n return {};\n }\n\n return {isMelindaRecord, f001, f035MelindaIds};\n\n }\n\n function compare(a, b) {\n\n if (a.isMelindaRecord && b.isMelindaRecord &&\n a.f001 === b.f001) {\n debugData(`Melinda record's A f001 ${a.f001} matches Melinda record's B f001 ${a.f001}`);\n return 1;\n }\n\n if (a.isMelindaRecord && typeof b.f035MelindaIds !== 'undefined' &&\n b.f035MelindaIds.some(id => id === a.f001)) {\n debugData(`Melinda record's A f001 ${a.f001} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);\n return 1;\n }\n\n if (b.isMelindaRecord && typeof a.f035MelindaIds !== 'undefined' &&\n a.f035MelindaIds.some(id => id === b.f001)) {\n debugData(`Melinda record's B f001 ${b.f001} matches record A f035 ${JSON.stringify(a.f035MelindaIds)}`);\n return 1;\n }\n\n if (typeof a.f035MelindaIds !== 'undefined' && typeof b.f035MelindaIds !== 'undefined' &&\n a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {\n debugData(`Record A f035 ${JSON.stringify(a.f035MelindaIds)} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);\n return 1;\n }\n debug(`No matching Melinda-IDs.`);\n return 0;\n }\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAA0D,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7B1D;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;AAKA;AACA;AACA;AACA;AACA;AACA;AAAA,IAAAG,QAAA,GAEeA,CAAA,KAAM;EAEnB,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,2EAA2E,CAAC;EAC5G,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtC,OAAO;IAACC,OAAO;IAAEC;EAAO,CAAC;EAEzB,SAASD,OAAOA,CAAC;IAACE,MAAM;IAAEC;EAAc,CAAC,EAAE;IAEzC,MAAMC,eAAe,GAAGF,MAAM,CAACG,GAAG,CAAC,KAAK,CAAC,CAACC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,KAAK,KAAK,YAAY,CAAC;IACnF,MAAM,CAACC,IAAI,CAAC,GAAGP,MAAM,CAACG,GAAG,CAAC,KAAK,CAAC,CAACK,GAAG,CAACC,KAAK,IAAIA,KAAK,CAACH,KA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AAC;IACV;IAEA,IAAI,OAAOK,CAAC,CAACL,cAAc,KAAK,WAAW,IAAI,OAAOM,CAAC,CAACN,cAAc,KAAK,WAAW,IACjFK,CAAC,CAACL,cAAc,CAACN,IAAI,CAACgB,GAAG,IAAIJ,CAAC,CAACN,cAAc,CAACN,IAAI,CAACiB,GAAG,IAAIA,GAAG,KAAKD,GAAG,CAAC,CAAC,EAAE;MAC5ExB,SAAS,CAAE,iBAAgBsB,IAAI,CAACC,SAAS,CAACJ,CAAC,CAACL,cAAc,CAAE,0BAAyBQ,IAAI,CAACC,SAAS,CAACH,CAAC,CAACN,cAAc,CAAE,EAAC,CAAC;MACxH,OAAO,CAAC;IACV;IACAhB,KAAK,CAAE,0BAAyB,CAAC;IACjC,OAAO,CAAC;EACV;AACF,CAAC;AAAA4B,OAAA,CAAA9B,OAAA,GAAAC,QAAA"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Melinda record matching modules for Javascript
14
- *
15
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-record-matching-js
18
- *
19
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Lesser General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-record-matching-js is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Lesser General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Affero General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
- // DEVELOP: we should compare indicators and sf2 for f024
37
- var _default = () => {
38
- const {
39
- extract,
40
- compare
41
- } = (0, _standardIdentifierFactory.default)({
42
- pattern: /^024$/u,
43
- subfieldCodes: ['a', 'z']
44
- });
45
- return {
46
- extract,
47
- compare,
48
- name: 'Other standard identifier'
49
- };
50
- };
51
- exports.default = _default;
52
- //# sourceMappingURL=other-standard-identifier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"other-standard-identifier.js","names":["_standardIdentifierFactory","_interopRequireDefault","require","obj","__esModule","default","_default","extract","compare","createInterface","pattern","subfieldCodes","name","exports"],"sources":["../../../../src/match-detection/features/bib/other-standard-identifier.js"],"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 createInterface from './standard-identifier-factory';\n\n// DEVELOP: we should compare indicators and sf2 for f024\n\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^024$/u, subfieldCodes: ['a', 'z']});\n return {extract, compare, name: 'Other standard identifier'};\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA5B5D;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;AAAA,IAAAG,QAAA,GAEeA,CAAA,KAAM;EACnB,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,kCAAe,EAAC;IAACC,OAAO,EAAE,QAAQ;IAAEC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG;EAAC,CAAC,CAAC;EAC1F,OAAO;IAACJ,OAAO;IAAEC,OAAO;IAAEI,IAAI,EAAE;EAA2B,CAAC;AAC9D,CAAC;AAAAC,OAAA,CAAAR,OAAA,GAAAC,QAAA"}
@@ -1,256 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _matchingUtils = require("../../../matching-utils");
8
- var _debug = _interopRequireDefault(require("debug"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- *
12
- * @licstart The following is the entire license notice for the JavaScript code in this file.
13
- *
14
- * Melinda record matching modules for Javascript
15
- *
16
- * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
17
- *
18
- * This file is part of melinda-record-matching-js
19
- *
20
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Lesser General Public License as
22
- * published by the Free Software Foundation, either version 3 of the
23
- * License, or (at your option) any later version.
24
- *
25
- * melinda-record-matching-js is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Lesser General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @licend The above is the entire license notice
34
- * for the JavaScript code in this file.
35
- *
36
- */
37
- // We should also get copyright time and copyright/publication times from 26x
38
- // We should also get publishing time type from f008
39
- // We should get reprint times from f500 $a "Lisäpainos/Lisäpainokset:"
40
- var _default = () => ({
41
- name: 'Publication time, allow consequent years, years from multiple sources',
42
- extract: ({
43
- record,
44
- recordExternal
45
- }) => {
46
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years-multi');
47
- const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';
48
- const f008Values = extractF008Values(record);
49
- debug(`${label} f008: ${JSON.stringify(f008Values)}`);
50
- const f26xValues = extractF26xValues(record);
51
- debug(`${label} f26x: ${JSON.stringify(f26xValues)}`);
52
- const f500Values = extractF500Years(record);
53
- debug(`${label} f500: ${JSON.stringify(f500Values)}`);
54
-
55
- // We should get copyrightYear from f008Date2 to copyrightYears when f008YearType = 'r'
56
- // Is the original year (f008Date2) in f008YearType === 'r' comparable to copyrightYear?
57
- // We should handle unknown years (here or comparison?)
58
- // We should handle year ranges for continuing resources / collections
59
-
60
- const normalYears = [...new Set(f26xValues.normalYears.concat(f008Values.f008Date1).filter(value => value && value !== ' ' && value !== '||||'))].sort();
61
- const copyrightYears = [...new Set(f26xValues.copyrightYears)].sort();
62
- const reprintYears = [...new Set(f500Values)].sort();
63
- const combined = {
64
- normalYears,
65
- copyrightYears,
66
- reprintYears
67
- };
68
- debug(`Combined: ${JSON.stringify(combined)}`);
69
- return combined;
70
- function extractF008Values(record) {
71
- // Record should have only one f008 - in case of several, we handle the first one
72
- const value = record.get(/^008$/u)?.[0]?.value || undefined;
73
- if (value && (0, _matchingUtils.testStringOrNumber)(value)) {
74
- const f008Date1 = extractF008Date1(value);
75
- const f008Date2 = extractF008Date2(value);
76
- const f008YearType = extractF008YearType(value);
77
- return {
78
- f008Date1,
79
- f008Date2,
80
- f008YearType
81
- };
82
- }
83
- return {
84
- f008Date1: undefined,
85
- f008Date2: undefined,
86
- f008YearType: undefined
87
- };
88
- function extractF008Date1(value) {
89
- return String(value).slice(7, 11);
90
- }
91
- function extractF008Date2(value) {
92
- return String(value).slice(11, 15);
93
- }
94
- function extractF008YearType(value) {
95
- return String(value).slice(6, 7);
96
- }
97
- }
98
- function extractF26xValues(record) {
99
- const copyrightRegex = /^(?<copyrightPrefix>cop|cop.|c|©|p|℗)/u;
100
- const pubNormalSubFieldValues = extractPubNormalSubfieldValues(record, copyrightRegex);
101
- debug(`Normal years: ${JSON.stringify(pubNormalSubFieldValues)}`);
102
- const pubF264CopySubFieldValues = extractPubF264CopySubfieldValues(record);
103
- debug(`F264 copyright years: ${JSON.stringify(pubF264CopySubFieldValues)}`);
104
- const pubF260CopySubFieldValues = extractPubF260CopySubfieldValues(record, copyrightRegex);
105
- debug(`F260 copyright years: ${JSON.stringify(pubF260CopySubFieldValues)}`);
106
- return {
107
- normalYears: pubNormalSubFieldValues,
108
- copyrightYears: [...pubF260CopySubFieldValues, ...pubF264CopySubFieldValues]
109
- };
110
- function extractPubNormalSubfieldValues(record, copyrightRegex) {
111
- return record.get(/^26[04]$/u).filter(field => !(field.tag === '264' && field.ind2 === '4')).map(({
112
- subfields
113
- }) => subfields).flat().filter(({
114
- code
115
- }) => code && code === 'c').filter(({
116
- value
117
- }) => value && !copyrightRegex.test(value)).map(({
118
- value
119
- }) => value).map(value => removeNonAlphaNumeric(value));
120
- }
121
- function extractPubF264CopySubfieldValues(record, copyrightRegex) {
122
- return record.get(/^264$/u).filter(field => field.ind2 === '4').map(({
123
- subfields
124
- }) => subfields).flat().filter(({
125
- code
126
- }) => code && code === 'c').filter(({
127
- value
128
- }) => value).map(({
129
- value
130
- }) => value).map(value => value.replace(copyrightRegex, '')).map(value => removeNonAlphaNumeric(value));
131
- }
132
- function extractPubF260CopySubfieldValues(record, copyrightRegex) {
133
- return record.get(/^260$/u).map(({
134
- subfields
135
- }) => subfields).flat().filter(({
136
- code
137
- }) => code && code === 'c').filter(({
138
- value
139
- }) => value && copyrightRegex.test(value)).map(({
140
- value
141
- }) => value).map(value => value.replace(copyrightRegex, '')).map(value => removeNonAlphaNumeric(value));
142
- }
143
- function removeNonAlphaNumeric(value) {
144
- debug(`Cleaning: ${JSON.stringify(value)}`);
145
- const nonAlphaNumericRegex = /[^A-Za-z0-9]/ug;
146
- return value ? value.replace(nonAlphaNumericRegex, '') : value;
147
- }
148
- }
149
- function extractF500Years(record) {
150
- const reprintRegex = /(?<reprint>Lisäpainokset:|Lisäpainos:)/u;
151
- const reprintFieldContents = record.get(/^500$/u).map(({
152
- subfields
153
- }) => subfields).flat().filter(({
154
- code
155
- }) => code === 'a').map(({
156
- value
157
- }) => value);
158
- //.filter(value => value.test(reprintRegex));
159
-
160
- debug(`f500 reprint field contents: ${JSON.stringify(reprintFieldContents)}`);
161
- const filteredF500 = reprintFieldContents.filter(content => content && content.match(reprintRegex));
162
- debug(`f500 reprint field contents (filtered): ${JSON.stringify(filteredF500)}`);
163
- const reprintYears = extractReprintYears(filteredF500);
164
- return reprintYears;
165
- }
166
- function extractReprintYears(contents) {
167
- const yearRegex = /[0-9][0-9][0-9][0-9]/gu;
168
- const years = contents.map(content => content.match(yearRegex)).flat();
169
- debug(`${JSON.stringify(years)}`);
170
- const uniqYears = [...new Set(years)].sort();
171
- debug(`${JSON.stringify(uniqYears)}`);
172
- return uniqYears;
173
- }
174
- },
175
- // eslint-disable-next-line max-statements
176
- compare: (a, b) => {
177
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years-multi');
178
- debug(`Comparing ${JSON.stringify(a)} to ${JSON.stringify(b)}`);
179
- const [firstA] = a.normalYears ? a.normalYears : a;
180
- const [firstB] = b.normalYears ? b.normalYears : b;
181
- debug(`Comparing ${JSON.stringify(firstA)} to ${JSON.stringify(firstB)}`);
182
- if (firstA === firstB) {
183
- return 0.1;
184
- }
185
-
186
- // If either of years is a non string/number, values are not comparable
187
- if (!(0, _matchingUtils.testStringOrNumber)(firstA) || !(0, _matchingUtils.testStringOrNumber)(firstB)) {
188
- return 0;
189
- }
190
- const firstANumber = parseInt(firstA, 10);
191
- const firstBNumber = parseInt(firstB, 10);
192
-
193
- // Handle consequent years as a match
194
- // see publication-time for a version that does not handle consequent years as a match
195
- if (!(isNaN(firstANumber) || isNaN(firstBNumber)) && (firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber)) {
196
- return 0.1;
197
- }
198
-
199
- // We should do something with copyrightYears, too
200
-
201
- // Do not give minus points if a normal publishing year is found in normal years
202
- const bNormalInANormal = a.normalYears.filter(aValue => b.normalYears.some(bValue => aValue === bValue));
203
- const aNormalInBNormal = b.normalYears.filter(bValue => a.normalYears.some(aValue => bValue === aValue));
204
- debug(`BNorm in ANorm: ${JSON.stringify(bNormalInANormal)}`);
205
- debug(`ANorm in BNorm: ${JSON.stringify(aNormalInBNormal)}`);
206
- if (bNormalInANormal > 0 || aNormalInBNormal > 0) {
207
- return 0;
208
- }
209
-
210
- // Do not give minus points if a normal publishing year is found in reprint years
211
- const bNormalInAReprint = a.reprintYears.filter(aValue => b.normalYears.some(bValue => aValue === bValue));
212
- const aNormalInBReprint = b.reprintYears.filter(bValue => a.normalYears.some(aValue => bValue === aValue));
213
- debug(`BNorm in AReprint: ${JSON.stringify(bNormalInAReprint)}`);
214
- debug(`ANorm in BReprint: ${JSON.stringify(aNormalInBReprint)}`);
215
- if (bNormalInAReprint > 0 || aNormalInBReprint > 0) {
216
- return 0;
217
- }
218
- return -1;
219
- }
220
- }); // https://www.loc.gov/marc/bibliographic/bd008.html
221
- // field 008
222
- // 06 - Type of date/Publication status
223
- // 07-10 - Date 1
224
- // 11-14 - Date 2
225
- //
226
- // 06 - Type of date/Publication status
227
- // b - No dates given; B.C. date involved
228
- // c - Continuing resource currently published
229
- // d - Continuing resource ceased publication
230
- // e - Detailed date
231
- // i - Inclusive dates of collection
232
- // k - Range of years of bulk of collection
233
- // m - Multiple dates
234
- // n - Dates unknown
235
- // p - Date of distribution/release/issue and production/recording session when different
236
- // q - Questionable date
237
- // r - Reprint/reissue date and original date
238
- // s - Single known date/probable date
239
- // t - Publication date and copyright date
240
- // u - Continuing resource status unknown
241
- // | - No attempt to code
242
- //
243
- // 07-10 - Date 1
244
- // 1-9 - Date digit
245
- // # - Date element is not applicable
246
- // u - Date element is totally or partially unknown
247
- // |||| - No attempt to code
248
- //
249
- // 11-14 - Date 2
250
- // 1-9 - Date digit
251
- // # - Date element is not applicable
252
- // u - Date element is totally or partially unknown
253
- // |||| - No attempt to code
254
- //
255
- exports.default = _default;
256
- //# sourceMappingURL=publication-time-allow-cons-years-multi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publication-time-allow-cons-years-multi.js","names":["_matchingUtils","require","_debug","_interopRequireDefault","obj","__esModule","default","_default","name","extract","record","recordExternal","debug","createDebugLogger","label","f008Values","extractF008Values","JSON","stringify","f26xValues","extractF26xValues","f500Values","extractF500Years","normalYears","Set","concat","f008Date1","filter","value","sort","copyrightYears","reprintYears","combined","get","undefined","testStringOrNumber","extractF008Date1","f008Date2","extractF008Date2","f008YearType","extractF008YearType","String","slice","copyrightRegex","pubNormalSubFieldValues","extractPubNormalSubfieldValues","pubF264CopySubFieldValues","extractPubF264CopySubfieldValues","pubF260CopySubFieldValues","extractPubF260CopySubfieldValues","field","tag","ind2","map","subfields","flat","code","test","removeNonAlphaNumeric","replace","nonAlphaNumericRegex","reprintRegex","reprintFieldContents","filteredF500","content","match","extractReprintYears","contents","yearRegex","years","uniqYears","compare","a","b","firstA","firstB","firstANumber","parseInt","firstBNumber","isNaN","bNormalInANormal","aValue","some","bValue","aNormalInBNormal","bNormalInAReprint","aNormalInBReprint","exports"],"sources":["../../../../src/match-detection/features/bib/publication-time-allow-cons-years-multi.js"],"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-2023 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 {testStringOrNumber} from '../../../matching-utils';\nimport createDebugLogger from 'debug';\n\n// We should also get copyright time and copyright/publication times from 26x\n// We should also get publishing time type from f008\n// We should get reprint times from f500 $a \"Lisäpainos/Lisäpainokset:\"\n\nexport default () => ({\n name: 'Publication time, allow consequent years, years from multiple sources',\n extract: ({record, recordExternal}) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years-multi');\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n\n const f008Values = extractF008Values(record);\n debug(`${label} f008: ${JSON.stringify(f008Values)}`);\n\n const f26xValues = extractF26xValues(record);\n debug(`${label} f26x: ${JSON.stringify(f26xValues)}`);\n\n const f500Values = extractF500Years(record);\n debug(`${label} f500: ${JSON.stringify(f500Values)}`);\n\n // We should get copyrightYear from f008Date2 to copyrightYears when f008YearType = 'r'\n // Is the original year (f008Date2) in f008YearType === 'r' comparable to copyrightYear?\n // We should handle unknown years (here or comparison?)\n // We should handle year ranges for continuing resources / collections\n\n const normalYears = [...new Set(f26xValues.normalYears.concat(f008Values.f008Date1).filter(value => value && value !== ' ' && value !== '||||'))].sort();\n const copyrightYears = [...new Set(f26xValues.copyrightYears)].sort();\n const reprintYears = [...new Set(f500Values)].sort();\n\n const combined = {normalYears, copyrightYears, reprintYears};\n\n debug(`Combined: ${JSON.stringify(combined)}`);\n\n return combined;\n\n function extractF008Values(record) {\n // Record should have only one f008 - in case of several, we handle the first one\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n if (value && testStringOrNumber(value)) {\n const f008Date1 = extractF008Date1(value);\n const f008Date2 = extractF008Date2(value);\n const f008YearType = extractF008YearType(value);\n return {f008Date1, f008Date2, f008YearType};\n }\n return {f008Date1: undefined, f008Date2: undefined, f008YearType: undefined};\n\n function extractF008Date1(value) {\n return String(value).slice(7, 11);\n }\n\n function extractF008Date2(value) {\n return String(value).slice(11, 15);\n }\n\n function extractF008YearType(value) {\n return String(value).slice(6, 7);\n }\n }\n\n function extractF26xValues(record) {\n const copyrightRegex = /^(?<copyrightPrefix>cop|cop.|c|©|p|℗)/u;\n\n const pubNormalSubFieldValues = extractPubNormalSubfieldValues(record, copyrightRegex);\n debug(`Normal years: ${JSON.stringify(pubNormalSubFieldValues)}`);\n\n const pubF264CopySubFieldValues = extractPubF264CopySubfieldValues(record);\n debug(`F264 copyright years: ${JSON.stringify(pubF264CopySubFieldValues)}`);\n\n const pubF260CopySubFieldValues = extractPubF260CopySubfieldValues(record, copyrightRegex);\n debug(`F260 copyright years: ${JSON.stringify(pubF260CopySubFieldValues)}`);\n\n return {normalYears: pubNormalSubFieldValues, copyrightYears: [...pubF260CopySubFieldValues, ...pubF264CopySubFieldValues]};\n\n function extractPubNormalSubfieldValues(record, copyrightRegex) {\n return record.get(/^26[04]$/u)\n .filter((field) => !(field.tag === '264' && field.ind2 === '4'))\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code && code === 'c')\n .filter(({value}) => value && !copyrightRegex.test(value))\n .map(({value}) => value)\n .map((value) => removeNonAlphaNumeric(value));\n }\n\n function extractPubF264CopySubfieldValues(record, copyrightRegex) {\n return record.get(/^264$/u)\n .filter((field) => field.ind2 === '4')\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code && code === 'c')\n .filter(({value}) => value)\n .map(({value}) => value)\n .map((value) => value.replace(copyrightRegex, ''))\n .map((value) => removeNonAlphaNumeric(value));\n }\n\n function extractPubF260CopySubfieldValues(record, copyrightRegex) {\n return record.get(/^260$/u)\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code && code === 'c')\n .filter(({value}) => value && copyrightRegex.test(value))\n .map(({value}) => value)\n .map((value) => value.replace(copyrightRegex, ''))\n .map((value) => removeNonAlphaNumeric(value));\n }\n\n function removeNonAlphaNumeric(value) {\n debug(`Cleaning: ${JSON.stringify(value)}`);\n const nonAlphaNumericRegex = /[^A-Za-z0-9]/ug;\n return value ? value.replace(nonAlphaNumericRegex, '') : value;\n }\n }\n\n function extractF500Years(record) {\n\n const reprintRegex = /(?<reprint>Lisäpainokset:|Lisäpainos:)/u;\n const reprintFieldContents = record.get(/^500$/u)\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'a')\n .map(({value}) => value);\n //.filter(value => value.test(reprintRegex));\n\n debug(`f500 reprint field contents: ${JSON.stringify(reprintFieldContents)}`);\n\n const filteredF500 = reprintFieldContents.filter((content) => content && content.match(reprintRegex));\n\n debug(`f500 reprint field contents (filtered): ${JSON.stringify(filteredF500)}`);\n\n const reprintYears = extractReprintYears(filteredF500);\n\n return reprintYears;\n }\n\n function extractReprintYears(contents) {\n const yearRegex = /[0-9][0-9][0-9][0-9]/gu;\n const years = contents.map(content => content.match(yearRegex))\n .flat();\n debug(`${JSON.stringify(years)}`);\n const uniqYears = [...new Set(years)].sort();\n debug(`${JSON.stringify(uniqYears)}`);\n return uniqYears;\n }\n\n },\n // eslint-disable-next-line max-statements\n compare: (a, b) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years-multi');\n debug(`Comparing ${JSON.stringify(a)} to ${JSON.stringify(b)}`);\n\n const [firstA] = a.normalYears ? a.normalYears : a;\n const [firstB] = b.normalYears ? b.normalYears : b;\n\n debug(`Comparing ${JSON.stringify(firstA)} to ${JSON.stringify(firstB)}`);\n\n if (firstA === firstB) {\n return 0.1;\n }\n\n // If either of years is a non string/number, values are not comparable\n if (!testStringOrNumber(firstA) || !testStringOrNumber(firstB)) {\n return 0;\n }\n\n const firstANumber = parseInt(firstA, 10);\n const firstBNumber = parseInt(firstB, 10);\n\n // Handle consequent years as a match\n // see publication-time for a version that does not handle consequent years as a match\n if (!(isNaN(firstANumber) || isNaN(firstBNumber)) &&\n (firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber)) {\n return 0.1;\n }\n\n // We should do something with copyrightYears, too\n\n // Do not give minus points if a normal publishing year is found in normal years\n const bNormalInANormal = a.normalYears.filter(aValue => b.normalYears.some(bValue => aValue === bValue));\n const aNormalInBNormal = b.normalYears.filter(bValue => a.normalYears.some(aValue => bValue === aValue));\n debug(`BNorm in ANorm: ${JSON.stringify(bNormalInANormal)}`);\n debug(`ANorm in BNorm: ${JSON.stringify(aNormalInBNormal)}`);\n\n if (bNormalInANormal > 0 || aNormalInBNormal > 0) {\n return 0;\n }\n\n // Do not give minus points if a normal publishing year is found in reprint years\n const bNormalInAReprint = a.reprintYears.filter(aValue => b.normalYears.some(bValue => aValue === bValue));\n const aNormalInBReprint = b.reprintYears.filter(bValue => a.normalYears.some(aValue => bValue === aValue));\n debug(`BNorm in AReprint: ${JSON.stringify(bNormalInAReprint)}`);\n debug(`ANorm in BReprint: ${JSON.stringify(aNormalInBReprint)}`);\n\n if (bNormalInAReprint > 0 || aNormalInBReprint > 0) {\n return 0;\n }\n\n return -1;\n\n }\n});\n\n// https://www.loc.gov/marc/bibliographic/bd008.html\n// field 008\n// 06 - Type of date/Publication status\n// 07-10 - Date 1\n// 11-14 - Date 2\n//\n// 06 - Type of date/Publication status\n// b - No dates given; B.C. date involved\n// c - Continuing resource currently published\n// d - Continuing resource ceased publication\n// e - Detailed date\n// i - Inclusive dates of collection\n// k - Range of years of bulk of collection\n// m - Multiple dates\n// n - Dates unknown\n// p - Date of distribution/release/issue and production/recording session when different\n// q - Questionable date\n// r - Reprint/reissue date and original date\n// s - Single known date/probable date\n// t - Publication date and copyright date\n// u - Continuing resource status unknown\n// | - No attempt to code\n//\n// 07-10 - Date 1\n// 1-9 - Date digit\n// # - Date element is not applicable\n// u - Date element is totally or partially unknown\n// |||| - No attempt to code\n//\n// 11-14 - Date 2\n// 1-9 - Date digit\n// # - Date element is not applicable\n// u - Date element is totally or partially unknown\n// |||| - No attempt to code\n//\n\n"],"mappings":";;;;;;AA4BA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAsC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7BtC;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;AAKA;AACA;AACA;AAAA,IAAAG,QAAA,GAEeA,CAAA,MAAO;EACpBC,IAAI,EAAE,uEAAuE;EAC7EC,OAAO,EAAEA,CAAC;IAACC,MAAM;IAAEC;EAAc,CAAC,KAAK;IACrC,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,wGAAwG,CAAC;IACzI,MAAMC,KAAK,GAAGH,cAAc,IAAIA,cAAc,CAACG,KAAK,GAAGH,cAAc,CAACG,KAAK,GAAG,QAAQ;IAEtF,MAAMC,UAAU,GAAGC,iBAAiB,CAACN,MAAM,CAAC;IAC5CE,KAAK,CAAE,GAAEE,KAAM,UAASG,IAAI,CAACC,SAAS,CAACH,UAAU,CAAE,EAAC,CAAC;IAErD,MAAMI,UAAU,GAAGC,iBAAiB,CAACV,MAAM,CAAC;IAC5CE,KAAK,CAAE,GAAEE,KAAM,UAASG,IAAI,CAACC,SAAS,CAACC,UAAU,CAAE,EAAC,CAAC;IAErD,MAAME,UAAU,GAAGC,gBAAgB,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S,CAACkE,gBAAgB,CAAE,EAAC,CAAC;IAE5D,IAAIJ,gBAAgB,GAAG,CAAC,IAAII,gBAAgB,GAAG,CAAC,EAAE;MAChD,OAAO,CAAC;IACV;;IAEA;IACA,MAAMC,iBAAiB,GAAGb,CAAC,CAACzC,YAAY,CAACJ,MAAM,CAACsD,MAAM,IAAIR,CAAC,CAAClD,WAAW,CAAC2D,IAAI,CAACC,MAAM,IAAIF,MAAM,KAAKE,MAAM,CAAC,CAAC;IAC1G,MAAMG,iBAAiB,GAAGb,CAAC,CAAC1C,YAAY,CAACJ,MAAM,CAACwD,MAAM,IAAIX,CAAC,CAACjD,WAAW,CAAC2D,IAAI,CAACD,MAAM,IAAIE,MAAM,KAAKF,MAAM,CAAC,CAAC;IAC1GrE,KAAK,CAAE,sBAAqBK,IAAI,CAACC,SAAS,CAACmE,iBAAiB,CAAE,EAAC,CAAC;IAChEzE,KAAK,CAAE,sBAAqBK,IAAI,CAACC,SAAS,CAACoE,iBAAiB,CAAE,EAAC,CAAC;IAEhE,IAAID,iBAAiB,GAAG,CAAC,IAAIC,iBAAiB,GAAG,CAAC,EAAE;MAClD,OAAO,CAAC;IACV;IAEA,OAAO,CAAC,CAAC;EAEX;AACF,CAAC,CAAC,EAEF;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAAC,OAAA,CAAAjF,OAAA,GAAAC,QAAA"}
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _matchingUtils = require("../../../matching-utils");
8
- var _debug = _interopRequireDefault(require("debug"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- *
12
- * @licstart The following is the entire license notice for the JavaScript code in this file.
13
- *
14
- * Melinda record matching modules for Javascript
15
- *
16
- * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
17
- *
18
- * This file is part of melinda-record-matching-js
19
- *
20
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Lesser General Public License as
22
- * published by the Free Software Foundation, either version 3 of the
23
- * License, or (at your option) any later version.
24
- *
25
- * melinda-record-matching-js is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Lesser General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @licend The above is the entire license notice
34
- * for the JavaScript code in this file.
35
- *
36
- */
37
- // We should also get copyright time and copyright/publication times from 26x
38
- var _default = () => ({
39
- name: 'Publication time, allow consequent years',
40
- extract: ({
41
- record
42
- }) => {
43
- const value = record.get(/^008$/u)?.[0]?.value || undefined;
44
- return (0, _matchingUtils.testStringOrNumber)(value) ? [String(value).slice(7, 11)] : [];
45
- },
46
- compare: (a, b) => {
47
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years');
48
- debug(`Comparing ${a[0]} to ${b[0]}`);
49
- const [firstA] = a;
50
- const [firstB] = b;
51
- if (firstA === firstB) {
52
- return 0.1;
53
- }
54
-
55
- // If either of years is a non string/number, values are not comparable
56
- if (!(0, _matchingUtils.testStringOrNumber)(firstA) || !(0, _matchingUtils.testStringOrNumber)(firstB)) {
57
- return 0;
58
- }
59
- const firstANumber = parseInt(firstA, 10);
60
- const firstBNumber = parseInt(firstB, 10);
61
- if (isNaN(firstANumber) || isNaN(firstBNumber)) {
62
- return -1;
63
- }
64
-
65
- // Handle consequent years as a match
66
- // see publication-time for a version that does not handle consequent years as a match
67
- return firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber ? 0.1 : -1;
68
- }
69
- });
70
- exports.default = _default;
71
- //# sourceMappingURL=publication-time-allow-cons-years.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publication-time-allow-cons-years.js","names":["_matchingUtils","require","_debug","_interopRequireDefault","obj","__esModule","default","_default","name","extract","record","value","get","undefined","testStringOrNumber","String","slice","compare","a","b","debug","createDebugLogger","firstA","firstB","firstANumber","parseInt","firstBNumber","isNaN","exports"],"sources":["../../../../src/match-detection/features/bib/publication-time-allow-cons-years.js"],"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-2023 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 {testStringOrNumber} from '../../../matching-utils';\nimport createDebugLogger from 'debug';\n\n// We should also get copyright time and copyright/publication times from 26x\n\nexport default () => ({\n name: 'Publication time, allow consequent years',\n extract: ({record}) => {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n return testStringOrNumber(value) ? [String(value).slice(7, 11)] : [];\n },\n compare: (a, b) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/publication-time-allow-cons-years');\n debug(`Comparing ${a[0]} to ${b[0]}`);\n\n const [firstA] = a;\n const [firstB] = b;\n\n if (firstA === firstB) {\n return 0.1;\n }\n\n // If either of years is a non string/number, values are not comparable\n if (!testStringOrNumber(firstA) || !testStringOrNumber(firstB)) {\n return 0;\n }\n\n const firstANumber = parseInt(firstA, 10);\n const firstBNumber = parseInt(firstB, 10);\n\n if (isNaN(firstANumber) || isNaN(firstBNumber)) {\n return -1;\n }\n\n // Handle consequent years as a match\n // see publication-time for a version that does not handle consequent years as a match\n return firstANumber + 1 === firstBNumber || firstANumber - 1 === firstBNumber ? 0.1 : -1;\n }\n});\n"],"mappings":";;;;;;AA4BA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAsC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7BtC;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;AAKA;AAAA,IAAAG,QAAA,GAEeA,CAAA,MAAO;EACpBC,IAAI,EAAE,0CAA0C;EAChDC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,KAAK;IACrB,MAAMC,KAAK,GAAGD,MAAM,CAACE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAED,KAAK,IAAIE,SAAS;IAC3D,OAAO,IAAAC,iCAAkB,EAACH,KAAK,CAAC,GAAG,CAACI,MAAM,CAACJ,KAAK,CAAC,CAACK,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE;EACtE,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAK;IACjB,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,kGAAkG,CAAC;IACnID,KAAK,CAAE,aAAYF,CAAC,CAAC,CAAC,CAAE,OAAMC,CAAC,CAAC,CAAC,CAAE,EAAC,CAAC;IAErC,MAAM,CAACG,MAAM,CAAC,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