@natlibfi/melinda-record-matching 2.2.1-alpha.1 → 2.2.1-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 (66) hide show
  1. package/dist/candidate-search/candidate-search-utils.js +58 -0
  2. package/dist/candidate-search/candidate-search-utils.js.map +1 -0
  3. package/dist/candidate-search/index.js +273 -0
  4. package/dist/candidate-search/index.js.map +1 -0
  5. package/dist/candidate-search/index.spec.js +161 -0
  6. package/dist/candidate-search/index.spec.js.map +1 -0
  7. package/dist/candidate-search/query-list/bib.js +252 -0
  8. package/dist/candidate-search/query-list/bib.js.map +1 -0
  9. package/dist/candidate-search/query-list/bib.spec.js +72 -0
  10. package/dist/candidate-search/query-list/bib.spec.js.map +1 -0
  11. package/dist/candidate-search/query-list/index.js +67 -0
  12. package/dist/candidate-search/query-list/index.js.map +1 -0
  13. package/dist/index.js +578 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/index.spec.js +133 -0
  16. package/dist/index.spec.js.map +1 -0
  17. package/dist/match-detection/features/bib/all-source-ids.js +122 -0
  18. package/dist/match-detection/features/bib/all-source-ids.js.map +1 -0
  19. package/dist/match-detection/features/bib/authors.js +120 -0
  20. package/dist/match-detection/features/bib/authors.js.map +1 -0
  21. package/dist/match-detection/features/bib/bibliographic-level.js +42 -0
  22. package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -0
  23. package/dist/match-detection/features/bib/host-component.js +42 -0
  24. package/dist/match-detection/features/bib/host-component.js.map +1 -0
  25. package/dist/match-detection/features/bib/index.js +104 -0
  26. package/dist/match-detection/features/bib/index.js.map +1 -0
  27. package/dist/match-detection/features/bib/index.spec.js +97 -0
  28. package/dist/match-detection/features/bib/index.spec.js.map +1 -0
  29. package/dist/match-detection/features/bib/isbn.js +55 -0
  30. package/dist/match-detection/features/bib/isbn.js.map +1 -0
  31. package/dist/match-detection/features/bib/issn.js +55 -0
  32. package/dist/match-detection/features/bib/issn.js.map +1 -0
  33. package/dist/match-detection/features/bib/language.js +113 -0
  34. package/dist/match-detection/features/bib/language.js.map +1 -0
  35. package/dist/match-detection/features/bib/melinda-id.js +52 -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 +100 -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 +55 -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 +51 -0
  42. package/dist/match-detection/features/bib/publication-time.js.map +1 -0
  43. package/dist/match-detection/features/bib/record-type.js +43 -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 +127 -0
  46. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -0
  47. package/dist/match-detection/features/bib/title.js +95 -0
  48. package/dist/match-detection/features/bib/title.js.map +1 -0
  49. package/dist/match-detection/features/index.js +15 -0
  50. package/dist/match-detection/features/index.js.map +1 -0
  51. package/dist/match-detection/index.js +184 -0
  52. package/dist/match-detection/index.js.map +1 -0
  53. package/dist/match-detection/index.spec.js +99 -0
  54. package/dist/match-detection/index.spec.js.map +1 -0
  55. package/dist/matching-utils.js +104 -0
  56. package/dist/matching-utils.js.map +1 -0
  57. package/package.json +2 -1
  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,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "allSourceIds", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _allSourceIds.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "authors", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _authors.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "bibliographicLevel", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _bibliographicLevel.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "hostComponent", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _hostComponent.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "isbn", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _isbn.default;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "issn", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _issn.default;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "language", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _language.default;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "melindaId", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _melindaId.default;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "otherStandardIdentifier", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _otherStandardIdentifier.default;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "publicationTime", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _publicationTime.default;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "recordType", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _recordType.default;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "title", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _title.default;
76
+ }
77
+ });
78
+
79
+ var _hostComponent = _interopRequireDefault(require("./host-component"));
80
+
81
+ var _isbn = _interopRequireDefault(require("./isbn"));
82
+
83
+ var _issn = _interopRequireDefault(require("./issn"));
84
+
85
+ var _otherStandardIdentifier = _interopRequireDefault(require("./other-standard-identifier"));
86
+
87
+ var _title = _interopRequireDefault(require("./title"));
88
+
89
+ var _authors = _interopRequireDefault(require("./authors"));
90
+
91
+ var _recordType = _interopRequireDefault(require("./record-type"));
92
+
93
+ var _publicationTime = _interopRequireDefault(require("./publication-time"));
94
+
95
+ var _language = _interopRequireDefault(require("./language"));
96
+
97
+ var _bibliographicLevel = _interopRequireDefault(require("./bibliographic-level"));
98
+
99
+ var _melindaId = _interopRequireDefault(require("./melinda-id"));
100
+
101
+ var _allSourceIds = _interopRequireDefault(require("./all-source-ids"));
102
+
103
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/match-detection/features/bib/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\nexport {default as hostComponent} from './host-component';\nexport {default as isbn} from './isbn';\nexport {default as issn} from './issn';\nexport {default as otherStandardIdentifier} from './other-standard-identifier';\nexport {default as title} from './title';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as language} from './language';\nexport {default as bibliographicLevel} from './bibliographic-level';\nexport {default as melindaId} from './melinda-id';\nexport {default as allSourceIds} from './all-source-ids';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
4
+
5
+ var _fixura = require("@natlibfi/fixura");
6
+
7
+ var _chai = require("chai");
8
+
9
+ var _marcRecord = require("@natlibfi/marc-record");
10
+
11
+ var features = _interopRequireWildcard(require("."));
12
+
13
+ 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); }
14
+
15
+ 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; }
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ /**
20
+ *
21
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
22
+ *
23
+ * Melinda record matching modules for Javascript
24
+ *
25
+ * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
26
+ *
27
+ * This file is part of melinda-record-matching-js
28
+ *
29
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
30
+ * it under the terms of the GNU Lesser General Public License as
31
+ * published by the Free Software Foundation, either version 3 of the
32
+ * License, or (at your option) any later version.
33
+ *
34
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+ * GNU Lesser General Public License for more details.
38
+ *
39
+ * You should have received a copy of the GNU Affero General Public License
40
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
41
+ *
42
+ * @licend The above is the entire license notice
43
+ * for the JavaScript code in this file.
44
+ *
45
+ */
46
+ describe('match-detection/features/bib/', () => {
47
+ (0, _fixugen.default)({
48
+ path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],
49
+ useMetadataFile: true,
50
+ fixura: {
51
+ reader: _fixura.READERS.JSON
52
+ },
53
+ // eslint-disable-next-line max-statements
54
+ callback: ({
55
+ enabled = true,
56
+ feature,
57
+ options,
58
+ type,
59
+ ...expectations
60
+ }) => {
61
+ if (!enabled) {
62
+ return;
63
+ }
64
+
65
+ if (type === 'extract') {
66
+ const {
67
+ expectedFeatures,
68
+ inputRecord
69
+ } = expectations;
70
+ const record = new _marcRecord.MarcRecord(inputRecord, {
71
+ subfieldValues: false
72
+ });
73
+ const {
74
+ extract
75
+ } = features[feature](options);
76
+ (0, _chai.expect)(extract(record)).to.eql(expectedFeatures);
77
+ return;
78
+ }
79
+
80
+ if (type === 'compare') {
81
+ const {
82
+ featuresA,
83
+ featuresB,
84
+ expectedPoints
85
+ } = expectations;
86
+ const {
87
+ compare
88
+ } = features[feature](options);
89
+ (0, _chai.expect)(compare(featuresA, featuresB)).to.equal(expectedPoints);
90
+ return;
91
+ }
92
+
93
+ throw new Error(`Invalid type ${type}`);
94
+ }
95
+ });
96
+ });
97
+ //# sourceMappingURL=index.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.js","names":["describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","features","expect","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"sources":["../../../../src/match-detection/features/bib/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 '.';\n\n\ndescribe('match-detection/features/bib/', () => {\n generateTests({\n path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n // eslint-disable-next-line max-statements\n callback: ({enabled = true, feature, options, type, ...expectations}) => {\n\n if (!enabled) {\n return;\n }\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n const {extract} = features[feature](options);\n\n expect(extract(record)).to.eql(expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n expect(compare(featuresA, featuresB)).to.equal(expectedPoints);\n return;\n }\n\n throw new Error(`Invalid type ${type}`);\n }\n });\n});\n"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA;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;AASAA,QAAQ,CAAC,+BAAD,EAAkC,MAAM;EAC9C,IAAAC,gBAAA,EAAc;IACZC,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,IAAxB,EAA8B,IAA9B,EAAoC,eAApC,EAAqD,iBAArD,EAAwE,UAAxE,EAAoF,KAApF,CADM;IAEZC,eAAe,EAAE,IAFL;IAGZC,MAAM,EAAE;MACNC,MAAM,EAAEC,eAAA,CAAQC;IADV,CAHI;IAMZ;IACAC,QAAQ,EAAE,CAAC;MAACC,OAAO,GAAG,IAAX;MAAiBC,OAAjB;MAA0BC,OAA1B;MAAmCC,IAAnC;MAAyC,GAAGC;IAA5C,CAAD,KAA+D;MAEvE,IAAI,CAACJ,OAAL,EAAc;QACZ;MACD;;MAED,IAAIG,IAAI,KAAK,SAAb,EAAwB;QACtB,MAAM;UAACE,gBAAD;UAAmBC;QAAnB,IAAkCF,YAAxC;QACA,MAAMG,MAAM,GAAG,IAAIC,sBAAJ,CAAeF,WAAf,EAA4B;UAACG,cAAc,EAAE;QAAjB,CAA5B,CAAf;QACA,MAAM;UAACC;QAAD,IAAYC,QAAQ,CAACV,OAAD,CAAR,CAAkBC,OAAlB,CAAlB;QAEA,IAAAU,YAAA,EAAOF,OAAO,CAACH,MAAD,CAAd,EAAwBM,EAAxB,CAA2BC,GAA3B,CAA+BT,gBAA/B;QACA;MACD;;MAED,IAAIF,IAAI,KAAK,SAAb,EAAwB;QACtB,MAAM;UAACY,SAAD;UAAYC,SAAZ;UAAuBC;QAAvB,IAAyCb,YAA/C;QACA,MAAM;UAACc;QAAD,IAAYP,QAAQ,CAACV,OAAD,CAAR,CAAkBC,OAAlB,CAAlB;QAEA,IAAAU,YAAA,EAAOM,OAAO,CAACH,SAAD,EAAYC,SAAZ,CAAd,EAAsCH,EAAtC,CAAyCM,KAAzC,CAA+CF,cAA/C;QACA;MACD;;MAED,MAAM,IAAIG,KAAJ,CAAW,gBAAejB,IAAK,EAA/B,CAAN;IACD;EA/BW,CAAd;AAiCD,CAlCO,CAAR"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
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 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
+ var _default = () => {
40
+ const {
41
+ extract,
42
+ compare
43
+ } = (0, _standardIdentifierFactory.default)({
44
+ pattern: /^020$/u,
45
+ subfieldCodes: ['a', 'z']
46
+ });
47
+ return {
48
+ extract,
49
+ compare,
50
+ name: 'ISBN'
51
+ };
52
+ };
53
+
54
+ exports.default = _default;
55
+ //# sourceMappingURL=isbn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isbn.js","names":["extract","compare","createInterface","pattern","subfieldCodes","name"],"sources":["../../../../src/match-detection/features/bib/isbn.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\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^020$/u, subfieldCodes: ['a', 'z']});\n return {extract, compare, name: 'ISBN'};\n};\n"],"mappings":";;;;;;;AA4BA;;;;AA5BA;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;eAIe,MAAM;EACnB,MAAM;IAACA,OAAD;IAAUC;EAAV,IAAqB,IAAAC,kCAAA,EAAgB;IAACC,OAAO,EAAE,QAAV;IAAoBC,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN;EAAnC,CAAhB,CAA3B;EACA,OAAO;IAACJ,OAAD;IAAUC,OAAV;IAAmBI,IAAI,EAAE;EAAzB,CAAP;AACD,C"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
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 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
+ var _default = () => {
40
+ const {
41
+ extract,
42
+ compare
43
+ } = (0, _standardIdentifierFactory.default)({
44
+ pattern: /^022$/u,
45
+ subfieldCodes: ['a', 'z', 'y']
46
+ });
47
+ return {
48
+ extract,
49
+ compare,
50
+ name: 'ISSN'
51
+ };
52
+ };
53
+
54
+ exports.default = _default;
55
+ //# sourceMappingURL=issn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issn.js","names":["extract","compare","createInterface","pattern","subfieldCodes","name"],"sources":["../../../../src/match-detection/features/bib/issn.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\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^022$/u, subfieldCodes: ['a', 'z', 'y']});\n return {extract, compare, name: 'ISSN'};\n};\n"],"mappings":";;;;;;;AA4BA;;;;AA5BA;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;eAIe,MAAM;EACnB,MAAM;IAACA,OAAD;IAAUC;EAAV,IAAqB,IAAAC,kCAAA,EAAgB;IAACC,OAAO,EAAE,QAAV;IAAoBC,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX;EAAnC,CAAhB,CAA3B;EACA,OAAO;IAACJ,OAAD;IAAUC,OAAV;IAAmBI,IAAI,EAAE;EAAzB,CAAP;AACD,C"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ /* eslint-disable max-statements */
13
+
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-2022 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
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:language');
42
+ const debugData = debug.extend('data');
43
+
44
+ var _default = () => ({
45
+ name: 'Language',
46
+ extract: record => {
47
+ const value008 = get008Value();
48
+ const values041 = get041Values();
49
+ debugData(`008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
50
+
51
+ if (value008 && values041.length > 0) {
52
+ debugData(`There's both 008 and 041, searching for value in both`);
53
+ const correspondingValue = values041.find(v => v === value008);
54
+ debugData(`Corresponding value: ${correspondingValue}`);
55
+ return correspondingValue ? [correspondingValue] : [];
56
+ }
57
+
58
+ if (!value008 && values041.length < 1) {
59
+ debugData(`No actual values found`);
60
+ return [];
61
+ }
62
+
63
+ return value008 ? [value008] : [values041[0]];
64
+
65
+ function get008Value() {
66
+ var _record$get, _record$get$;
67
+
68
+ const value = ((_record$get = record.get(/^008$/u)) === null || _record$get === void 0 ? void 0 : (_record$get$ = _record$get[0]) === null || _record$get$ === void 0 ? void 0 : _record$get$.value) || undefined;
69
+ debugData(`008 value: ${value}`);
70
+
71
+ if (!value) {
72
+ return undefined;
73
+ }
74
+
75
+ const code = value.slice(35, 38);
76
+ debugData(`008 code: ${code}`);
77
+ return code === '|||' || code === ' ' || code === '^^^' ? undefined : code;
78
+ } // Main language for the resource: in the first f041 $a or f041 $d
79
+ // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes
80
+
81
+
82
+ function get041Values() {
83
+ return record.get(/^041$/u).filter(({
84
+ ind2
85
+ }) => ind2 === ' ').map(({
86
+ subfields
87
+ }) => subfields).flat().filter(({
88
+ code
89
+ }) => code === 'a' || code === 'd').map(({
90
+ value
91
+ }) => value);
92
+ }
93
+ },
94
+ compare: (a, b) => {
95
+ debugData(`Comparing ${JSON.stringify(a[0])} and ${JSON.stringify(b[0])}`);
96
+
97
+ if (a.length === 0 || b.length === 0) {
98
+ debugData(`No language to compare`);
99
+ return 0;
100
+ }
101
+
102
+ debugData(`There are languages to compare`);
103
+
104
+ if (a[0] === b[0]) {
105
+ return 0.1;
106
+ }
107
+
108
+ return a[0] === 'und' || b[0] === 'und' ? 0.0 : -1.0;
109
+ }
110
+ });
111
+
112
+ exports.default = _default;
113
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","names":["debug","createDebugLogger","debugData","extend","name","extract","record","value008","get008Value","values041","get041Values","JSON","stringify","length","correspondingValue","find","v","value","get","undefined","code","slice","filter","ind2","map","subfields","flat","compare","a","b"],"sources":["../../../../src/match-detection/features/bib/language.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:language');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Language',\n extract: record => {\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (value008 && values041.length > 0) {\n debugData(`There's both 008 and 041, searching for value in both`);\n const correspondingValue = values041.find(v => v === value008);\n debugData(`Corresponding value: ${correspondingValue}`);\n return correspondingValue ? [correspondingValue] : [];\n }\n\n if (!value008 && values041.length < 1) {\n debugData(`No actual values found`);\n return [];\n }\n\n return value008 ? [value008] : [values041[0]];\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`008 code: ${code}`);\n return code === '|||' || code === ' ' || code === '^^^' ? undefined : code;\n }\n\n // Main language for the resource: in the first f041 $a or f041 $d\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 .map(({value}) => value);\n }\n },\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a[0])} and ${JSON.stringify(b[0])}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n debugData(`There are languages to compare`);\n\n if (a[0] === b[0]) {\n return 0.1;\n }\n\n return a[0] === 'und' || b[0] === 'und' ? 0.0 : -1.0;\n }\n});\n"],"mappings":"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"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _melindaIdentifierFactory = _interopRequireDefault(require("./melinda-identifier-factory"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
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 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
+ var _default = () => {
40
+ const {
41
+ extract,
42
+ compare
43
+ } = (0, _melindaIdentifierFactory.default)();
44
+ return {
45
+ extract,
46
+ compare,
47
+ name: 'melinda-id'
48
+ };
49
+ };
50
+
51
+ exports.default = _default;
52
+ //# sourceMappingURL=melinda-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"melinda-id.js","names":["extract","compare","createInterface","name"],"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;;;;AA5BA;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;eAIe,MAAM;EACnB,MAAM;IAACA,OAAD;IAAUC;EAAV,IAAqB,IAAAC,iCAAA,GAA3B;EACA,OAAO;IAACF,OAAD;IAAUC,OAAV;IAAmBE,IAAI,EAAE;EAAzB,CAAP;AACD,C"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+
10
+ var _matchingUtils = require("../../../matching-utils");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
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
+ // 003+001 FI-MELINDA <melinda-id>
42
+ // 035 $a (FI-MELINDA)<melinda-id>
43
+ // 035 $z (FI-MELINDA)<melinda-id>
44
+ // 035 $a FCC<melinda-id>
45
+ // 035 $z FCC<melinda-id>
46
+ // melinda-id = 001234567
47
+ var _default = () => {
48
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/melinda-id');
49
+ const debugData = debug.extend('data');
50
+ return {
51
+ extract,
52
+ compare
53
+ };
54
+
55
+ function extract(record) {
56
+ const isMelindaRecord = record.get('003').some(f003 => f003.value === 'FI-MELINDA');
57
+ const [f001] = record.get('001').map(field => field.value);
58
+ const f035MelindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
59
+
60
+ if (isMelindaRecord === undefined && f001 === undefined && f035MelindaIds.length < 1) {
61
+ debug(`No Melinda-IDs found`);
62
+ return {};
63
+ }
64
+
65
+ return {
66
+ isMelindaRecord,
67
+ f001,
68
+ f035MelindaIds
69
+ };
70
+ } // eslint-disable-next-line max-statements
71
+
72
+
73
+ function compare(a, b) {
74
+ if (a.isMelindaRecord && b.isMelindaRecord && a.f001 === b.f001) {
75
+ debugData(`Melinda record's A f001 ${a.f001} matches Melinda record's B f001 ${a.f001}`);
76
+ return 1;
77
+ }
78
+
79
+ if (a.isMelindaRecord && typeof b.f035MelindaIds !== 'undefined' && b.f035MelindaIds.some(id => id === a.f001)) {
80
+ debugData(`Melinda record's A f001 ${a.f001} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
81
+ return 1;
82
+ }
83
+
84
+ if (b.isMelindaRecord && typeof a.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(id => id === b.f001)) {
85
+ debugData(`Melinda record's B f001 ${b.f001} matches record A f035 ${JSON.stringify(a.f035MelindaIds)}`);
86
+ return 1;
87
+ }
88
+
89
+ if (typeof a.f035MelindaIds !== 'undefined' && typeof b.f035MelindaIds !== 'undefined' && a.f035MelindaIds.some(idA => b.f035MelindaIds.some(idB => idB === idA))) {
90
+ debugData(`Record A f035 ${JSON.stringify(a.f035MelindaIds)} matches record B f035 ${JSON.stringify(b.f035MelindaIds)}`);
91
+ return 1;
92
+ }
93
+
94
+ debug(`No matching Melinda-IDs.`);
95
+ return 0;
96
+ }
97
+ };
98
+
99
+ exports.default = _default;
100
+ //# sourceMappingURL=melinda-identifier-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"melinda-identifier-factory.js","names":["debug","createDebugLogger","debugData","extend","extract","compare","record","isMelindaRecord","get","some","f003","value","f001","map","field","f035MelindaIds","getMelindaIdsF035","undefined","length","a","b","id","JSON","stringify","idA","idB"],"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) {\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(`No Melinda-IDs found`);\n return {};\n }\n\n return {isMelindaRecord, f001, f035MelindaIds};\n\n }\n\n // eslint-disable-next-line max-statements\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":"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"}