@natlibfi/melinda-record-matching 1.0.10 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candidate-search/candidate-search-utils.js +3 -2
- package/dist/candidate-search/candidate-search-utils.js.map +1 -1
- package/dist/candidate-search/index.js +3 -3
- package/dist/candidate-search/index.js.map +1 -1
- package/dist/candidate-search/index.spec.js +2 -2
- package/dist/candidate-search/index.spec.js.map +1 -1
- package/dist/candidate-search/query-list/bib.js +8 -4
- package/dist/candidate-search/query-list/bib.js.map +1 -1
- package/dist/candidate-search/query-list/bib.spec.js +2 -2
- package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
- package/dist/candidate-search/query-list/index.js +3 -3
- package/dist/candidate-search/query-list/index.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.spec.js +2 -2
- package/dist/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/all-source-ids.js.map +1 -1
- package/dist/match-detection/features/bib/authors.js.map +1 -1
- package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -1
- package/dist/match-detection/features/bib/host-component.js.map +1 -1
- package/dist/match-detection/features/bib/index.js +24 -24
- package/dist/match-detection/features/bib/index.spec.js +2 -2
- package/dist/match-detection/features/bib/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/isbn.js.map +1 -1
- package/dist/match-detection/features/bib/issn.js.map +1 -1
- package/dist/match-detection/features/bib/language.js.map +1 -1
- package/dist/match-detection/features/bib/melinda-id.js.map +1 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +1 -1
- package/dist/match-detection/features/bib/publication-time.js.map +1 -1
- package/dist/match-detection/features/bib/record-type.js.map +1 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -1
- package/dist/match-detection/features/bib/title.js.map +1 -1
- package/dist/match-detection/features/index.js +2 -2
- package/dist/match-detection/index.js +2 -2
- package/dist/match-detection/index.js.map +1 -1
- package/dist/match-detection/index.spec.js +2 -2
- package/dist/match-detection/index.spec.js.map +1 -1
- package/dist/matching-utils.js +1 -1
- package/dist/matching-utils.js.map +1 -1
- package/package.json +26 -29
- package/src/candidate-search/candidate-search-utils.js +3 -1
- package/src/candidate-search/query-list/bib.js +5 -0
|
@@ -3,76 +3,76 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "allSourceIds", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _allSourceIds.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "authors", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _authors.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "bibliographicLevel", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _bibliographicLevel.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "hostComponent", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _hostComponent.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "isbn", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _isbn.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "issn", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _issn.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "language", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _language.default;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "melindaId", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function () {
|
|
51
|
-
return
|
|
51
|
+
return _melindaId.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "otherStandardIdentifier", {
|
|
55
55
|
enumerable: true,
|
|
56
56
|
get: function () {
|
|
57
|
-
return
|
|
57
|
+
return _otherStandardIdentifier.default;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
Object.defineProperty(exports, "
|
|
60
|
+
Object.defineProperty(exports, "publicationTime", {
|
|
61
61
|
enumerable: true,
|
|
62
62
|
get: function () {
|
|
63
|
-
return
|
|
63
|
+
return _publicationTime.default;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
Object.defineProperty(exports, "
|
|
66
|
+
Object.defineProperty(exports, "recordType", {
|
|
67
67
|
enumerable: true,
|
|
68
68
|
get: function () {
|
|
69
|
-
return
|
|
69
|
+
return _recordType.default;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
Object.defineProperty(exports, "
|
|
72
|
+
Object.defineProperty(exports, "title", {
|
|
73
73
|
enumerable: true,
|
|
74
74
|
get: function () {
|
|
75
|
-
return
|
|
75
|
+
return _title.default;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -10,9 +10,9 @@ var _marcRecord = require("@natlibfi/marc-record");
|
|
|
10
10
|
|
|
11
11
|
var features = _interopRequireWildcard(require("."));
|
|
12
12
|
|
|
13
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
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
14
|
|
|
15
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
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
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"names":["describe","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","features","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"names":["describe","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","features","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"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;AAC9C,wBAAc;AACZC,IAAAA,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,IAAxB,EAA8B,IAA9B,EAAoC,eAApC,EAAqD,iBAArD,EAAwE,UAAxE,EAAoF,KAApF,CADM;AAEZC,IAAAA,eAAe,EAAE,IAFL;AAGZC,IAAAA,MAAM,EAAE;AACNC,MAAAA,MAAM,EAAEC,gBAAQC;AADV,KAHI;AAMZ;AACAC,IAAAA,QAAQ,EAAE,CAAC;AAACC,MAAAA,OAAO,GAAG,IAAX;AAAiBC,MAAAA,OAAjB;AAA0BC,MAAAA,OAA1B;AAAmCC,MAAAA,IAAnC;AAAyC,SAAGC;AAA5C,KAAD,KAA+D;AAEvE,UAAI,CAACJ,OAAL,EAAc;AACZ;AACD;;AAED,UAAIG,IAAI,KAAK,SAAb,EAAwB;AACtB,cAAM;AAACE,UAAAA,gBAAD;AAAmBC,UAAAA;AAAnB,YAAkCF,YAAxC;AACA,cAAMG,MAAM,GAAG,IAAIC,sBAAJ,CAAeF,WAAf,EAA4B;AAACG,UAAAA,cAAc,EAAE;AAAjB,SAA5B,CAAf;AACA,cAAM;AAACC,UAAAA;AAAD,YAAYC,QAAQ,CAACV,OAAD,CAAR,CAAkBC,OAAlB,CAAlB;AAEA,0BAAOQ,OAAO,CAACH,MAAD,CAAd,EAAwBK,EAAxB,CAA2BC,GAA3B,CAA+BR,gBAA/B;AACA;AACD;;AAED,UAAIF,IAAI,KAAK,SAAb,EAAwB;AACtB,cAAM;AAACW,UAAAA,SAAD;AAAYC,UAAAA,SAAZ;AAAuBC,UAAAA;AAAvB,YAAyCZ,YAA/C;AACA,cAAM;AAACa,UAAAA;AAAD,YAAYN,QAAQ,CAACV,OAAD,CAAR,CAAkBC,OAAlB,CAAlB;AAEA,0BAAOe,OAAO,CAACH,SAAD,EAAYC,SAAZ,CAAd,EAAsCH,EAAtC,CAAyCM,KAAzC,CAA+CF,cAA/C;AACA;AACD;;AAED,YAAM,IAAIG,KAAJ,CAAW,gBAAehB,IAAK,EAA/B,CAAN;AACD;AA/BW,GAAd;AAiCD,CAlCO,CAAR","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"],"file":"index.spec.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/isbn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/isbn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"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;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAAgB;AAACC,IAAAA,OAAO,EAAE,QAAV;AAAoBC,IAAAA,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN;AAAnC,GAAhB,CAA3B;AACA,SAAO;AAACH,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBG,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","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"],"file":"isbn.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/issn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/issn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"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;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAAgB;AAACC,IAAAA,OAAO,EAAE,QAAV;AAAoBC,IAAAA,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX;AAAnC,GAAhB,CAA3B;AACA,SAAO;AAACH,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBG,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","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"],"file":"issn.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/language.js"],"names":["debug","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"],"mappings":";;;;;;;AA6BA;;;;AA7BA;;AACA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/language.js"],"names":["debug","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"],"mappings":";;;;;;;AA6BA;;;;AA7BA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,MAAMA,KAAK,GAAG,oBAAkB,qEAAlB,CAAd;AACA,MAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;;eAEe,OAAO;AACpBC,EAAAA,IAAI,EAAE,UADc;AAEpBC,EAAAA,OAAO,EAAEC,MAAM,IAAI;AACjB,UAAMC,QAAQ,GAAGC,WAAW,EAA5B;AACA,UAAMC,SAAS,GAAGC,YAAY,EAA9B;AACAR,IAAAA,SAAS,CAAE,QAAOS,IAAI,CAACC,SAAL,CAAeL,QAAf,CAAyB,UAASI,IAAI,CAACC,SAAL,CAAeH,SAAf,CAA0B,EAArE,CAAT;;AAEA,QAAIF,QAAQ,IAAIE,SAAS,CAACI,MAAV,GAAmB,CAAnC,EAAsC;AACpCX,MAAAA,SAAS,CAAE,uDAAF,CAAT;AACA,YAAMY,kBAAkB,GAAGL,SAAS,CAACM,IAAV,CAAeC,CAAC,IAAIA,CAAC,KAAKT,QAA1B,CAA3B;AACAL,MAAAA,SAAS,CAAE,wBAAuBY,kBAAmB,EAA5C,CAAT;AACA,aAAOA,kBAAkB,GAAG,CAACA,kBAAD,CAAH,GAA0B,EAAnD;AACD;;AAED,QAAI,CAACP,QAAD,IAAaE,SAAS,CAACI,MAAV,GAAmB,CAApC,EAAuC;AACrCX,MAAAA,SAAS,CAAE,wBAAF,CAAT;AACA,aAAO,EAAP;AACD;;AAED,WAAOK,QAAQ,GAAG,CAACA,QAAD,CAAH,GAAgB,CAACE,SAAS,CAAC,CAAD,CAAV,CAA/B;;AAEA,aAASD,WAAT,GAAuB;AAAA;;AACrB,YAAMS,KAAK,GAAG,gBAAAX,MAAM,CAACY,GAAP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,CAAP;AACD;;AAEDA,IAAAA,SAAS,CAAE,iCAAF,CAAT;;AAEA,QAAI0B,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAd,EAAmB;AACjB,aAAO,GAAP;AACD;;AAED,WAAOD,CAAC,CAAC,CAAD,CAAD,KAAS,KAAT,IAAkBC,CAAC,CAAC,CAAD,CAAD,KAAS,KAA3B,GAAmC,GAAnC,GAAyC,CAAC,GAAjD;AACD;AA7DmB,CAAP,C","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 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 area 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"],"file":"language.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/melinda-id.js"],"names":["extract","compare","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/melinda-id.js"],"names":["extract","compare","name"],"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;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAA3B;AACA,SAAO;AAACD,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBC,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","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"],"file":"melinda-id.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/melinda-identifier-factory.js"],"names":["debug","debugData","extend","extract","compare","record","isMelindaRecord","get","some","f003","value","f001","map","field","f035MelindaIds","undefined","length","a","b","id","JSON","stringify","idA","idB"],"mappings":";;;;;;;AA4BA;;AACA;;;;AA7BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/melinda-identifier-factory.js"],"names":["debug","debugData","extend","extract","compare","record","isMelindaRecord","get","some","f003","value","f001","map","field","f035MelindaIds","undefined","length","a","b","id","JSON","stringify","idA","idB"],"mappings":";;;;;;;AA4BA;;AACA;;;;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;eAEe,MAAM;AAEnB,QAAMA,KAAK,GAAG,oBAAkB,2EAAlB,CAAd;AACA,QAAMC,SAAS,GAAGD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CAACN,IAAK,0BAAyBS,IAAI,CAACC,SAAL,CAAeH,CAAC,CAACJ,cAAjB,CAAiC,EAA7F,CAAT;AACA,aAAO,CAAP;AACD;;AAED,QAAII,CAAC,CAACZ,eAAF,IAAqB,OAAOW,CAAC,CAACH,cAAT,KAA4B,WAAjD,IACAG,CAAC,CAACH,cAAF,CAAiBN,IAAjB,CAAsBW,EAAE,IAAIA,EAAE,KAAKD,CAAC,CAACP,IAArC,CADJ,EACgD;AAC9CV,MAAAA,SAAS,CAAE,2BAA0BiB,CAAC,CAACP,IAAK,0BAAyBS,IAAI,CAACC,SAAL,CAAeJ,CAAC,CAACH,cAAjB,CAAiC,EAA7F,CAAT;AACA,aAAO,CAAP;AACD;;AAED,QAAI,OAAOG,CAAC,CAACH,cAAT,KAA4B,WAA5B,IAA2C,OAAOI,CAAC,CAACJ,cAAT,KAA4B,WAAvE,IACCG,CAAC,CAACH,cAAF,CAAiBN,IAAjB,CAAsBc,GAAG,IAAIJ,CAAC,CAACJ,cAAF,CAAiBN,IAAjB,CAAsBe,GAAG,IAAIA,GAAG,KAAKD,GAArC,CAA7B,CADL,EAC8E;AAC5ErB,MAAAA,SAAS,CAAE,iBAAgBmB,IAAI,CAACC,SAAL,CAAeJ,CAAC,CAACH,cAAjB,CAAiC,0BAAyBM,IAAI,CAACC,SAAL,CAAeH,CAAC,CAACJ,cAAjB,CAAiC,EAA7G,CAAT;AACA,aAAO,CAAP;AACD;;AACDd,IAAAA,KAAK,CAAE,0BAAF,CAAL;AACA,WAAO,CAAP;AACD;AACF,C","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"],"file":"melinda-identifier-factory.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/other-standard-identifier.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/other-standard-identifier.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"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;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAAgB;AAACC,IAAAA,OAAO,EAAE,QAAV;AAAoBC,IAAAA,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN;AAAnC,GAAhB,CAA3B;AACA,SAAO;AAACH,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBG,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","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: /^024$/u, subfieldCodes: ['a', 'z']});\n return {extract, compare, name: 'Other standard identifier'};\n};\n"],"file":"other-standard-identifier.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/publication-time.js"],"names":["name","extract","record","value","get","slice","compare","a","b"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/publication-time.js"],"names":["name","extract","record","value","get","slice","compare","a","b"],"mappings":";;;;;;;AAAA;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;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,kBADc;AAEpBC,EAAAA,OAAO,EAAEC,MAAM,IAAI;AAAA;;AACjB,UAAMC,KAAK,GAAG,gBAAAD,MAAM,CAACE,GAAP,CAAW,QAAX,6EAAuB,CAAvB,+DAA2BD,KAA3B,KAAoC,EAAlD;AACA,WAAOA,KAAK,GAAG,CAACA,KAAK,CAACE,KAAN,CAAY,CAAZ,EAAe,EAAf,CAAD,CAAH,GAA0B,EAAtC;AACD,GALmB;AAMpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AANtB,CAAP,C","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 () => ({\n name: 'Publication time',\n extract: record => {\n const value = record.get(/^008$/u)?.[0]?.value || '';\n return value ? [value.slice(7, 11)] : [];\n },\n compare: (a, b) => a[0] === b[0] ? 0.1 : -1.0\n});\n"],"file":"publication-time.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/record-type.js"],"names":["name","extract","r","leader","compare","a","b"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/record-type.js"],"names":["name","extract","r","leader","compare","a","b"],"mappings":";;;;;;;AAAA;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;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,aADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,MAAF,CAAS,CAAT,IAAc,CAACD,CAAC,CAACC,MAAF,CAAS,CAAT,CAAD,CAAd,GAA8B,EAFxB;AAGpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AAHtB,CAAP,C","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 () => ({\n name: 'Record type',\n extract: r => r.leader[6] ? [r.leader[6]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.5\n});\n"],"file":"record-type.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/standard-identifier-factory.js"],"names":["debug","debugData","extend","pattern","subfieldCodes","extract","compare","record","field","get","subfields","filter","code","includes","map","value","replace","a","b","length","bothHaveValidIdentifiers","maxValues","matchingValues","getValueCount","aValues","bValues","validOnly","getIdentifiers","aValue","some","bValue","values"],"mappings":";;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/standard-identifier-factory.js"],"names":["debug","debugData","extend","pattern","subfieldCodes","extract","compare","record","field","get","subfields","filter","code","includes","map","value","replace","a","b","length","bothHaveValidIdentifiers","maxValues","matchingValues","getValueCount","aValues","bValues","validOnly","getIdentifiers","aValue","some","bValue","values"],"mappings":";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;AAAD,SAAD,KAAaA,KAAxB,CAAP;AACD;AACF;AACF;AACF,C","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';\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: value.replace(/-/ug, '')}));\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"],"file":"standard-identifier-factory.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/title.js"],"names":["treshold","name","extract","record","title","getTitle","replace","toLowerCase","field","get","subfields","filter","code","includes","map","value","join","compare","a","b","debug","distance","maxLength","getMaxLength","percentage","length"],"mappings":";;;;;;;AA4BA;;AACA;;;;AA7BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/title.js"],"names":["treshold","name","extract","record","title","getTitle","replace","toLowerCase","field","get","subfields","filter","code","includes","map","value","join","compare","a","b","debug","distance","maxLength","getMaxLength","percentage","length"],"mappings":";;;;;;;AA4BA;;AACA;;;;AA7BA;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;eAKe,CAAC;AAACA,EAAAA,QAAQ,GAAG;AAAZ,IAAkB,EAAnB,MAA2B;AACxCC,EAAAA,IAAI,EAAE,OADkC;AAExCC,EAAAA,OAAO,EAAEC,MAAM,IAAI;AACjB,UAAMC,KAAK,GAAGC,QAAQ,EAAtB;;AAEA,QAAID,KAAJ,EAAW;AACT,aAAO,CAACA,KAAK,CAACE,OAAN,CAAc,2BAAd,EAA2C,EAA3C,EAA+CC,WAA/C,EAAD,CAAP;AACD;;AAED,WAAO,EAAP;;AAEA,aAASF,QAAT,GAAoB;AAClB,YAAM,CAACG,KAAD,IAAUL,MAAM,CAACM,GAAP,CAAW,QAAX,CAAhB;;AAEA,UAAID,KAAJ,EAAW;AACT,eAAOA,KAAK,CAACE,SAAN,CACJC,MADI,CACG,CAAC;AAACC,UAAAA;AAAD,SAAD,KAAY,CAAC,GAAD,EAAM,GAAN,EAAWC,QAAX,CAAoBD,IAApB,CADf,EAEJE,GAFI,CAEA,CAAC;AAACC,UAAAA;AAAD,SAAD,KAAaA,KAFb,EAGJC,IAHI,CAGC,EAHD,CAAP;AAID;AACF;AACF,GArBuC;AAsBxCC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAU;AACjB,UAAMC,KAAK,GAAG,oBAAkB,sEAAlB,CAAd;AACA,UAAMC,QAAQ,GAAG,kCAAMH,CAAC,CAAC,CAAD,CAAP,EAAYC,CAAC,CAAC,CAAD,CAAb,CAAjB;;AAEA,QAAIE,QAAQ,KAAK,CAAjB,EAAoB;AAClB,aAAO,GAAP;AACD;;AAED,UAAMC,SAAS,GAAGC,YAAY,EAA9B;AACA,UAAMC,UAAU,GAAGH,QAAQ,GAAGC,SAAX,GAAuB,GAA1C;AAEAF,IAAAA,KAAK,CAAE,IAAGF,CAAE,SAAQC,CAAE,mBAAkBG,SAAU,gBAAeD,QAAS,kBAAiBG,UAAW,EAAjG,CAAL;;AAEA,QAAIA,UAAU,IAAIxB,QAAlB,EAA4B;AAC1B,aAAO,GAAP;AACD;;AAED,WAAO,CAAC,GAAR;;AAEA,aAASuB,YAAT,GAAwB;AACtB,aAAOL,CAAC,CAAC,CAAD,CAAD,CAAKO,MAAL,GAAcN,CAAC,CAAC,CAAD,CAAD,CAAKM,MAAnB,GAA4BP,CAAC,CAAC,CAAD,CAAD,CAAKO,MAAjC,GAA0CN,CAAC,CAAC,CAAD,CAAD,CAAKM,MAAtD;AACD;AAEF;AA7CuC,CAA3B,C","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 {LevenshteinDistance as leven} from 'natural';\n\nexport default ({treshold = 10} = {}) => ({\n name: 'Title',\n extract: record => {\n const title = getTitle();\n\n if (title) {\n return [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}) => value)\n .join('');\n }\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"],"file":"title.js"}
|
|
@@ -9,7 +9,7 @@ var bib = _interopRequireWildcard(require("./bib"));
|
|
|
9
9
|
|
|
10
10
|
exports.bib = bib;
|
|
11
11
|
|
|
12
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
12
|
+
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); }
|
|
13
13
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
14
|
+
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; }
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -11,9 +11,9 @@ var features = _interopRequireWildcard(require("./features"));
|
|
|
11
11
|
|
|
12
12
|
exports.features = features;
|
|
13
13
|
|
|
14
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
14
|
+
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); }
|
|
15
15
|
|
|
16
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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
|
+
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; }
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/match-detection/index.js"],"names":["strategy","treshold","recordA","recordB","minProbabilityQuantifier","debug","debugData","extend","featuresA","extractFeatures","featuresB","JSON","stringify","featurePairs","generateFeaturePairs","similarityVector","generateSimilarityVector","some","v","probability","calculateprobability","match","reduce","acc","record","name","extract","concat","value","compared","map","a","b","compare","find","featureName","points","pairs","generatePairs","missingFeatures","findMissing","index","filter","length"],"mappings":";;;;;;;AA6BA;;AACA;;;;;;;;;;AA9BA;;AACA
|
|
1
|
+
{"version":3,"sources":["../../src/match-detection/index.js"],"names":["strategy","treshold","recordA","recordB","minProbabilityQuantifier","debug","debugData","extend","featuresA","extractFeatures","featuresB","JSON","stringify","featurePairs","generateFeaturePairs","similarityVector","generateSimilarityVector","some","v","probability","calculateprobability","match","reduce","acc","record","name","extract","concat","value","compared","map","a","b","compare","find","featureName","points","pairs","generatePairs","missingFeatures","findMissing","index","filter","length"],"mappings":";;;;;;;AA6BA;;AACA;;;;;;;;;;AA9BA;;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;AAOA;eACe,CAAC;AAACA,EAAAA,QAAD;AAAWC,EAAAA,QAAQ,GAAG;AAAtB,CAAD,KAAgC,CAACC,OAAD,EAAUC,OAAV,KAAsB;AACnE,QAAMC,wBAAwB,GAAG,GAAjC;AAEA,QAAMC,KAAK,GAAG,oBAAkB,mDAAlB,CAAd;AACA,QAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;AACA,QAAMC,SAAS,GAAGC,eAAe,CAACP,OAAD,CAAjC;AACA,QAAMQ,SAAS,GAAGD,eAAe,CAACN,OAAD,CAAjC;AAEAG,EAAAA,SAAS,CAAE,iBAAgBK,IAAI,CAACC,SAAL,CAAeJ,SAAf,CAA0B,EAA5C,CAAT;AACAF,EAAAA,SAAS,CAAE,iBAAgBK,IAAI,CAACC,SAAL,CAAeF,SAAf,CAA0B,EAA5C,CAAT;AAEA,QAAMG,YAAY,GAAGC,oBAAoB,EAAzC;AACA,QAAMC,gBAAgB,GAAGC,wBAAwB,EAAjD;;AAEA,MAAID,gBAAgB,CAACE,IAAjB,CAAsBC,CAAC,IA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AAW,CAAC;AAACQ,QAAAA;AAAD,OAAD,KAAYA,IAAI,KAAKP,CAAhC,MAAuC,KAF/C,CAAP;AAGD;AACF;AACF,C","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\n// eslint-disable-next-line max-statements\nexport default ({strategy, treshold = 0.9}) => (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 const featuresA = extractFeatures(recordA);\n const featuresB = extractFeatures(recordB);\n\n debugData(`Features (a): ${JSON.stringify(featuresA)}`);\n debugData(`Features (b): ${JSON.stringify(featuresB)}`);\n\n const featurePairs = generateFeaturePairs();\n const similarityVector = generateSimilarityVector();\n\n if (similarityVector.some(v => v >= minProbabilityQuantifier)) {\n const probability = calculateprobability();\n debug(`probability: ${probability} (Treshold: ${treshold})`);\n return {match: probability >= treshold, probability};\n }\n\n debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);\n return {match: false, probability: 0.0};\n\n function calculateprobability() {\n const probability = similarityVector.reduce((acc, v) => acc + v, 0.0);\n return probability > 1.0 ? 1.0 : probability;\n }\n\n function extractFeatures(record) {\n return strategy.reduce((acc, {name, extract}) => acc.concat({name, value: extract(record)}), []);\n }\n\n function generateSimilarityVector() {\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() {\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"],"file":"index.js"}
|
|
@@ -12,9 +12,9 @@ var features = _interopRequireWildcard(require("./features"));
|
|
|
12
12
|
|
|
13
13
|
var _ = _interopRequireDefault(require("."));
|
|
14
14
|
|
|
15
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
15
|
+
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); }
|
|
16
16
|
|
|
17
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
17
|
+
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; }
|
|
18
18
|
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/match-detection/index.spec.js"],"names":["describe","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","callback","getFixture","options","expectedResults","enabled","detect","formatOptions","recordA","MarcRecord","recordB","results","to","eql","contextFeatures","features","strategy","type","map","v"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAjCA
|
|
1
|
+
{"version":3,"sources":["../../src/match-detection/index.spec.js"],"names":["describe","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","callback","getFixture","options","expectedResults","enabled","detect","formatOptions","recordA","MarcRecord","recordB","results","to","eql","contextFeatures","features","strategy","type","map","v"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/BO,CAAR","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 '.';\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, enabled = true}) => {\n\n if (!enabled) {\n return;\n }\n\n const detect = createDetectionInterface(formatOptions());\n const recordA = new MarcRecord(getFixture('recordA.json'));\n const recordB = new MarcRecord(getFixture('recordB.json'));\n const results = detect(recordA, recordB);\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"],"file":"index.spec.js"}
|
package/dist/matching-utils.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getMelindaIdsF035 = getMelindaIdsF035;
|
|
7
|
-
exports.validateSidFieldSubfieldCounts = validateSidFieldSubfieldCounts;
|
|
8
7
|
exports.getSubfieldValues = getSubfieldValues;
|
|
8
|
+
exports.validateSidFieldSubfieldCounts = validateSidFieldSubfieldCounts;
|
|
9
9
|
|
|
10
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matching-utils.js"],"names":["debug","debugData","extend","getMelindaIdsF035","record","f035s","getFields","length","allF035MelindaIds","concat","map","toMelindaIds","f035MelindaIds","Set","JSON","stringify","subfields","melindaIdRegExp","filter","sub","includes","code","test","value","replace","validateSidFieldSubfieldCounts","field","countC","countSubfields","countB","subfieldCode","getSubfieldValues"],"mappings":";;;;;;;;;AA4BA;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../src/matching-utils.js"],"names":["debug","debugData","extend","getMelindaIdsF035","record","f035s","getFields","length","allF035MelindaIds","concat","map","toMelindaIds","f035MelindaIds","Set","JSON","stringify","subfields","melindaIdRegExp","filter","sub","includes","code","test","value","replace","validateSidFieldSubfieldCounts","field","countC","countSubfields","countB","subfieldCode","getSubfieldValues"],"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;AAIA,MAAMA,KAAK,GAAG,oBAAkB,yCAAlB,CAAd;AACA,MAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB,C,CAEA;;AACO,SAASC,iBAAT,CAA2BC,MAA3B,EAAmC;AAExC,QAAMJ,KAAK,GAAG,oBAAkB,8CAAlB,CAAd;AACA,QAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;AAEA,QAAMG,KAAK,GAAGD,MAAM,CAACE,SAAP,CAAiB,KAA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AAM,GAAGC,cAAc,CAACF,KAAD,EAAQ,GAAR,CAA7B;AACA,QAAMG,MAAM,GAAGD,cAAc,CAACF,KAAD,EAAQ,GAAR,CAA7B;AACA1B,EAAAA,KAAK,CAAE,SAAQ2B,MAAO,eAAcE,MAAO,qBAAoBF,MAAM,KAAK,CAAX,IAAgBE,MAAM,KAAK,CAAE,EAAvF,CAAL;AAEA,SAAOF,MAAM,KAAK,CAAX,IAAgBE,MAAM,KAAK,CAAlC;AACD;;AAED,SAASD,cAAT,CAAwBF,KAAxB,EAA+BI,YAA/B,EAA6C;AAC3C;AACA,SAAOJ,KAAK,CAACV,SAAN,CAAgBE,MAAhB,CAAuB,CAAC;AAACG,IAAAA;AAAD,GAAD,KAAYA,IAAI,KAAKS,YAA5C,EAA0DvB,MAAjE;AACD;;AAEM,SAASwB,iBAAT,CAA2BL,KAA3B,EAAkCI,YAAlC,EAAgD;AACrD7B,EAAAA,SAAS,CAAE,oBAAmB6B,YAAa,SAAQhB,IAAI,CAACC,SAAL,CAAeW,KAAf,CAAsB,EAAhE,CAAT;AACA,SAAOA,KAAK,CAACV,SAAN,CAAgBE,MAAhB,CAAuB,CAAC;AAACG,IAAAA;AAAD,GAAD,KAAYA,IAAI,KAAKS,YAA5C,EAA0DpB,GAA1D,CAA8D,CAAC;AAACa,IAAAA;AAAD,GAAD,KAAaA,KAA3E,CAAP;AACD","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';\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 => melindaIdRegExp.test(sub.value))\n .map(({value}) => 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.filter(({code}) => code === subfieldCode).map(({value}) => value);\n}\n\n"],"file":"matching-utils.js"}
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"url": "git@github.com:natlibfi/melinda-record-matching-js.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "LGPL-3.0+",
|
|
17
|
-
"version": "
|
|
17
|
+
"version": "2.0.0-alpha.1",
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=14"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
@@ -35,35 +35,34 @@
|
|
|
35
35
|
"watch:test": "cross-env DEBUG=1 NODE_ENV=test nodemon -w src -w test-fixtures --exec 'npm run test:dev'"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@natlibfi/marc-record": "^
|
|
39
|
-
"@natlibfi/marc-record-serializers": "^
|
|
40
|
-
"@natlibfi/sru-client": "^4.
|
|
41
|
-
"debug": "^4.
|
|
42
|
-
"moment": "^2.
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"uuid": "^8.3.0",
|
|
38
|
+
"@natlibfi/marc-record": "^7.0.0-alpha.1",
|
|
39
|
+
"@natlibfi/marc-record-serializers": "^8.0.4",
|
|
40
|
+
"@natlibfi/sru-client": "^4.1.0",
|
|
41
|
+
"debug": "^4.3.2",
|
|
42
|
+
"moment": "^2.29.1",
|
|
43
|
+
"natural": "^5.1.11",
|
|
44
|
+
"uuid": "^8.3.2",
|
|
46
45
|
"winston": "^3.3.3"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@babel/cli": "^7.
|
|
50
|
-
"@babel/core": "^7.
|
|
51
|
-
"@babel/node": "^7.
|
|
52
|
-
"@babel/preset-env": "^7.
|
|
53
|
-
"@babel/register": "^7.
|
|
54
|
-
"@natlibfi/eslint-config-melinda-backend": "^1.
|
|
55
|
-
"@natlibfi/fixugen": "^1.0.
|
|
56
|
-
"@natlibfi/fixugen-http-client": "^1.1.
|
|
57
|
-
"@natlibfi/fixura": "^2.1
|
|
58
|
-
"babel-
|
|
59
|
-
"babel-plugin-istanbul": "^6.
|
|
48
|
+
"@babel/cli": "^7.16.0",
|
|
49
|
+
"@babel/core": "^7.16.0",
|
|
50
|
+
"@babel/node": "^7.16.0",
|
|
51
|
+
"@babel/preset-env": "^7.16.4",
|
|
52
|
+
"@babel/register": "^7.16.0",
|
|
53
|
+
"@natlibfi/eslint-config-melinda-backend": "^1.1.1",
|
|
54
|
+
"@natlibfi/fixugen": "^1.0.2",
|
|
55
|
+
"@natlibfi/fixugen-http-client": "^1.1.3",
|
|
56
|
+
"@natlibfi/fixura": "^2.2.1",
|
|
57
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
58
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
60
59
|
"babel-plugin-rewire": "^1.2.0",
|
|
61
|
-
"chai": "^4.
|
|
60
|
+
"chai": "^4.3.4",
|
|
62
61
|
"chai-as-promised": "^7.1.1",
|
|
63
|
-
"cross-env": "^7.0.
|
|
64
|
-
"eslint": "^7.
|
|
65
|
-
"mocha": "^
|
|
66
|
-
"nodemon": "^2.0.
|
|
62
|
+
"cross-env": "^7.0.3",
|
|
63
|
+
"eslint": "^7.32.0",
|
|
64
|
+
"mocha": "^9.1.3",
|
|
65
|
+
"nodemon": "^2.0.15",
|
|
67
66
|
"nyc": "^15.1.0"
|
|
68
67
|
},
|
|
69
68
|
"eslintConfig": {
|
|
@@ -74,9 +73,7 @@
|
|
|
74
73
|
[
|
|
75
74
|
"@babel/preset-env",
|
|
76
75
|
{
|
|
77
|
-
"targets":
|
|
78
|
-
"node": "12"
|
|
79
|
-
}
|
|
76
|
+
"targets": "maintained node versions"
|
|
80
77
|
}
|
|
81
78
|
]
|
|
82
79
|
],
|
|
@@ -33,8 +33,10 @@ export function toQueries(identifiers, queryString) {
|
|
|
33
33
|
const debug = createDebugLogger('@natlibfi/melinda-record-matching:toQueries');
|
|
34
34
|
const debugData = debug.extend('data');
|
|
35
35
|
|
|
36
|
+
const quotedIdentifiers = identifiers.map(identifier => identifier.match(/\//u) ? `"${identifier}"` : `${identifier}`);
|
|
37
|
+
|
|
36
38
|
// Aleph supports only two queries with or -operator (This is not actually true)
|
|
37
|
-
const pairs = toPairs(
|
|
39
|
+
const pairs = toPairs(quotedIdentifiers);
|
|
38
40
|
const queries = pairs.map(([a, b]) => b ? `${queryString}=${a} or ${queryString}=${b}` : `${queryString}=${a}`);
|
|
39
41
|
|
|
40
42
|
debugData(`Pairs (${pairs.length}): ${JSON.stringify(pairs)}`);
|