@natlibfi/melinda-record-matching 2.2.1-alpha.1 → 2.2.1-alpha.3

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 (66) hide show
  1. package/dist/candidate-search/candidate-search-utils.js +55 -0
  2. package/dist/candidate-search/candidate-search-utils.js.map +1 -0
  3. package/dist/candidate-search/index.js +258 -0
  4. package/dist/candidate-search/index.js.map +1 -0
  5. package/dist/candidate-search/index.spec.js +148 -0
  6. package/dist/candidate-search/index.spec.js.map +1 -0
  7. package/dist/candidate-search/query-list/bib.js +230 -0
  8. package/dist/candidate-search/query-list/bib.js.map +1 -0
  9. package/dist/candidate-search/query-list/bib.spec.js +63 -0
  10. package/dist/candidate-search/query-list/bib.spec.js.map +1 -0
  11. package/dist/candidate-search/query-list/index.js +61 -0
  12. package/dist/candidate-search/query-list/index.js.map +1 -0
  13. package/dist/index.js +559 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/index.spec.js +125 -0
  16. package/dist/index.spec.js.map +1 -0
  17. package/dist/match-detection/features/bib/all-source-ids.js +116 -0
  18. package/dist/match-detection/features/bib/all-source-ids.js.map +1 -0
  19. package/dist/match-detection/features/bib/authors.js +107 -0
  20. package/dist/match-detection/features/bib/authors.js.map +1 -0
  21. package/dist/match-detection/features/bib/bibliographic-level.js +39 -0
  22. package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -0
  23. package/dist/match-detection/features/bib/host-component.js +39 -0
  24. package/dist/match-detection/features/bib/host-component.js.map +1 -0
  25. package/dist/match-detection/features/bib/index.js +91 -0
  26. package/dist/match-detection/features/bib/index.js.map +1 -0
  27. package/dist/match-detection/features/bib/index.spec.js +87 -0
  28. package/dist/match-detection/features/bib/index.spec.js.map +1 -0
  29. package/dist/match-detection/features/bib/isbn.js +50 -0
  30. package/dist/match-detection/features/bib/isbn.js.map +1 -0
  31. package/dist/match-detection/features/bib/issn.js +50 -0
  32. package/dist/match-detection/features/bib/issn.js.map +1 -0
  33. package/dist/match-detection/features/bib/language.js +98 -0
  34. package/dist/match-detection/features/bib/language.js.map +1 -0
  35. package/dist/match-detection/features/bib/melinda-id.js +47 -0
  36. package/dist/match-detection/features/bib/melinda-id.js.map +1 -0
  37. package/dist/match-detection/features/bib/melinda-identifier-factory.js +88 -0
  38. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -0
  39. package/dist/match-detection/features/bib/other-standard-identifier.js +50 -0
  40. package/dist/match-detection/features/bib/other-standard-identifier.js.map +1 -0
  41. package/dist/match-detection/features/bib/publication-time.js +47 -0
  42. package/dist/match-detection/features/bib/publication-time.js.map +1 -0
  43. package/dist/match-detection/features/bib/record-type.js +41 -0
  44. package/dist/match-detection/features/bib/record-type.js.map +1 -0
  45. package/dist/match-detection/features/bib/standard-identifier-factory.js +112 -0
  46. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -0
  47. package/dist/match-detection/features/bib/title.js +78 -0
  48. package/dist/match-detection/features/bib/title.js.map +1 -0
  49. package/dist/match-detection/features/index.js +11 -0
  50. package/dist/match-detection/features/index.js.map +1 -0
  51. package/dist/match-detection/index.js +162 -0
  52. package/dist/match-detection/index.js.map +1 -0
  53. package/dist/match-detection/index.spec.js +88 -0
  54. package/dist/match-detection/index.spec.js.map +1 -0
  55. package/dist/matching-utils.js +95 -0
  56. package/dist/matching-utils.js.map +1 -0
  57. package/package.json +18 -17
  58. package/src/candidate-search/query-list/bib.js +19 -18
  59. package/src/candidate-search/query-list/index.js +1 -1
  60. package/src/match-detection/features/bib/authors.js +5 -2
  61. package/src/match-detection/features/bib/language.js +2 -2
  62. package/src/match-detection/features/bib/publication-time.js +8 -3
  63. package/src/match-detection/features/bib/record-type.js +2 -0
  64. package/src/match-detection/features/bib/standard-identifier-factory.js +4 -3
  65. package/src/match-detection/features/bib/title.js +6 -4
  66. package/src/matching-utils.js +13 -4
@@ -0,0 +1,112 @@
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-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:standard-identifiers');
39
+ const debugData = debug.extend('data');
40
+ var _default = ({
41
+ pattern,
42
+ subfieldCodes
43
+ }) => {
44
+ return {
45
+ extract,
46
+ compare
47
+ };
48
+ function extract(record) {
49
+ const [field] = record.get(pattern);
50
+ if (field) {
51
+ return field.subfields.filter(({
52
+ code
53
+ }) => subfieldCodes.includes(code)).map(({
54
+ code,
55
+ value
56
+ }) => ({
57
+ code,
58
+ value: (0, _matchingUtils.testStringOrNumber)(value) ? String(value).replace(/-/ug, '') : ''
59
+ })).filter(value => value);
60
+ }
61
+ return [];
62
+ }
63
+ function compare(a, b) {
64
+ if (a.length === 0 || b.length === 0) {
65
+ debugData(`No standardidentifiers to compare`);
66
+ return 0;
67
+ }
68
+ if (bothHaveValidIdentifiers()) {
69
+ const {
70
+ maxValues,
71
+ matchingValues
72
+ } = getValueCount(true);
73
+ return matchingValues / maxValues * 0.75;
74
+ }
75
+ const {
76
+ maxValues,
77
+ matchingValues
78
+ } = getValueCount();
79
+ return matchingValues / maxValues * 0.2;
80
+ function bothHaveValidIdentifiers() {
81
+ const aValues = a.filter(({
82
+ code
83
+ }) => code === 'a');
84
+ const bValues = a.filter(({
85
+ code
86
+ }) => code === 'a');
87
+ return aValues.length > 0 && bValues.length > 0;
88
+ }
89
+ function getValueCount(validOnly = false) {
90
+ const aValues = getIdentifiers(a);
91
+ const bValues = getIdentifiers(b);
92
+ return {
93
+ maxValues: aValues.length > bValues.length ? aValues.length : bValues.length,
94
+ matchingValues: aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length
95
+ };
96
+ function getIdentifiers(values) {
97
+ if (validOnly) {
98
+ return values.filter(({
99
+ code
100
+ }) => code === 'a').map(({
101
+ value
102
+ }) => value);
103
+ }
104
+ return values.map(({
105
+ value
106
+ }) => value);
107
+ }
108
+ }
109
+ }
110
+ };
111
+ exports.default = _default;
112
+ //# sourceMappingURL=standard-identifier-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-identifier-factory.js","names":["debug","createDebugLogger","debugData","extend","pattern","subfieldCodes","extract","compare","record","field","get","subfields","filter","code","includes","map","value","testStringOrNumber","String","replace","a","b","length","bothHaveValidIdentifiers","maxValues","matchingValues","getValueCount","aValues","bValues","validOnly","getIdentifiers","aValue","some","bValue","values"],"sources":["../../../../src/match-detection/features/bib/standard-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-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';\nimport {testStringOrNumber} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers');\nconst debugData = debug.extend('data');\n\nexport default ({pattern, subfieldCodes}) => {\n return {extract, compare};\n\n function extract(record) {\n const [field] = record.get(pattern);\n\n if (field) {\n return field.subfields\n .filter(({code}) => subfieldCodes.includes(code))\n .map(({code, value}) => ({code, value: testStringOrNumber(value) ? String(value).replace(/-/ug, '') : ''}))\n .filter(value => value);\n }\n\n return [];\n }\n\n function compare(a, b) {\n if (a.length === 0 || b.length === 0) {\n debugData(`No standardidentifiers to compare`);\n return 0;\n }\n\n if (bothHaveValidIdentifiers()) {\n const {maxValues, matchingValues} = getValueCount(true);\n return matchingValues / maxValues * 0.75;\n }\n\n const {maxValues, matchingValues} = getValueCount();\n return matchingValues / maxValues * 0.2;\n\n function bothHaveValidIdentifiers() {\n const aValues = a.filter(({code}) => code === 'a');\n const bValues = a.filter(({code}) => code === 'a');\n return aValues.length > 0 && bValues.length > 0;\n }\n\n function getValueCount(validOnly = false) {\n const aValues = getIdentifiers(a);\n const bValues = getIdentifiers(b);\n\n return {\n maxValues: aValues.length > bValues.length ? aValues.length : bValues.length,\n matchingValues: aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length\n };\n\n function getIdentifiers(values) {\n if (validOnly) {\n return values\n .filter(({code}) => code === 'a')\n .map(({value}) => value);\n }\n\n return values.map(({value}) => value);\n }\n }\n }\n};\n"],"mappings":";;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AAC;MACvC;IACF;EACF;AACF,CAAC;AAAA"}
@@ -0,0 +1,78 @@
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 _natural = require("natural");
9
+ var _matchingUtils = require("../../../matching-utils");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ /**
12
+ *
13
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
14
+ *
15
+ * Melinda record matching modules for Javascript
16
+ *
17
+ * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
18
+ *
19
+ * This file is part of melinda-record-matching-js
20
+ *
21
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
22
+ * it under the terms of the GNU Lesser General Public License as
23
+ * published by the Free Software Foundation, either version 3 of the
24
+ * License, or (at your option) any later version.
25
+ *
26
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
27
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
+ * GNU Lesser General Public License for more details.
30
+ *
31
+ * You should have received a copy of the GNU Affero General Public License
32
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
+ *
34
+ * @licend The above is the entire license notice
35
+ * for the JavaScript code in this file.
36
+ *
37
+ */var _default = ({
38
+ treshold = 10
39
+ } = {}) => ({
40
+ name: 'Title',
41
+ extract: record => {
42
+ const title = getTitle();
43
+ if ((0, _matchingUtils.testStringOrNumber)(title)) {
44
+ return [String(title).replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase()];
45
+ }
46
+ return [];
47
+ function getTitle() {
48
+ const [field] = record.get(/^245$/u);
49
+ if (field) {
50
+ return field.subfields.filter(({
51
+ code
52
+ }) => ['a', 'b'].includes(code)).map(({
53
+ value
54
+ }) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').join('');
55
+ }
56
+ return false;
57
+ }
58
+ },
59
+ compare: (a, b) => {
60
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/title');
61
+ const distance = (0, _natural.LevenshteinDistance)(a[0], b[0]);
62
+ if (distance === 0) {
63
+ return 0.5;
64
+ }
65
+ const maxLength = getMaxLength();
66
+ const percentage = distance / maxLength * 100;
67
+ debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);
68
+ if (percentage <= treshold) {
69
+ return 0.3;
70
+ }
71
+ return -0.5;
72
+ function getMaxLength() {
73
+ return a[0].length > b[0].length ? a[0].length : b[0].length;
74
+ }
75
+ }
76
+ });
77
+ exports.default = _default;
78
+ //# sourceMappingURL=title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title.js","names":["treshold","name","extract","record","title","getTitle","testStringOrNumber","String","replace","toLowerCase","field","get","subfields","filter","code","includes","map","value","join","compare","a","b","debug","createDebugLogger","distance","leven","maxLength","getMaxLength","percentage","length"],"sources":["../../../../src/match-detection/features/bib/title.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-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';\nimport {LevenshteinDistance as leven} from 'natural';\nimport {testStringOrNumber} from '../../../matching-utils';\n\nexport default ({treshold = 10} = {}) => ({\n name: 'Title',\n extract: record => {\n const title = getTitle();\n\n if (testStringOrNumber(title)) {\n return [String(title).replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase()];\n }\n\n return [];\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n return field.subfields\n .filter(({code}) => ['a', 'b'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .join('');\n }\n return false;\n }\n },\n compare: (a, b) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/title');\n const distance = leven(a[0], b[0]);\n\n if (distance === 0) {\n return 0.5;\n }\n\n const maxLength = getMaxLength();\n const percentage = distance / maxLength * 100;\n\n debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);\n\n if (percentage <= treshold) {\n return 0.3;\n }\n\n return -0.5;\n\n function getMaxLength() {\n return a[0].length > b[0].length ? a[0].length : b[0].length;\n }\n\n }\n});\n"],"mappings":";;;;;;AA4BA;AACA;AACA;AAA2D;AA9B3D;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,EA1BA,eAgCe,CAAC;EAACA,QAAQ,GAAG;AAAE,CAAC,GAAG,CAAC,CAAC,MAAM;EACxCC,IAAI,EAAE,OAAO;EACbC,OAAO,EAAEC,MAAM,IAAI;IACjB,MAAMC,KAAK,GAAGC,QAAQ,EAAE;IAExB,IAAI,IAAAC,iCAAkB,EAACF,KAAK,CAAC,EAAE;MAC7B,OAAO,CAACG,MAAM,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAACC,WAAW,EAAE,CAAC;IAC/E;IAEA,OAAO,EAAE;IAET,SAASJ,QAAQ,GAAG;MAClB,MAAM,CAACK,KAAK,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CAAC;AAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.bib = void 0;
7
+ var bib = _interopRequireWildcard(require("./bib"));
8
+ exports.bib = bib;
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/match-detection/features/index.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 * as bib from './bib';\nexport {bib};\n"],"mappings":";;;;;;AA4BA;AAA6B;AAAA;AAAA"}
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.features = exports.default = void 0;
7
+ var _debug = _interopRequireDefault(require("debug"));
8
+ var features = _interopRequireWildcard(require("./features"));
9
+ exports.features = features;
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ /* eslint-disable no-console */
14
+ /**
15
+ *
16
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
17
+ *
18
+ * Melinda record matching modules for Javascript
19
+ *
20
+ * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
21
+ *
22
+ * This file is part of melinda-record-matching-js
23
+ *
24
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
25
+ * it under the terms of the GNU Lesser General Public License as
26
+ * published by the Free Software Foundation, either version 3 of the
27
+ * License, or (at your option) any later version.
28
+ *
29
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
30
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ * GNU Lesser General Public License for more details.
33
+ *
34
+ * You should have received a copy of the GNU Affero General Public License
35
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
36
+ *
37
+ * @licend The above is the entire license notice
38
+ * for the JavaScript code in this file.
39
+ *
40
+ */
41
+ var _default = ({
42
+ strategy,
43
+ treshold = 0.9
44
+ }, returnStrategy = false) => (recordA, recordB) => {
45
+ const minProbabilityQuantifier = 0.5;
46
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection');
47
+ const debugData = debug.extend('data');
48
+ debugData(`Strategy: ${JSON.stringify(strategy)}`);
49
+ debugData(`Treshold: ${JSON.stringify(treshold)}`);
50
+ debugData(`ReturnStrategy: ${JSON.stringify(returnStrategy)}`);
51
+ const featuresA = extractFeatures(recordA);
52
+ debug(`We got an array of records: ${Array.isArray(recordB)}`);
53
+ const recordsB = Array.isArray(recordB) ? recordB : [recordB];
54
+ const detectionResults = recordsB.map(record => actualDetection(featuresA, record));
55
+ return Array.isArray(recordB) ? detectionResults : detectionResults[0];
56
+ function actualDetection(featuresA, record) {
57
+ const featuresB = extractFeatures(record);
58
+ debugData(`Features (a): ${JSON.stringify(featuresA)}`);
59
+ debugData(`Features (b): ${JSON.stringify(featuresB)}`);
60
+ const featurePairs = generateFeaturePairs(featuresA, featuresB);
61
+ const similarityVector = generateSimilarityVector(featurePairs);
62
+ if (similarityVector.some(v => v >= minProbabilityQuantifier)) {
63
+ const probability = calculateprobability(similarityVector);
64
+ debug(`probability: ${probability} (Treshold: ${treshold})`);
65
+ return returnResult({
66
+ match: probability >= treshold,
67
+ probability
68
+ });
69
+ }
70
+ debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);
71
+ return returnResult({
72
+ match: false,
73
+ probability: 0.0
74
+ });
75
+ }
76
+ function extractFeatures(record) {
77
+ return strategy.reduce((acc, {
78
+ name,
79
+ extract
80
+ }) => acc.concat({
81
+ name,
82
+ value: extract(record)
83
+ }), []);
84
+ }
85
+ function returnResult(result) {
86
+ if (returnStrategy) {
87
+ debug(`Returning detection strategy with the result`);
88
+ const resultWithStrategy = {
89
+ match: result.match,
90
+ probability: result.probability,
91
+ strategy: formatStrategy(strategy),
92
+ treshold
93
+ };
94
+ debugData(`${JSON.stringify(resultWithStrategy)}`);
95
+ return resultWithStrategy;
96
+ }
97
+ return result;
98
+ }
99
+ function formatStrategy(strategy) {
100
+ const strategyNames = strategy.map(element => element.name);
101
+ return strategyNames || [];
102
+ }
103
+ function calculateprobability(similarityVector) {
104
+ const probability = similarityVector.reduce((acc, v) => acc + v, 0.0);
105
+ return probability > 1.0 ? 1.0 : probability;
106
+ }
107
+ function generateSimilarityVector(featurePairs) {
108
+ const compared = featurePairs.map(({
109
+ name,
110
+ a,
111
+ b
112
+ }) => {
113
+ const {
114
+ compare
115
+ } = strategy.find(({
116
+ name: featureName
117
+ }) => name === featureName);
118
+ const points = compare(a, b);
119
+ return {
120
+ name,
121
+ points
122
+ };
123
+ });
124
+ debugData(`Points: ${JSON.stringify(compared)}`);
125
+ return compared.map(({
126
+ points
127
+ }) => points);
128
+ }
129
+ function generateFeaturePairs(featuresA, featuresB) {
130
+ const pairs = generatePairs();
131
+ const missingFeatures = findMissing();
132
+ debug(`Not comparing the following features because one, or both records are missing features: ${JSON.stringify(missingFeatures)}`);
133
+ return pairs;
134
+ function generatePairs() {
135
+ return featuresA.reduce((acc, {
136
+ name,
137
+ value
138
+ }, index) => acc.concat({
139
+ name,
140
+ a: value,
141
+ b: featuresB[index].value
142
+ }), []).filter(({
143
+ a,
144
+ b
145
+ }) => {
146
+ if (a.length === 0 || b.length === 0) {
147
+ return false;
148
+ }
149
+ return true;
150
+ });
151
+ }
152
+ function findMissing() {
153
+ return featuresA.map(({
154
+ name
155
+ }) => name).filter(v => pairs.some(({
156
+ name
157
+ }) => name === v) === false);
158
+ }
159
+ }
160
+ };
161
+ exports.default = _default;
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["strategy","treshold","returnStrategy","recordA","recordB","minProbabilityQuantifier","debug","createDebugLogger","debugData","extend","JSON","stringify","featuresA","extractFeatures","Array","isArray","recordsB","detectionResults","map","record","actualDetection","featuresB","featurePairs","generateFeaturePairs","similarityVector","generateSimilarityVector","some","v","probability","calculateprobability","returnResult","match","reduce","acc","name","extract","concat","value","result","resultWithStrategy","formatStrategy","strategyNames","element","compared","a","b","compare","find","featureName","points","pairs","generatePairs","missingFeatures","findMissing","index","filter","length"],"sources":["../../src/match-detection/index.js"],"sourcesContent":["/* eslint-disable no-console */\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 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 * as features from './features';\n\nexport {features};\n\nexport default ({strategy, treshold = 0.9}, returnStrategy = false) => (recordA, recordB) => {\n const minProbabilityQuantifier = 0.5;\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection');\n const debugData = debug.extend('data');\n\n debugData(`Strategy: ${JSON.stringify(strategy)}`);\n debugData(`Treshold: ${JSON.stringify(treshold)}`);\n debugData(`ReturnStrategy: ${JSON.stringify(returnStrategy)}`);\n\n const featuresA = extractFeatures(recordA);\n\n debug(`We got an array of records: ${Array.isArray(recordB)}`);\n const recordsB = Array.isArray(recordB) ? recordB : [recordB];\n const detectionResults = recordsB.map(record => actualDetection(featuresA, record));\n\n return Array.isArray(recordB) ? detectionResults : detectionResults[0];\n\n function actualDetection(featuresA, record) {\n\n const featuresB = extractFeatures(record);\n\n debugData(`Features (a): ${JSON.stringify(featuresA)}`);\n debugData(`Features (b): ${JSON.stringify(featuresB)}`);\n\n const featurePairs = generateFeaturePairs(featuresA, featuresB);\n const similarityVector = generateSimilarityVector(featurePairs);\n\n if (similarityVector.some(v => v >= minProbabilityQuantifier)) {\n const probability = calculateprobability(similarityVector);\n debug(`probability: ${probability} (Treshold: ${treshold})`);\n return returnResult({match: probability >= treshold, probability});\n }\n\n debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);\n return returnResult({match: false, probability: 0.0});\n }\n\n function extractFeatures(record) {\n return strategy.reduce((acc, {name, extract}) => acc.concat({name, value: extract(record)}), []);\n }\n\n function returnResult(result) {\n if (returnStrategy) {\n debug(`Returning detection strategy with the result`);\n const resultWithStrategy = {match: result.match, probability: result.probability, strategy: formatStrategy(strategy), treshold};\n debugData(`${JSON.stringify(resultWithStrategy)}`);\n return resultWithStrategy;\n }\n return result;\n }\n\n function formatStrategy(strategy) {\n const strategyNames = strategy.map(element => element.name);\n return strategyNames || [];\n }\n\n function calculateprobability(similarityVector) {\n const probability = similarityVector.reduce((acc, v) => acc + v, 0.0);\n return probability > 1.0 ? 1.0 : probability;\n }\n\n function generateSimilarityVector(featurePairs) {\n const compared = featurePairs.map(({name, a, b}) => {\n const {compare} = strategy.find(({name: featureName}) => name === featureName);\n const points = compare(a, b);\n return {name, points};\n });\n\n debugData(`Points: ${JSON.stringify(compared)}`);\n return compared.map(({points}) => points);\n }\n\n function generateFeaturePairs(featuresA, featuresB) {\n const pairs = generatePairs();\n const missingFeatures = findMissing();\n\n debug(`Not comparing the following features because one, or both records are missing features: ${JSON.stringify(missingFeatures)}`);\n return pairs;\n\n function generatePairs() {\n return featuresA\n .reduce((acc, {name, value}, index) => acc.concat({\n name,\n a: value,\n b: featuresB[index].value\n }), [])\n .filter(({a, b}) => {\n if (a.length === 0 || b.length === 0) {\n return false;\n }\n\n return true;\n });\n }\n\n function findMissing() {\n return featuresA\n .map(({name}) => name)\n .filter(v => pairs.some(({name}) => name === v) === false);\n }\n }\n\n};\n"],"mappings":";;;;;;AA6BA;AACA;AAAuC;AAAA;AAAA;AAAA;AA9BvC;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;AA1BA,eAiCe,CAAC;EAACA,QAAQ;EAAEC,QAAQ,GAAG;AAAG,CAAC,EAAEC,cAAc,GAAG,KAAK,KAAK,CAACC,OAAO,EAAEC,OAAO,KAAK;EAC3F,MAAMC,wBAAwB,GAAG,GAAG;EAEpC,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,mDAAmD,CAAC;EACpF,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtCD,SAAS,CAAE,aAAYE,IAAI,CAACC,SAAS,CAACX,QAAQ,CAAE,EAAC,CAAC;EAClDQ,SAAS,CAAE,aAAYE,IAAI,CAACC,SAAS,CAACV,QAAQ,CAAE,EAAC,CAAC;EAClDO,SAAS,CAAE,mBAAkBE,IAAI,CAACC,SAAS,CAACT,cAAc,CAAE,EAAC,CAAC;EAE9D,MAAMU,SAAS,GAAGC,eAAe,CAACV,OAAO,CAAC;EA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A,IAAI,CAAC,CACrBqB,MAAM,CAAC5B,CAAC,IAAIuB,KAAK,CAACxB,IAAI,CAAC,CAAC;QAACQ;MAAI,CAAC,KAAKA,IAAI,KAAKP,CAAC,CAAC,KAAK,KAAK,CAAC;IAC9D;EACF;AAEF,CAAC;AAAA"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
4
+ var _fixura = require("@natlibfi/fixura");
5
+ var _chai = require("chai");
6
+ var _marcRecord = require("@natlibfi/marc-record");
7
+ var features = _interopRequireWildcard(require("./features"));
8
+ var _ = _interopRequireDefault(require("."));
9
+ var _util = require("util");
10
+ var _debug = _interopRequireDefault(require("debug"));
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ /**
15
+ *
16
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
17
+ *
18
+ * Melinda record matching modules for Javascript
19
+ *
20
+ * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
21
+ *
22
+ * This file is part of melinda-record-matching-js
23
+ *
24
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
25
+ * it under the terms of the GNU Lesser General Public License as
26
+ * published by the Free Software Foundation, either version 3 of the
27
+ * License, or (at your option) any later version.
28
+ *
29
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
30
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ * GNU Lesser General Public License for more details.
33
+ *
34
+ * You should have received a copy of the GNU Affero General Public License
35
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
36
+ *
37
+ * @licend The above is the entire license notice
38
+ * for the JavaScript code in this file.
39
+ *
40
+ */
41
+
42
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:test');
43
+ const debugData = debug.extend('data');
44
+ describe('match-detection', () => {
45
+ (0, _fixugen.default)({
46
+ path: [__dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],
47
+ useMetadataFile: true,
48
+ recurse: false,
49
+ fixura: {
50
+ reader: _fixura.READERS.JSON
51
+ },
52
+ callback: ({
53
+ getFixture,
54
+ options,
55
+ expectedResults,
56
+ array,
57
+ enabled = true
58
+ }) => {
59
+ if (!enabled) {
60
+ debug(`*** DISABLED TEST! ***`);
61
+ return;
62
+ }
63
+ const detect = (0, _.default)(formatOptions());
64
+ const recordA = new _marcRecord.MarcRecord(getFixture('recordA.json'), {
65
+ subfieldValues: false
66
+ });
67
+ debugData((0, _util.inspect)(recordA));
68
+ debug(`Our recordB is an array of records: ${array}`);
69
+ const recordB = array ? getFixture('recordB.json').map(recordJson => new _marcRecord.MarcRecord(recordJson, {
70
+ subfieldValues: false
71
+ })) : new _marcRecord.MarcRecord(getFixture('recordB.json'), {
72
+ subfieldValues: false
73
+ });
74
+ debugData((0, _util.inspect)(recordB));
75
+ const results = detect(recordA, recordB);
76
+ debugData(`${JSON.stringify(results)}`);
77
+ (0, _chai.expect)(results).to.eql(expectedResults);
78
+ function formatOptions() {
79
+ const contextFeatures = features[options.strategy.type];
80
+ return {
81
+ ...options,
82
+ strategy: options.strategy.features.map(v => contextFeatures[v]())
83
+ };
84
+ }
85
+ }
86
+ });
87
+ });
88
+ //# sourceMappingURL=index.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.js","names":["debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","callback","getFixture","options","expectedResults","array","enabled","detect","createDetectionInterface","formatOptions","recordA","MarcRecord","subfieldValues","inspect","recordB","map","recordJson","results","stringify","expect","to","eql","contextFeatures","features","strategy","type","v"],"sources":["../../src/match-detection/index.spec.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 generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from './features';\nimport createDetectionInterface from '.';\nimport {inspect} from 'util';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:test');\nconst debugData = debug.extend('data');\n\ndescribe('match-detection', () => {\n generateTests({\n path: [__dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({getFixture, options, expectedResults, array, enabled = true}) => {\n\n if (!enabled) {\n debug(`*** DISABLED TEST! ***`);\n return;\n }\n\n const detect = createDetectionInterface(formatOptions());\n const recordA = new MarcRecord(getFixture('recordA.json'), {subfieldValues: false});\n debugData(inspect(recordA));\n\n debug(`Our recordB is an array of records: ${array}`);\n const recordB = array\n ? getFixture('recordB.json').map(recordJson => new MarcRecord(recordJson, {subfieldValues: false}))\n : new MarcRecord(getFixture('recordB.json'), {subfieldValues: false});\n debugData(inspect(recordB));\n\n const results = detect(recordA, recordB);\n debugData(`${JSON.stringify(results)}`);\n\n expect(results).to.eql(expectedResults);\n\n function formatOptions() {\n const contextFeatures = features[options.strategy.type];\n\n return {\n ...options,\n strategy: options.strategy.features.map(v => contextFeatures[v]())\n };\n }\n }\n });\n});\n"],"mappings":";;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAsC;AAAA;AAAA;AAnCtC;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;;AAWA,MAAMA,KAAK,GAAG,IAAAC,cAAiB,EAAC,wDAAwD,CAAC;AACzF,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAEtCC,QAAQ,CAAC,iBAAiB,EAAE,MAAM;EAChC,IAAAC,gBAAa,EAAC;IACZC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,CAAC;IAC1EC,eAAe,EAAE,IAAI;IACrBC,OAAO,EAAE,KAAK;IACdC,MAAM,EAAE;MACNC,MAAM,EAAEC,eAAO,CAACC;IAClB,CAAC;IACDC,QA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AIJ,eAAe,CAACI,CAAC,CAAC,EAAE;QACnE,CAAC;MACH;IACF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMelindaIdsF035 = getMelindaIdsF035;
7
+ exports.getSubfieldValues = getSubfieldValues;
8
+ exports.testStringOrNumber = testStringOrNumber;
9
+ exports.validateSidFieldSubfieldCounts = validateSidFieldSubfieldCounts;
10
+ var _debug = _interopRequireDefault(require("debug"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ *
14
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
15
+ *
16
+ * Melinda record matching modules for Javascript
17
+ *
18
+ * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
19
+ *
20
+ * This file is part of melinda-record-matching-js
21
+ *
22
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
23
+ * it under the terms of the GNU Lesser General Public License as
24
+ * published by the Free Software Foundation, either version 3 of the
25
+ * License, or (at your option) any later version.
26
+ *
27
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU Lesser General Public License for more details.
31
+ *
32
+ * You should have received a copy of the GNU Affero General Public License
33
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
+ *
35
+ * @licend The above is the entire license notice
36
+ * for the JavaScript code in this file.
37
+ *
38
+ */
39
+
40
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:utils');
41
+ const debugData = debug.extend('data');
42
+
43
+ // eslint-disable-next-line max-statements
44
+ function getMelindaIdsF035(record) {
45
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:melinda-id');
46
+ const debugData = debug.extend('data');
47
+ const f035s = record.getFields('035');
48
+ if (f035s.length < 1) {
49
+ debug(`No f035s found.`);
50
+ return [];
51
+ }
52
+ const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));
53
+ const f035MelindaIds = [...new Set(allF035MelindaIds)];
54
+ debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);
55
+ debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);
56
+ debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);
57
+ return f035MelindaIds;
58
+ function toMelindaIds({
59
+ subfields
60
+ }) {
61
+ const melindaIdRegExp = /^(?<prefix>\(FI-MELINDA\)|FCC)(?<id>\d{9})$/u;
62
+ return subfields.filter(sub => ['a', 'z'].includes(sub.code)).filter(sub => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value))).map(({
63
+ value
64
+ }) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, '$<id>') : '');
65
+ }
66
+ }
67
+ function validateSidFieldSubfieldCounts(field) {
68
+ // Valid SID-fields have just one $c and one $b
69
+ debugData(`Validating SID field ${JSON.stringify(field)}`);
70
+ const countC = countSubfields(field, 'c');
71
+ const countB = countSubfields(field, 'b');
72
+ debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);
73
+ return countC === 1 && countB === 1;
74
+ }
75
+ function countSubfields(field, subfieldCode) {
76
+ // debug(`Counting subfields ${subfieldCode}`);
77
+ return field.subfields.filter(({
78
+ code
79
+ }) => code === subfieldCode).length;
80
+ }
81
+ function getSubfieldValues(field, subfieldCode) {
82
+ debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);
83
+ return field.subfields.filter(({
84
+ code
85
+ }) => code === subfieldCode).map(({
86
+ value
87
+ }) => testStringOrNumber(value) ? String(value) : '').filter(value => value);
88
+ }
89
+ function testStringOrNumber(value) {
90
+ if (typeof value === 'string' || typeof value === 'number') {
91
+ return true;
92
+ }
93
+ return false;
94
+ }
95
+ //# sourceMappingURL=matching-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching-utils.js","names":["debug","createDebugLogger","debugData","extend","getMelindaIdsF035","record","f035s","getFields","length","allF035MelindaIds","concat","map","toMelindaIds","f035MelindaIds","Set","JSON","stringify","subfields","melindaIdRegExp","filter","sub","includes","code","testStringOrNumber","value","test","String","replace","validateSidFieldSubfieldCounts","field","countC","countSubfields","countB","subfieldCode","getSubfieldValues"],"sources":["../src/matching-utils.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-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:utils');\nconst debugData = debug.extend('data');\n\n// eslint-disable-next-line max-statements\nexport function getMelindaIdsF035(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:melinda-id');\n const debugData = debug.extend('data');\n\n const f035s = record.getFields('035');\n\n if (f035s.length < 1) {\n debug(`No f035s found.`);\n return [];\n }\n\n const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));\n const f035MelindaIds = [...new Set(allF035MelindaIds)];\n\n debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);\n debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);\n debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);\n\n return f035MelindaIds;\n\n function toMelindaIds({subfields}) {\n const melindaIdRegExp = /^(?<prefix>\\(FI-MELINDA\\)|FCC)(?<id>\\d{9})$/u;\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code))\n .filter(sub => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value)))\n .map(({value}) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, '$<id>') : '');\n\n }\n}\n\nexport function validateSidFieldSubfieldCounts(field) {\n // Valid SID-fields have just one $c and one $b\n debugData(`Validating SID field ${JSON.stringify(field)}`);\n const countC = countSubfields(field, 'c');\n const countB = countSubfields(field, 'b');\n debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);\n\n return countC === 1 && countB === 1;\n}\n\nfunction countSubfields(field, subfieldCode) {\n // debug(`Counting subfields ${subfieldCode}`);\n return field.subfields.filter(({code}) => code === subfieldCode).length;\n}\n\nexport function getSubfieldValues(field, subfieldCode) {\n debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);\n return field.subfields\n .filter(({code}) => code === subfieldCode)\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value);\n}\n\nexport function testStringOrNumber(value) {\n if (typeof value === 'string' || typeof value === 'number') {\n return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;AA4BA;AAAsC;AA5BtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,KAAK,GAAG,IAAAC,cAAiB,EAAC,yCAAyC,CAAC;AAC1E,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;;AAEtC;AACO,SAASC,iBAAiB,CAACC,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