@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,94 +1,40 @@
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-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
-
38
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:language');
39
- const debugData = debug.extend('data');
40
- var _default = () => ({
41
- name: 'Language',
42
- extract: ({
43
- record,
44
- recordExternal
45
- }) => {
46
- const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';
1
+ import createDebugLogger from "debug";
2
+ import { getMatchCounts } from "../../../matching-utils.js";
3
+ const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:features:language");
4
+ const debugData = debug.extend("data");
5
+ export default () => ({
6
+ name: "Language",
7
+ extract: ({ record, recordExternal }) => {
8
+ const label = recordExternal && recordExternal.label ? recordExternal.label : "record";
47
9
  const value008 = get008Value();
48
10
  const values041 = get041Values();
49
- debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
11
+ debugData(`${label}: 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
50
12
  if (!value008 && values041.length < 1) {
51
- debugData(`{$label} No actual values found`);
13
+ debugData(`${label}: No actual values found`);
52
14
  return [];
53
15
  }
54
- const allValues = value008 === undefined ? values041 : values041.concat(value008);
16
+ const allValues = value008 === void 0 ? values041 : values041.concat(value008);
55
17
  const uniqueSortedValues = [...new Set(allValues)].sort();
56
18
  return uniqueSortedValues;
57
19
  function get008Value() {
58
- const value = record.get(/^008$/u)?.[0]?.value || undefined;
59
- debugData(`${label} 008 value: ${value}`);
20
+ const value = record.get(/^008$/u)?.[0]?.value || void 0;
21
+ debugData(`${label}: 008 value: ${value}`);
60
22
  if (!value) {
61
- return undefined;
23
+ return void 0;
62
24
  }
63
25
  const code = value.slice(35, 38);
64
- debugData(`${label} 008 code: ${code}`);
65
- return isLangCodeForALanguage(code) ? code : undefined;
26
+ debugData(`${label}: 008 code: ${code}`);
27
+ return isLangCodeForALanguage(code) ? code : void 0;
66
28
  }
67
-
68
- // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes
69
-
70
29
  function get041Values() {
71
- return record.get(/^041$/u).filter(({
72
- ind2
73
- }) => ind2 === ' ').map(({
74
- subfields
75
- }) => subfields).flat().filter(({
76
- code
77
- }) => code === 'a' || code === 'd').filter(({
78
- value
79
- }) => value && isLangCodeForALanguage(value)).map(({
80
- value
81
- }) => value);
30
+ return record.get(/^041$/u).filter(({ ind2 }) => ind2 === " ").map(({ subfields }) => subfields).flat().filter(({ code }) => code === "a" || code === "d").filter(({ value }) => value && isLangCodeForALanguage(value)).map(({ value }) => value);
82
31
  }
83
-
84
- // Check if a string is a possible, validly formed language code for a single language
85
- // Currently accept also codes in capitals
86
32
  function isLangCodeForALanguage(code) {
87
33
  if (code.length !== 3) {
88
34
  debugData(`Code ${code} is not correct length (3) for a language code.`);
89
35
  return false;
90
36
  }
91
- if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {
37
+ if (code === "|||" || code === " " || code === "^^^" || code === "mul" || code === "zxx") {
92
38
  debugData(`Code ${code} is not code for a spesific language.`);
93
39
  return false;
94
40
  }
@@ -111,31 +57,24 @@ var _default = () => ({
111
57
  debugData(`All languages match`);
112
58
  return 0.1;
113
59
  }
114
- const {
115
- matchingValues,
116
- possibleMatchValues,
117
- maxValues
118
- } = (0, _matchingUtils.getMatchCounts)(a, b);
60
+ const { matchingValues, possibleMatchValues, maxValues } = getMatchCounts(a, b);
119
61
  if (matchingValues < 1) {
120
62
  debug(`Both have languages, but none of these match.`);
121
- return -1.0;
63
+ return -1;
122
64
  }
123
65
  debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);
124
- // ignore non-matches if there is mismatching amount of values
125
66
  debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);
126
- //we give some kind of penalty for mismatching amount of values instead of simple divide?
127
67
  const missingCount = maxValues - possibleMatchValues;
128
68
  const misMatchCount = possibleMatchValues - matchingValues;
129
- debug(`\t missing: ${missingCount}`);
130
- debug(`\t mismatches: ${misMatchCount}`);
69
+ debug(` missing: ${missingCount}`);
70
+ debug(` mismatches: ${misMatchCount}`);
131
71
  const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);
132
72
  const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);
133
- debug(`\t points: penaltyForMissing: ${penaltyForMissing}`);
134
- debug(`\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);
73
+ debug(` points: penaltyForMissing: ${penaltyForMissing}`);
74
+ debug(` points: penaltyForMisMatch: ${penaltyForMisMatch}`);
135
75
  const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));
136
76
  debug(`Total points: ${points}`);
137
77
  return points;
138
78
  }
139
79
  });
140
- exports.default = _default;
141
- //# sourceMappingURL=language.js.map
80
+ //# sourceMappingURL=language.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"language.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","value008","get008Value","values041","get041Values","JSON","stringify","length","allValues","undefined","concat","uniqueSortedValues","Set","sort","value","get","code","slice","isLangCodeForALanguage","filter","ind2","map","subfields","flat","langCodePattern","test","compare","a","b","every","element","index","matchingValues","possibleMatchValues","maxValues","getMatchCounts","missingCount","misMatchCount","penaltyForMissing","penaltyForMisMatch","points","Number","toFixed","exports"],"sources":["../../../../src/match-detection/features/bib/language.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 createDebugLogger from 'debug';\nimport {getMatchCounts} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:language');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Language',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (!value008 && values041.length < 1) {\n debugData(`{$label} No actual values found`);\n return [];\n }\n\n const allValues = value008 === undefined ? values041 : values041.concat(value008);\n const uniqueSortedValues = [...new Set(allValues)].sort();\n\n return uniqueSortedValues;\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`${label} 008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`${label} 008 code: ${code}`);\n return isLangCodeForALanguage(code) ? code : undefined;\n }\n\n // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes\n\n function get041Values() {\n return record.get(/^041$/u)\n .filter(({ind2}) => ind2 === ' ')\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'a' || code === 'd')\n .filter(({value}) => value && isLangCodeForALanguage(value))\n .map(({value}) => value);\n }\n\n // Check if a string is a possible, validly formed language code for a single language\n // Currently accept also codes in capitals\n function isLangCodeForALanguage(code) {\n if (code.length !== 3) {\n debugData(`Code ${code} is not correct length (3) for a language code.`);\n return false;\n }\n if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {\n debugData(`Code ${code} is not code for a spesific language.`);\n return false;\n }\n const langCodePattern = /^[a-z][a-z][a-z]$/ui;\n if (!langCodePattern.test(code)) {\n debugData(`Code ${code} is not valid as a language code`);\n return false;\n }\n return true;\n }\n\n },\n // eslint-disable-next-line max-statements\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n if (a.length === b.length && a.every((element, index) => element === b[index])) {\n debugData(`All languages match`);\n return 0.1;\n }\n\n const {matchingValues, possibleMatchValues, maxValues} = getMatchCounts(a, b);\n\n if (matchingValues < 1) {\n debug(`Both have languages, but none of these match.`);\n return -1.0;\n }\n debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);\n // ignore non-matches if there is mismatching amount of values\n debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);\n //we give some kind of penalty for mismatching amount of values instead of simple divide?\n const missingCount = maxValues - possibleMatchValues;\n const misMatchCount = possibleMatchValues - matchingValues;\n debug(`\\t missing: ${missingCount}`);\n debug(`\\t mismatches: ${misMatchCount}`);\n\n const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);\n const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);\n debug(`\\t points: penaltyForMissing: ${penaltyForMissing}`);\n debug(`\\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);\n\n const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));\n debug(`Total points: ${points}`);\n\n return points;\n }\n});\n"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAuD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7BvD;AACA;AACA;AACA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B8C,aAAc,EAAC,CAAC;IAExC,MAAMC,iBAAiB,GAAG,IAAI,IAAIJ,SAAS,GAAGD,mBAAmB,CAAC;IAClE,MAAMM,kBAAkB,GAAG,IAAI,IAAIN,mBAAmB,GAAGD,cAAc,CAAC;IACxEzC,KAAK,CAAE,iCAAgC+C,iBAAkB,EAAC,CAAC;IAC3D/C,KAAK,CAAE,kCAAiCgD,kBAAmB,EAAC,CAAC;IAE7D,MAAMC,MAAM,GAAGC,MAAM,CAACA,MAAM,CAAC,GAAG,GAAGF,kBAAkB,GAAGD,iBAAiB,CAAC,CAACI,OAAO,CAAC,CAAC,CAAC,CAAC;IACtFnD,KAAK,CAAE,iBAAgBiD,MAAO,EAAC,CAAC;IAEhC,OAAOA,MAAM;EACf;AACF,CAAC,CAAC;AAAAG,OAAA,CAAArD,OAAA,GAAAK,QAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/match-detection/features/bib/language.js"],
4
+ "sourcesContent": ["\nimport createDebugLogger from 'debug';\nimport {getMatchCounts} from '../../../matching-utils.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:language');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Language',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`${label}: 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (!value008 && values041.length < 1) {\n debugData(`${label}: No actual values found`);\n return [];\n }\n\n const allValues = value008 === undefined ? values041 : values041.concat(value008);\n const uniqueSortedValues = [...new Set(allValues)].sort();\n\n return uniqueSortedValues;\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`${label}: 008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`${label}: 008 code: ${code}`);\n return isLangCodeForALanguage(code) ? code : undefined;\n }\n\n // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes\n\n function get041Values() {\n return record.get(/^041$/u)\n .filter(({ind2}) => ind2 === ' ')\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'a' || code === 'd')\n .filter(({value}) => value && isLangCodeForALanguage(value))\n .map(({value}) => value);\n }\n\n // Check if a string is a possible, validly formed language code for a single language\n // Currently accept also codes in capitals\n function isLangCodeForALanguage(code) {\n if (code.length !== 3) {\n debugData(`Code ${code} is not correct length (3) for a language code.`);\n return false;\n }\n if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {\n debugData(`Code ${code} is not code for a spesific language.`);\n return false;\n }\n const langCodePattern = /^[a-z][a-z][a-z]$/ui;\n if (!langCodePattern.test(code)) {\n debugData(`Code ${code} is not valid as a language code`);\n return false;\n }\n return true;\n }\n\n },\n // eslint-disable-next-line max-statements\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n if (a.length === b.length && a.every((element, index) => element === b[index])) {\n debugData(`All languages match`);\n return 0.1;\n }\n\n const {matchingValues, possibleMatchValues, maxValues} = getMatchCounts(a, b);\n\n if (matchingValues < 1) {\n debug(`Both have languages, but none of these match.`);\n return -1.0;\n }\n debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);\n // ignore non-matches if there is mismatching amount of values\n debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);\n //we give some kind of penalty for mismatching amount of values instead of simple divide?\n const missingCount = maxValues - possibleMatchValues;\n const misMatchCount = possibleMatchValues - matchingValues;\n debug(`\\t missing: ${missingCount}`);\n debug(`\\t mismatches: ${misMatchCount}`);\n\n const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);\n const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);\n debug(`\\t points: penaltyForMissing: ${penaltyForMissing}`);\n debug(`\\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);\n\n const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));\n debug(`Total points: ${points}`);\n\n return points;\n }\n});\n"],
5
+ "mappings": "AACA,OAAO,uBAAuB;AAC9B,SAAQ,sBAAqB;AAE7B,MAAM,QAAQ,kBAAkB,qEAAqE;AACrG,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,eAAe,OAAO;AAAA,EACpB,MAAM;AAAA,EACN,SAAS,CAAC,EAAC,QAAQ,eAAc,MAAM;AACrC,UAAM,QAAQ,kBAAkB,eAAe,QAAQ,eAAe,QAAQ;AAE9E,UAAM,WAAW,YAAY;AAC7B,UAAM,YAAY,aAAa;AAC/B,cAAU,GAAG,KAAK,UAAU,KAAK,UAAU,QAAQ,CAAC,UAAU,KAAK,UAAU,SAAS,CAAC,EAAE;AAEzF,QAAI,CAAC,YAAY,UAAU,SAAS,GAAG;AACrC,gBAAU,GAAG,KAAK,0BAA0B;AAC5C,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,YAAY,aAAa,SAAY,YAAY,UAAU,OAAO,QAAQ;AAChF,UAAM,qBAAqB,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC,EAAE,KAAK;AAExD,WAAO;AAEP,aAAS,cAAc;AACrB,YAAM,QAAQ,OAAO,IAAI,QAAQ,IAAI,CAAC,GAAG,SAAS;AAClD,gBAAU,GAAG,KAAK,gBAAgB,KAAK,EAAE;AAEzC,UAAI,CAAC,OAAO;AACV,eAAO;AAAA,MACT;AAEA,YAAM,OAAO,MAAM,MAAM,IAAI,EAAE;AAC/B,gBAAU,GAAG,KAAK,eAAe,IAAI,EAAE;AACvC,aAAO,uBAAuB,IAAI,IAAI,OAAO;AAAA,IAC/C;AAIA,aAAS,eAAe;AACtB,aAAO,OAAO,IAAI,QAAQ,EACvB,OAAO,CAAC,EAAC,KAAI,MAAM,SAAS,GAAG,EAC/B,IAAI,CAAC,EAAC,UAAS,MAAM,SA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B,sBAAsB;AAC5C,UAAM,cAAe,YAAY,EAAE;AACnC,UAAM,iBAAkB,aAAa,EAAE;AAEvC,UAAM,oBAAoB,QAAQ,YAAY;AAC9C,UAAM,qBAAqB,QAAQ,sBAAsB;AACzD,UAAM,gCAAiC,iBAAiB,EAAE;AAC1D,UAAM,iCAAkC,kBAAkB,EAAE;AAE5D,UAAM,SAAS,OAAO,OAAO,MAAM,qBAAqB,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACrF,UAAM,iBAAiB,MAAM,EAAE;AAE/B,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -1,77 +1,26 @@
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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /* eslint-disable max-statements */
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-2022 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
-
38
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:media-type');
39
- const debugData = debug.extend('data');
40
- var _default = () => ({
41
- name: 'Media type',
42
- extract: ({
43
- record,
44
- recordExternal
45
- }) => {
46
- const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';
1
+ import createDebugLogger from "debug";
2
+ const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:features:media-type");
3
+ const debugData = debug.extend("data");
4
+ export default () => ({
5
+ name: "Media type",
6
+ extract: ({ record, recordExternal }) => {
7
+ const label = recordExternal && recordExternal.label ? recordExternal.label : "record";
47
8
  debugData(`Record (${label}): ${JSON.stringify(record)}`);
48
9
  debugData(`RecordExternal: ${JSON.stringify(recordExternal)}`);
49
10
  const values337 = get337Values();
50
- debug(`${label} 337 $b values: ${JSON.stringify(values337)}`);
11
+ debug(`${label}: 337 $b values: ${JSON.stringify(values337)}`);
51
12
  return values337;
52
13
  function get337Values() {
53
- return record.get(/^337$/u).filter(f => f.subfields.some(subfield => subfield.code === '2' && subfield.value === 'rdamedia')).map(({
54
- subfields
55
- }) => subfields).flat().filter(({
56
- code
57
- }) => code === 'b').map(({
58
- value
59
- }) => value);
14
+ return record.get(/^337$/u).filter((f) => f.subfields.some((subfield) => subfield.code === "2" && subfield.value === "rdamedia")).map(({ subfields }) => subfields).flat().filter(({ code }) => code === "b").map(({ value }) => value);
60
15
  }
61
16
  },
62
17
  compare: (a, b) => {
63
18
  debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
64
-
65
- // Should we give extra good points if all mediaTypes match?
66
- // Should we give partial points for partially matching mediaTypes?
67
- // Should we check whether recordType is 'mixedMaterials'
68
- // Should we okay typical cases of not totally matching mediaTypes? What would these be?
69
-
70
- if (a.every(elem => b.includes(elem))) {
19
+ if (a.every((elem) => b.includes(elem))) {
71
20
  debug(`All mediaTypes from A are in B`);
72
21
  return 1;
73
22
  }
74
- if (b.every(elem => a.includes(elem))) {
23
+ if (b.every((elem) => a.includes(elem))) {
75
24
  debug(`All mediaTypes from B are in A`);
76
25
  return 1;
77
26
  }
@@ -79,5 +28,4 @@ var _default = () => ({
79
28
  return -1;
80
29
  }
81
30
  });
82
- exports.default = _default;
83
- //# sourceMappingURL=media-type.js.map
31
+ //# sourceMappingURL=media-type.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"media-type.js","names":["_debug","_interopRequireDefault","require","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","JSON","stringify","values337","get337Values","get","filter","f","subfields","some","subfield","code","value","map","flat","compare","a","b","every","elem","includes","exports"],"sources":["../../../../src/match-detection/features/bib/media-type.js"],"sourcesContent":["/* eslint-disable max-statements */\n/**\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-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:media-type');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Media type',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n debugData(`Record (${label}): ${JSON.stringify(record)}`);\n debugData(`RecordExternal: ${JSON.stringify(recordExternal)}`);\n const values337 = get337Values();\n debug(`${label} 337 $b values: ${JSON.stringify(values337)}`);\n\n return values337;\n\n function get337Values() {\n return record.get(/^337$/u)\n .filter(f => f.subfields.some((subfield) => subfield.code === '2' && subfield.value === 'rdamedia'))\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'b')\n .map(({value}) => value);\n }\n },\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n // Should we give extra good points if all mediaTypes match?\n // Should we give partial points for partially matching mediaTypes?\n // Should we check whether recordType is 'mixedMaterials'\n // Should we okay typical cases of not totally matching mediaTypes? What would these be?\n\n if (a.every(elem => b.includes(elem))) {\n debug(`All mediaTypes from A are in B`);\n return 1;\n }\n\n if (b.every(elem => a.includes(elem))) {\n debug(`All mediaTypes from B are in A`);\n return 1;\n }\n\n debug(`Mismatch in mediaTypes between A and B`);\n return -1;\n\n }\n});\n"],"mappings":";;;;;;AA6BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAE,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;AACA;;AAIA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,uEAAuE,CAAC;AACxG,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAAC,IAAAC,QAAA,GAExBA,CAAA,MAAO;EACpBC,IAAI,EAAE,YAAY;EAClBC,OAAO,EAAEA,CAAC;IAACC,MAAM;IAAEC;EAAc,CAAC,KAAK;IACrC,MAAMC,KAAK,GAAGD,cAAc,IAAIA,cAAc,CAACC,KAAK,GAAGD,cAAc,CAACC,KAAK,GAAG,QAAQ;IACtFP,SAAS,CAAE,WAAUO,KAAM,MAAKC,IAAI,CAACC,SAAS,CAACJ,MAAM,CAAE,EAAC,CAAC;IACzDL,SAAS,CAAE,mBAAkBQ,I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AC;IAC/C,OAAO,CAAC,CAAC;EAEX;AACF,CAAC,CAAC;AAAA8B,OAAA,CAAA/B,OAAA,GAAAK,QAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/match-detection/features/bib/media-type.js"],
4
+ "sourcesContent": ["/* eslint-disable max-statements */\n\n\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:media-type');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Media type',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n debugData(`Record (${label}): ${JSON.stringify(record)}`);\n debugData(`RecordExternal: ${JSON.stringify(recordExternal)}`);\n const values337 = get337Values();\n debug(`${label}: 337 $b values: ${JSON.stringify(values337)}`);\n\n return values337;\n\n function get337Values() {\n return record.get(/^337$/u)\n .filter(f => f.subfields.some((subfield) => subfield.code === '2' && subfield.value === 'rdamedia'))\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'b')\n .map(({value}) => value);\n }\n },\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n // Should we give extra good points if all mediaTypes match?\n // Should we give partial points for partially matching mediaTypes?\n // Should we check whether recordType is 'mixedMaterials'\n // Should we okay typical cases of not totally matching mediaTypes? What would these be?\n\n if (a.every(elem => b.includes(elem))) {\n debug(`All mediaTypes from A are in B`);\n return 1;\n }\n\n if (b.every(elem => a.includes(elem))) {\n debug(`All mediaTypes from B are in A`);\n return 1;\n }\n\n debug(`Mismatch in mediaTypes between A and B`);\n return -1;\n\n }\n});\n"],
5
+ "mappings": "AAGA,OAAO,uBAAuB;AAE9B,MAAM,QAAQ,kBAAkB,uEAAuE;AACvG,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,eAAe,OAAO;AAAA,EACpB,MAAM;AAAA,EACN,SAAS,CAAC,EAAC,QAAQ,eAAc,MAAM;AACrC,UAAM,QAAQ,kBAAkB,eAAe,QAAQ,eAAe,QAAQ;AAC9E,cAAU,WAAW,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,EAAE;AACxD,cAAU,mBAAmB,KAAK,UAAU,cAAc,CAAC,EAAE;AAC7D,UAAM,YAAY,aAAa;AAC/B,UAAM,GAAG,KAAK,oBAAoB,KAAK,UAAU,SAAS,CAAC,EAAE;AAE7D,WAAO;AAEP,aAAS,eAAe;AACtB,aAAO,OAAO,IAAI,QAAQ,EACvB,OAAO,OAAK,EAAE,UAAU,KAAK,CAAC,aAAa,SAAS,SAAS,OAAO,SAAS,UAAU,UAAU,CAAC,EAClG,IAAI,CAAC,EAAC,UAAS,MAAM,SAAS,EAC9B,KAAK,EACL,OAAO,CAAC,EAAC,KAAI,MAAM,SAAS,GAAG,EAC/B,IAAI,CAAC,EAAC,MAAK,MAAM,KAAK;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,SAAS,CAAC,GAAG,MAAM;AACjB,cAAU,aAAa,KAAK,UAAU,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,EAAE;AAOnE,QAAI,EAAE,MAAM,UAAQ,EAAE,SAAS,IAAI,CAAC,GAAG;AACrC,YAAM,gCAAgC;AACtC,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,MAAM,UAAQ,EAAE,SAAS,IAAI,CAAC,GAAG;AACrC,YAAM,gCAAgC;AACtC,aAAO;AAAA,IACT;AAEA,UAAM,wCAAwC;AAC9C,WAAO;AAAA,EAET;AACF;",
6
+ "names": []
7
+ }
@@ -1,48 +1,6 @@
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
- };
1
+ import createInterface from "./melinda-identifier-factory.js";
2
+ export default () => {
3
+ const { extract, compare } = createInterface();
4
+ return { extract, compare, name: "melinda-id" };
46
5
  };
47
- exports.default = _default;
48
- //# sourceMappingURL=melinda-id.js.map
6
+ //# sourceMappingURL=melinda-id.js.map
@@ -1 +1,7 @@
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
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/match-detection/features/bib/melinda-id.js"],
4
+ "sourcesContent": ["\nimport createInterface from './melinda-identifier-factory.js';\n\nexport default () => {\n const {extract, compare} = createInterface();\n return {extract, compare, name: 'melinda-id'};\n};\n"],
5
+ "mappings": "AACA,OAAO,qBAAqB;AAE5B,eAAe,MAAM;AACnB,QAAM,EAAC,SAAS,QAAO,IAAI,gBAAgB;AAC3C,SAAO,EAAC,SAAS,SAAS,MAAM,aAAY;AAC9C;",
6
+ "names": []
7
+ }
@@ -1,83 +1,33 @@
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) {
1
+ import createDebugLogger from "debug";
2
+ import { getMelindaIdsF035 } from "../../../matching-utils.js";
3
+ export default () => {
4
+ const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:features/bib/melinda-id");
5
+ const debugData = debug.extend("data");
6
+ return { extract, compare };
7
+ function extract({ record, recordExternal }) {
8
+ const isMelindaRecord = record.get("003").some((f003) => f003.value === "FI-MELINDA");
9
+ const [f001] = record.get("001").map((field) => field.value);
10
+ const f035MelindaIds = getMelindaIdsF035(record);
11
+ if (isMelindaRecord === void 0 && f001 === void 0 && f035MelindaIds.length < 1) {
58
12
  debug(`${recordExternal.label} No Melinda-IDs found`);
59
13
  return {};
60
14
  }
61
- return {
62
- isMelindaRecord,
63
- f001,
64
- f035MelindaIds
65
- };
15
+ return { isMelindaRecord, f001, f035MelindaIds };
66
16
  }
67
17
  function compare(a, b) {
68
18
  if (a.isMelindaRecord && b.isMelindaRecord && a.f001 === b.f001) {
69
19
  debugData(`Melinda record's A f001 ${a.f001} matches Melinda record's B f001 ${a.f001}`);
70
20
  return 1;
71
21
  }
72
- if (a.isMelindaRecord && typeof b.f035MelindaIds !== 'undefined' && b.f035MelindaIds.some(id => id === a.f001)) {
22
+ if (a.isMelindaRecord && typeof b.f035MelindaIds !== "undefined" && b.f035MelindaIds.some((id) => id === a.f001)) {
73
23
  debugData(`Melinda record's A f001 ${a.f001} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
74
24
  return 1;
75
25
  }
76
- if (b.isMelindaRecord && typeof a.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(id => id === b.f001)) {
26
+ if (b.isMelindaRecord && typeof a.f035MelindaIds !== "undefined" && a.f035MelindaIds.some((id) => id === b.f001)) {
77
27
  debugData(`Melinda record's B f001 ${b.f001} matches record A f035 ${JSON.stringify(a.f035MelindaIds)}`);
78
28
  return 1;
79
29
  }
80
- if (typeof a.f035MelindaIds !== 'undefined' && typeof b.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {
30
+ if (typeof a.f035MelindaIds !== "undefined" && typeof b.f035MelindaIds !== "undefined" && a.f035MelindaIds.some((idA) => b.f035MelindaIds.some((idB) => idB === idA))) {
81
31
  debugData(`Record A f035 ${JSON.stringify(a.f035MelindaIds)} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
82
32
  return 1;
83
33
  }
@@ -85,5 +35,4 @@ var _default = () => {
85
35
  return 0;
86
36
  }
87
37
  };
88
- exports.default = _default;
89
- //# sourceMappingURL=melinda-identifier-factory.js.map
38
+ //# sourceMappingURL=melinda-identifier-factory.js.map
@@ -1 +1,7 @@
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;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,OAAO,CAAC;IACV;IACAhB,KAAK,CAAE,0BAAyB,CAAC;IACjC,OAAO,CAAC;EACV;AACF,CAAC;AAAA4B,OAAA,CAAA9B,OAAA,GAAAC,QAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/match-detection/features/bib/melinda-identifier-factory.js"],
4
+ "sourcesContent": ["\nimport createDebugLogger from 'debug';\nimport {getMelindaIdsF035} from '../../../matching-utils.js';\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"],
5
+ "mappings": "AACA,OAAO,uBAAuB;AAC9B,SAAQ,yBAAwB;AAShC,eAAe,MAAM;AAEnB,QAAM,QAAQ,kBAAkB,2EAA2E;AAC3G,QAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAO,EAAC,SAAS,QAAO;AAExB,WAAS,QAAQ,EAAC,QAAQ,eAAc,GAAG;AAEzC,UAAM,kBAAkB,OAAO,IAAI,KAAK,EAAE,KAAK,UAAQ,KAAK,UAAU,YAAY;AAClF,UAAM,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,EAAE,IAAI,WAAS,MAAM,KAAK;AACzD,UAAM,iBAAiB,kBAAkB,MAAM;AAE/C,QACE,oBAAoB,UACpB,SAAS,UACT,eAAe,SAAS,GAAG;AAE3B,YAAM,GAAG,eAAe,KAAK,uBAAuB;AACpD,aAAO,CAAC;AAAA,IACV;AAEA,WAAO,EAAC,iBAAiB,MAAM,eAAc;AAAA,EAE/C;AAEA,WAAS,QAAQ,GAAG,GAAG;AAErB,QAAI,EAAE,mBAAmB,EAAE,mBACzB,EAAE,SAAS,EAAE,MAAM;AACnB,gBAAU,2BAA2B,EAAE,IAAI,oCAAoC,EAAE,IAAI,EAAE;AACvF,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,mBAAmB,OAAO,EAAE,mBAAmB,eACnD,EAAE,eAAe,KAAK,QAAM,OAAO,EAAE,IAAI,GAAG;AAC5C,gBAAU,2BAA2B,EAAE,IAAI,0BAA0B,KAAK,UAAU,EAAE,cAAc,CAAC,EAAE;AACvG,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,mBAAmB,OAAO,EAAE,mBAAmB,eACnD,EAAE,eAAe,KAAK,QAAM,OAAO,EAAE,IAAI,GAAG;AAC5C,gBAAU,2BAA2B,EAAE,IAAI,0BAA0B,KAAK,UAAU,EAAE,cAAc,CAAC,EAAE;AACvG,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,EAAE,mBAAmB,eAAe,OAAO,EAAE,mBAAmB,eACzE,EAAE,eAAe,KAAK,SAAO,EAAE,eAAe,KAAK,SAAO,QAAQ,GAAG,CAAC,GAAG;AACzE,gBAAU,iBAAiB,KAAK,UAAU,EAAE,cAAc,CAAC,0BAA0B,KAAK,UAAU,EAAE,cAAc,CAAC,EAAE;AACvH,aAAO;AAAA,IACT;AACA,UAAM,0BAA0B;AAChC,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -1,52 +1,6 @@
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
- };
1
+ import createInterface from "./standard-identifier-factory.js";
2
+ export default () => {
3
+ const { extract, compare } = createInterface({ pattern: /^024$/u, subfieldCodes: ["a", "z"] });
4
+ return { extract, compare, name: "Other standard identifier" };
50
5
  };
51
- exports.default = _default;
52
- //# sourceMappingURL=other-standard-identifier.js.map
6
+ //# sourceMappingURL=other-standard-identifier.js.map
@@ -1 +1,7 @@
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
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/match-detection/features/bib/other-standard-identifier.js"],
4
+ "sourcesContent": ["\nimport createInterface from './standard-identifier-factory.js';\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"],
5
+ "mappings": "AACA,OAAO,qBAAqB;AAI5B,eAAe,MAAM;AACnB,QAAM,EAAC,SAAS,QAAO,IAAI,gBAAgB,EAAC,SAAS,UAAU,eAAe,CAAC,KAAK,GAAG,EAAC,CAAC;AACzF,SAAO,EAAC,SAAS,SAAS,MAAM,4BAA2B;AAC7D;",
6
+ "names": []
7
+ }