@natlibfi/melinda-record-matching 1.0.6 → 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 +58 -0
- package/dist/candidate-search/candidate-search-utils.js.map +1 -0
- package/dist/candidate-search/index.js +4 -4
- package/dist/candidate-search/index.js.map +1 -1
- package/dist/candidate-search/index.spec.js +94 -86
- package/dist/candidate-search/index.spec.js.map +1 -1
- package/dist/candidate-search/query-list/bib.js +103 -20
- package/dist/candidate-search/query-list/bib.js.map +1 -1
- package/dist/candidate-search/query-list/bib.spec.js +25 -23
- package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
- package/dist/candidate-search/query-list/index.js +6 -4
- 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 +53 -46
- package/dist/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/all-source-ids.js +122 -0
- package/dist/match-detection/features/bib/all-source-ids.js.map +1 -0
- 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 +32 -16
- package/dist/match-detection/features/bib/index.js.map +1 -1
- package/dist/match-detection/features/bib/index.spec.js +50 -42
- 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 +42 -5
- package/dist/match-detection/features/bib/language.js.map +1 -1
- package/dist/match-detection/features/bib/melinda-id.js +52 -0
- package/dist/match-detection/features/bib/melinda-id.js.map +1 -0
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +100 -0
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -0
- 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 +8 -0
- 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 +10 -6
- package/dist/match-detection/index.js.map +1 -1
- package/dist/match-detection/index.spec.js +32 -25
- package/dist/match-detection/index.spec.js.map +1 -1
- package/dist/matching-utils.js +95 -0
- package/dist/matching-utils.js.map +1 -0
- package/package.json +26 -29
- package/src/candidate-search/candidate-search-utils.js +53 -0
- package/src/candidate-search/index.js +1 -1
- package/src/candidate-search/index.spec.js +64 -58
- package/src/candidate-search/query-list/bib.js +120 -19
- package/src/candidate-search/query-list/bib.spec.js +16 -14
- package/src/candidate-search/query-list/index.js +3 -1
- package/src/index.spec.js +46 -39
- package/src/match-detection/features/bib/all-source-ids.js +122 -0
- package/src/match-detection/features/bib/index.js +2 -0
- package/src/match-detection/features/bib/index.spec.js +32 -23
- package/src/match-detection/features/bib/language.js +37 -3
- package/src/match-detection/features/bib/melinda-id.js +34 -0
- package/src/match-detection/features/bib/melinda-identifier-factory.js +94 -0
- package/src/match-detection/features/bib/standard-identifier-factory.js +6 -0
- package/src/match-detection/index.js +7 -4
- package/src/match-detection/index.spec.js +27 -20
- package/src/matching-utils.js +86 -0
|
@@ -10,9 +10,9 @@ var _marcRecord = require("@natlibfi/marc-record");
|
|
|
10
10
|
|
|
11
11
|
var generators = _interopRequireWildcard(require("./bib"));
|
|
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
|
|
|
@@ -43,28 +43,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
43
43
|
* for the JavaScript code in this file.
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
describe('candidate-search/query-list/bib/', () => {
|
|
47
|
+
(0, _fixugen.default)({
|
|
48
|
+
path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
|
|
49
|
+
useMetadataFile: true,
|
|
50
|
+
fixura: {
|
|
51
|
+
reader: _fixura.READERS.JSON
|
|
52
|
+
},
|
|
53
|
+
callback: ({
|
|
54
|
+
type,
|
|
55
|
+
inputRecord,
|
|
56
|
+
expectedQuery,
|
|
57
|
+
enabled = true
|
|
58
|
+
}) => {
|
|
59
|
+
const generate = generators[type];
|
|
60
|
+
const record = new _marcRecord.MarcRecord(inputRecord, {
|
|
61
|
+
subfieldValues: false
|
|
62
|
+
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (!enabled) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
(0, _chai.expect)(generate(record)).to.eql(expectedQuery);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
69
71
|
});
|
|
70
72
|
//# sourceMappingURL=bib.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/candidate-search/query-list/bib.spec.js"],"names":["path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","generators","record","MarcRecord","subfieldValues","to","eql"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA
|
|
1
|
+
{"version":3,"sources":["../../../src/candidate-search/query-list/bib.spec.js"],"names":["describe","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","generators","record","MarcRecord","subfieldValues","to","eql"],"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;AAQAA,QAAQ,CAAC,kCAAD,EAAqC,MAAM;AACjD,wBAAc;AACZC,IAAAA,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,IAAxB,EAA8B,eAA9B,EAA+C,kBAA/C,EAAmE,YAAnE,EAAiF,KAAjF,CADM;AAEZC,IAAAA,eAAe,EAAE,IAFL;AAGZC,IAAAA,MAAM,EAAE;AACNC,MAAAA,MAAM,EAAEC,gBAAQC;AADV,KAHI;AAMZC,IAAAA,QAAQ,EAAE,CAAC;AAACC,MAAAA,IAAD;AAAOC,MAAAA,WAAP;AAAoBC,MAAAA,aAApB;AAAmCC,MAAAA,OAAO,GAAG;AAA7C,KAAD,KAAwD;AAChE,YAAMC,QAAQ,GAAGC,UAAU,CAACL,IAAD,CAA3B;AACA,YAAMM,MAAM,GAAG,IAAIC,sBAAJ,CAAeN,WAAf,EAA4B;AAACO,QAAAA,cAAc,EAAE;AAAjB,OAA5B,CAAf;;AAEA,UAAI,CAACL,OAAL,EAAc;AACZ;AACD;;AAED,wBAAOC,QAAQ,CAACE,MAAD,CAAf,EAAyBG,EAAzB,CAA4BC,GAA5B,CAAgCR,aAAhC;AACD;AAfW,GAAd;AAiBD,CAlBO,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 generators from './bib';\n\ndescribe('candidate-search/query-list/bib/', () => {\n generateTests({\n path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({type, inputRecord, expectedQuery, enabled = true}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n if (!enabled) {\n return;\n }\n\n expect(generate(record)).to.eql(expectedQuery);\n }\n });\n});\n"],"file":"bib.spec.js"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.searchTypes = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var bib = _interopRequireWildcard(require("./bib"));
|
|
9
9
|
|
|
10
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
|
|
12
|
-
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; }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
@@ -42,7 +42,9 @@ const searchTypes = {
|
|
|
42
42
|
bib: {
|
|
43
43
|
standardIdentifiers: 'bibStandardIdentifiers',
|
|
44
44
|
hostComponents: 'bibHostComponents',
|
|
45
|
-
title: 'bibTitle'
|
|
45
|
+
title: 'bibTitle',
|
|
46
|
+
melindaId: 'bibMelindaIds',
|
|
47
|
+
sourceIds: 'bibSourceIds'
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
exports.searchTypes = searchTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/candidate-search/query-list/index.js"],"names":["searchTypes","bib","standardIdentifiers","hostComponents","title","record","searchSpec","extractors","map","generateQueryExtractor","cb","flat","type","Error"],"mappings":";;;;;;;AA4BA;;;;;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../src/candidate-search/query-list/index.js"],"names":["searchTypes","bib","standardIdentifiers","hostComponents","title","melindaId","sourceIds","record","searchSpec","extractors","map","generateQueryExtractor","cb","flat","type","Error"],"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;AAIO,MAAMA,WAAW,GAAG;AACzBC,EAAAA,GAAG,EAAE;AACHC,IAAAA,mBAAmB,EAAE,wBADlB;AAEHC,IAAAA,cAAc,EAAE,mBAFb;AAGHC,IAAAA,KAAK,EAAE,UAHJ;AAIHC,IAAAA,SAAS,EAAE,eAJR;AAKHC,IAAAA,SAAS,EAAE;AALR;AADoB,CAApB;;;eAUQ,CAACC,MAAD,EAASC,UAAT,KAAwB;AACrC,QAAMC,UAAU,GAAG,EAAC,GAAGR;AAAJ,GAAnB;AAEA,SAAOO,UAAU,CACdE,GADI,CACAC,sBADA,EAEJD,GAFI,CAEAE,EAAE,IAAIA,EAAE,CAACL,MAAD,CAFR,EAGJM,IAHI,EAAP;;AAKA,WAASF,sBAAT,CAAgCG,IAAhC,EAAsC;AACpC,QAAIL,UAAU,CAACK,IAAD,CAAd,EAAsB;AACpB,aAAOL,UAAU,CAACK,IAAD,CAAjB;AACD;;AAED,UAAM,IAAIC,KAAJ,CAAW,wBAAuBD,IAAK,EAAvC,CAAN;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 * as bib from './bib';\n\nexport const searchTypes = {\n bib: {\n standardIdentifiers: 'bibStandardIdentifiers',\n hostComponents: 'bibHostComponents',\n title: 'bibTitle',\n melindaId: 'bibMelindaIds',\n sourceIds: 'bibSourceIds'\n }\n};\n\nexport default (record, searchSpec) => {\n const extractors = {...bib};\n\n return searchSpec\n .map(generateQueryExtractor)\n .map(cb => cb(record))\n .flat();\n\n function generateQueryExtractor(type) {\n if (extractors[type]) {\n return extractors[type];\n }\n\n throw new Error(`Unknown search type: ${type}`);\n }\n};\n"],"file":"index.js"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.matchDetection = exports.
|
|
6
|
+
exports.matchDetection = exports.default = exports.candidateSearch = void 0;
|
|
7
7
|
|
|
8
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
9
|
|
|
@@ -15,9 +15,9 @@ var matchDetection = _interopRequireWildcard(require("./match-detection"));
|
|
|
15
15
|
|
|
16
16
|
exports.matchDetection = matchDetection;
|
|
17
17
|
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
18
|
+
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); }
|
|
19
19
|
|
|
20
|
-
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; }
|
|
20
|
+
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; }
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["detection","detectionOptions","search","searchOptions","maxMatches","maxCandidates","debug","detect","record","iterate","initialState","matches","candidateCount","records","state","length","queriesLeft","matchResult","iterateRecords","newMatches","concat","maxCandidatesRetrieved","candidate","candidateRecord","id","candidateId","match","probability","slice"],"mappings":";;;;;;;AA4BA;;AACA;;;;AACA;;;;;;;;;;AA9BA
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["detection","detectionOptions","search","searchOptions","maxMatches","maxCandidates","debug","detect","record","iterate","initialState","matches","candidateCount","records","state","length","queriesLeft","matchResult","iterateRecords","newMatches","concat","maxCandidatesRetrieved","candidate","candidateRecord","id","candidateId","match","probability","slice"],"mappings":";;;;;;;AA4BA;;AACA;;;;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;eAQe,CAAC;AAACA,EAAAA,SAAS,EAAEC,gBAAZ;AAA8BC,EAAAA,MAAM,EAAEC,aAAtC;AAAqDC,EAAAA,UAAU,GAAG,CAAlE;AAAqEC,EAAAA,aAAa,GAAG;AAArF,CAAD,KAA8F;AAC3G,QAAMC,KAAK,GAAG,oBAAkB,yCAAlB,CAAd;AACA,QAAMC,MAAM,GAAG,4BAAyBN,gBAAzB,CAAf;AAEA,SAAOO,MAAM,IAAI;AACf,UAAMN,MAAM,GAAG,6BAAsB,EAAC,GAAGC,aAAJ;AAAmBK,MAAAA;AAAnB,KAAtB,CAAf;AACA,WAAOC,OAAO,EAAd,CAFe,CAIf;;AACA,mBAAeA,OAAf,CAAuBC,YAAY,GAAG,EAAtC,EAA0CC,OAAO,GAAG,EAApD,EAAwDC,cAAc,GAAG,CAAzE,EAA4E;AAC1E,YAAM;AAACC,QAAAA,OAAD;AAAU,WAAGC;AAAb,UAAsB,MAAMZ,MAAM,CAACQ,YAAD,CAAxC;;AAEA,UAAIG,OAAO,CAACE,MAAR,GAAiB,CAAjB,IAAsBD,KAAK,CAACE,WAAN,GAAoB,CAA9C,EAAiD;AAC/CV,QAAAA,KAAK,CAAE,YAAWO,OAAO,CAACE,MAAO,yBAA5B,CAAL;AAEA,cAAME,WAAW,GAAGC,cAAc,CAACL,OAAD,CAAlC;;AAEA,YAAII,WAAJ,EAAiB;AACf,gBAAME,UAAU,GAAGR,OAAO,CAACS,MAAR,CAAeH,WAAf,CAAnB;;AAEA,cAAIE,UAAU,CAACJ,MAAX,KAAsBX,UAA1B,EAAsC;AACpC,mBAAOe,UAAP;AACD;;AAED,iBAAOE,sBAAsB,KAAKF,UAAL,GAAkBV,OAAO,CAACK,KAAD,EAAQK,UAAR,EAAoBP,cAAc,GAAGC,OAAO,CAACE,MAA7C,CAAtD;AACD;;AAED,eAAOM,sBAAsB,KAAKV,OAAL,GAAeF,OAAO,CAACK,KAAD,EAAQH,OAAR,EAAiBC,cAAc,GAAGC,OAAO,CAACE,MAA1C,CAAnD;AACD;;AAEDT,MAAAA,KAAK,CAAE,kDAAiDK,OAAO,CAACI,MAAO,EAAlE,CAAL;AACA,aAAOJ,OAAP;;AAEA,eAASU,sBAAT,GAAkC;AAChC,YAAIT,cAAc,GAAGC,OAAO,CAACE,MAAzB,GAAkCV,aAAtC,EAAqD;AACnDC,UAAAA,KAAK,CAAE,4EAAF,CAAL;AACA,iBAAO,IAAP;AACD;AACF;;AAED,eAASY,cAAT,CAAwBL,OAAxB,EAAiC;AAC/B,cAAM,CAACS,SAAD,IAAcT,OAApB;;AAEA,YAAIS,SAAJ,EAAe;AACb,gBAAM;AAACd,YAAAA,MAAM,EAAEe,eAAT;AAA0BC,YAAAA,EAAE,EAAEC;AAA9B,cAA6CH,SAAnD;AACA,gBAAM;AAACI,YAAAA,KAAD;AAAQC,YAAAA;AAAR,cAAuBpB,MAAM,CAACC,MAAD,EAASe,eAAT,CAAnC;;AAEA,cAAIG,KAAJ,EAAW;AACT,mBAAO;AACLC,cAAAA,WADK;AAELL,cAAAA,SAAS,EAAE;AACTE,gBAAAA,EAAE,EAAEC,WADK;AAETjB,gBAAAA,MAAM,EAAEe;AAFC;AAFN,aAAP;AAOD;;AAED,iBAAOL,cAAc,CAACL,OAAO,CAACe,KAAR,CAAc,CAAd,CAAD,CAArB;AACD;AACF;AACF;AACF,GAzDD;AA0DD,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 createSearchInterface, * as candidateSearch from './candidate-search';\nimport createDetectionInterface, * as matchDetection from './match-detection';\n\nexport {candidateSearch, matchDetection};\n\nexport default ({detection: detectionOptions, search: searchOptions, maxMatches = 1, maxCandidates = 25}) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:index');\n const detect = createDetectionInterface(detectionOptions);\n\n return record => {\n const search = createSearchInterface({...searchOptions, record});\n return iterate();\n\n // eslint-disable-next-line max-statements\n async function iterate(initialState = {}, matches = [], candidateCount = 0) {\n const {records, ...state} = await search(initialState);\n\n if (records.length > 0 || state.queriesLeft > 0) {\n debug(`Checking ${records.length} candidates for matches`);\n\n const matchResult = iterateRecords(records);\n\n if (matchResult) {\n const newMatches = matches.concat(matchResult);\n\n if (newMatches.length === maxMatches) {\n return newMatches;\n }\n\n return maxCandidatesRetrieved() ? newMatches : iterate(state, newMatches, candidateCount + records.length);\n }\n\n return maxCandidatesRetrieved() ? matches : iterate(state, matches, candidateCount + records.length);\n }\n\n debug(`No (more) candidate records to check, matches: ${matches.length}`);\n return matches;\n\n function maxCandidatesRetrieved() {\n if (candidateCount + records.length > maxCandidates) {\n debug(`Stopped searching because maximum number of candidates have been retrieved`);\n return true;\n }\n }\n\n function iterateRecords(records) {\n const [candidate] = records;\n\n if (candidate) {\n const {record: candidateRecord, id: candidateId} = candidate;\n const {match, probability} = detect(record, candidateRecord);\n\n if (match) {\n return {\n probability,\n candidate: {\n id: candidateId,\n record: candidateRecord\n }\n };\n }\n\n return iterateRecords(records.slice(1));\n }\n }\n }\n };\n};\n"],"file":"index.js"}
|
package/dist/index.spec.js
CHANGED
|
@@ -10,9 +10,9 @@ var _marcRecord = require("@natlibfi/marc-record");
|
|
|
10
10
|
|
|
11
11
|
var _ = _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
|
|
|
@@ -43,52 +43,59 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
43
43
|
* for the JavaScript code in this file.
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function callback({
|
|
56
|
-
getFixture,
|
|
57
|
-
options
|
|
58
|
-
}) {
|
|
59
|
-
const record = new _marcRecord.MarcRecord(getFixture('inputRecord.json'), {
|
|
60
|
-
subfieldValues: false
|
|
46
|
+
describe('INDEX', () => {
|
|
47
|
+
(0, _fixugenHttpClient.default)({
|
|
48
|
+
callback,
|
|
49
|
+
path: [__dirname, '..', 'test-fixtures', 'index'],
|
|
50
|
+
recurse: false,
|
|
51
|
+
fixura: {
|
|
52
|
+
reader: _fixura.READERS.JSON
|
|
53
|
+
}
|
|
61
54
|
});
|
|
62
|
-
const expectedMatches = getFixture('expectedMatches.json');
|
|
63
|
-
const match = (0, _.default)(formatOptions());
|
|
64
|
-
const matches = await match(record);
|
|
65
|
-
(0, _chai.expect)(formatResults()).to.eql(expectedMatches);
|
|
66
55
|
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
maxMatches: 2,
|
|
77
|
-
maxCandidates: 1
|
|
78
|
-
};
|
|
79
|
-
}
|
|
56
|
+
async function callback({
|
|
57
|
+
getFixture,
|
|
58
|
+
options,
|
|
59
|
+
enabled = true
|
|
60
|
+
}) {
|
|
61
|
+
if (!enabled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
80
64
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
65
|
+
const record = new _marcRecord.MarcRecord(getFixture('inputRecord.json'), {
|
|
66
|
+
subfieldValues: false
|
|
67
|
+
});
|
|
68
|
+
const expectedMatches = getFixture('expectedMatches.json');
|
|
69
|
+
const match = (0, _.default)(formatOptions());
|
|
70
|
+
const matches = await match(record);
|
|
71
|
+
(0, _chai.expect)(formatResults()).to.eql(expectedMatches);
|
|
72
|
+
|
|
73
|
+
function formatOptions() {
|
|
74
|
+
const contextFeatures = _.matchDetection.features[options.detection.strategy.type];
|
|
75
|
+
return { ...options,
|
|
76
|
+
search: { ...options.search,
|
|
77
|
+
maxRecordsPerRequest: 1
|
|
78
|
+
},
|
|
79
|
+
detection: { ...options.detect,
|
|
80
|
+
strategy: options.detection.strategy.features.map(v => contextFeatures[v]())
|
|
81
|
+
},
|
|
82
|
+
maxMatches: 2,
|
|
83
|
+
maxCandidates: 1
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function formatResults() {
|
|
88
|
+
return matches.map(({
|
|
89
|
+
candidate,
|
|
90
|
+
probability
|
|
91
|
+
}) => ({
|
|
92
|
+
probability,
|
|
93
|
+
candidate: {
|
|
94
|
+
id: candidate.id,
|
|
95
|
+
record: candidate.record.toObject()
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
92
99
|
}
|
|
93
|
-
}
|
|
100
|
+
});
|
|
94
101
|
//# sourceMappingURL=index.spec.js.map
|
package/dist/index.spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.spec.js"],"names":["callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","record","MarcRecord","subfieldValues","expectedMatches","match","formatOptions","matches","formatResults","to","eql","contextFeatures","matchDetection","features","detection","strategy","type","search","maxRecordsPerRequest","detect","map","v","maxMatches","maxCandidates","candidate","probability","id","toObject"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA
|
|
1
|
+
{"version":3,"sources":["../src/index.spec.js"],"names":["describe","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","enabled","record","MarcRecord","subfieldValues","expectedMatches","match","formatOptions","matches","formatResults","to","eql","contextFeatures","matchDetection","features","detection","strategy","type","search","maxRecordsPerRequest","detect","map","v","maxMatches","maxCandidates","candidate","probability","id","toObject"],"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;AAQAA,QAAQ,CAAC,OAAD,EAAU,MAAM;AACtB,kCAAc;AACZC,IAAAA,QADY;AAEZC,IAAAA,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,eAAlB,EAAmC,OAAnC,CAFM;AAGZC,IAAAA,OAAO,EAAE,KAHG;AAIZC,IAAAA,MAAM,EAAE;AACNC,MAAAA,MAAM,EAAEC,gBAAQC;AADV;AAJI,GAAd;;AASA,iBAAeP,QAAf,CAAwB;AAACQ,IAAAA,UAAD;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,OAAO,GAAG;AAAhC,GAAxB,EAA+D;AAE7D,QAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,UAAMC,MAAM,GAAG,IAAIC,sBAAJ,CAAeJ,UAAU,CAAC,kBAAD,CAAzB,EAA+C;AAACK,MAAAA,cAAc,EAAE;AAAjB,KAA/C,CAAf;AACA,UAAMC,eAAe,GAAGN,UAAU,CAAC,sBAAD,CAAlC;AAEA,UAAMO,KAAK,GAAG,eAAqBC,aAAa,EAAlC,CAAd;AACA,UAAMC,OAAO,GAAG,MAAMF,KAAK,CAACJ,MAAD,CAA3B;AAEA,sBAAOO,aAAa,EAApB,EAAwBC,EAAxB,CAA2BC,GAA3B,CAA+BN,eAA/B;;AAEA,aAASE,aAAT,GAAyB;AACvB,YAAMK,eAAe,GAAGC,iBAAeC,QAAf,CAAwBd,OAAO,CAACe,SAAR,CAAkBC,QAAlB,CAA2BC,IAAnD,CAAxB;AAEA,aAAO,EACL,GAAGjB,OADE;AAELkB,QAAAA,MAAM,EAAE,EACN,GAAGlB,OAAO,CAACkB,MADL;AAENC,UAAAA,oBAAoB,EAAE;AAFhB,SAFH;AAMLJ,QAAAA,SAAS,EAAE,EACT,GAAGf,OAAO,CAACoB,MADF;AAETJ,UAAAA,QAAQ,EAAEhB,OAAO,CAACe,SAAR,CAAkBC,QAAlB,CAA2BF,QAA3B,CAAoCO,GAApC,CAAwCC,CAAC,IAAIV,eAAe,CAACU,CAAD,CAAf,EAA7C;AAFD,SANN;AAULC,QAAAA,UAAU,EAAE,CAVP;AAWLC,QAAAA,aAAa,EAAE;AAXV,OAAP;AAaD;;AAED,aAASf,aAAT,GAAyB;AACvB,aAAOD,OAAO,CAACa,GAAR,CAAY,CAAC;AAACI,QAAAA,SAAD;AAAYC,QAAAA;AAAZ,OAAD,MAA+B;AAChDA,QAAAA,WADgD;AAEhDD,QAAAA,SAAS,EAAE;AACTE,UAAAA,EAAE,EAAEF,SAAS,CAACE,EADL;AAETzB,UAAAA,MAAM,EAAEuB,SAAS,CAACvB,MAAV,CAAiB0B,QAAjB;AAFC;AAFqC,OAA/B,CAAZ,CAAP;AAOD;AACF;AACF,CApDO,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 {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createMatchInterface, {matchDetection} from '.';\n\ndescribe('INDEX', () => {\n generateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'index'],\n recurse: false,\n fixura: {\n reader: READERS.JSON\n }\n });\n\n async function callback({getFixture, options, enabled = true}) {\n\n if (!enabled) {\n return;\n }\n\n const record = new MarcRecord(getFixture('inputRecord.json'), {subfieldValues: false});\n const expectedMatches = getFixture('expectedMatches.json');\n\n const match = createMatchInterface(formatOptions());\n const matches = await match(record);\n\n expect(formatResults()).to.eql(expectedMatches);\n\n function formatOptions() {\n const contextFeatures = matchDetection.features[options.detection.strategy.type];\n\n return {\n ...options,\n search: {\n ...options.search,\n maxRecordsPerRequest: 1\n },\n detection: {\n ...options.detect,\n strategy: options.detection.strategy.features.map(v => contextFeatures[v]())\n },\n maxMatches: 2,\n maxCandidates: 1\n };\n }\n\n function formatResults() {\n return matches.map(({candidate, probability}) => ({\n probability,\n candidate: {\n id: candidate.id,\n record: candidate.record.toObject()\n }\n }));\n }\n }\n});\n"],"file":"index.spec.js"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
/* eslint-disable max-statements */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
19
|
+
*
|
|
20
|
+
* Melinda record matching modules for Javascript
|
|
21
|
+
*
|
|
22
|
+
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
23
|
+
*
|
|
24
|
+
* This file is part of melinda-record-matching-js
|
|
25
|
+
*
|
|
26
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
27
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
28
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
29
|
+
* License, or (at your option) any later version.
|
|
30
|
+
*
|
|
31
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
32
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
33
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
34
|
+
* GNU Lesser General Public License for more details.
|
|
35
|
+
*
|
|
36
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
37
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
38
|
+
*
|
|
39
|
+
* @licend The above is the entire license notice
|
|
40
|
+
* for the JavaScript code in this file.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');
|
|
44
|
+
const debugData = debug.extend('data');
|
|
45
|
+
/*
|
|
46
|
+
|
|
47
|
+
SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
|
|
48
|
+
|
|
49
|
+
SID__ $c 123457 $b helka
|
|
50
|
+
SID__ $c (ANDL100020)1077305 $b sata
|
|
51
|
+
SID__ $c VER999999 $ FI-KV
|
|
52
|
+
|
|
53
|
+
allSourceIds matching feature is formatted as [{sourceDb: "helka", sourceId: "123457"}, {sourceDb: "sata", sourceId: "(ANDL100020)1077305"}, {sourceDb: "FI-KV", sourceId: "VER999999"}]
|
|
54
|
+
- no normalization / prefix deletions etc. in the feature
|
|
55
|
+
|
|
56
|
+
Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,
|
|
57
|
+
existence of a SID field depends on how the record has been added to Melinda and how it has been handled
|
|
58
|
+
afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
|
|
59
|
+
after the matching record is removed from the local db.
|
|
60
|
+
|
|
61
|
+
Records with mismatching local ids for matching local db are a strong mismatch.
|
|
62
|
+
Records with matching local ids for matching local db are a very good match.
|
|
63
|
+
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
var _default = () => ({
|
|
67
|
+
name: 'All source IDs',
|
|
68
|
+
extract: record => {
|
|
69
|
+
debug(`Creating match detection features for all local source id's`);
|
|
70
|
+
const fSids = record.get('SID');
|
|
71
|
+
debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
|
|
72
|
+
const sidFeatures = getSidFeatures(fSids);
|
|
73
|
+
debugData(`SID-features (${sidFeatures.length}): ${JSON.stringify(sidFeatures)}`);
|
|
74
|
+
return sidFeatures;
|
|
75
|
+
|
|
76
|
+
function getSidFeatures(fSids) {
|
|
77
|
+
debug(`Getting Sid strings from SID fields`); // Map SID fields to sidFeatures, filter out empty strings
|
|
78
|
+
|
|
79
|
+
const sidFeatures = fSids.map(toSidFeature).filter(nonEmptySid => nonEmptySid);
|
|
80
|
+
return sidFeatures;
|
|
81
|
+
|
|
82
|
+
function toSidFeature(field) {
|
|
83
|
+
debug(`Getting feature from a field`);
|
|
84
|
+
return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidFeature(field) : '';
|
|
85
|
+
|
|
86
|
+
function createSidFeature(field) {
|
|
87
|
+
debug(`Creating feature from a field`);
|
|
88
|
+
const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
|
|
89
|
+
const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
|
|
90
|
+
debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
|
|
91
|
+
debugData(`sourceDb: ${sfB}, sourceId: ${sfC}`);
|
|
92
|
+
return {
|
|
93
|
+
'sourceDb': sfB,
|
|
94
|
+
'sourceId': sfC
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
compare: (a, b) => {
|
|
101
|
+
debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
|
|
102
|
+
const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId === sidB.sourceId));
|
|
103
|
+
debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);
|
|
104
|
+
const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId !== sidB.sourceId));
|
|
105
|
+
debugData(`Mismatches (${mismatches.length}): ${JSON.stringify(mismatches)}`); // If there's at least one mismatching source ID from matching source db
|
|
106
|
+
|
|
107
|
+
if (mismatches.length > 0) {
|
|
108
|
+
return -1;
|
|
109
|
+
} // If there's at least one matching source ID from matching source db
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if (matches.length > 0) {
|
|
113
|
+
return 1;
|
|
114
|
+
} // If there are no source IDs with matching sources
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
exports.default = _default;
|
|
122
|
+
//# sourceMappingURL=all-source-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/all-source-ids.js"],"names":["debug","debugData","extend","name","extract","record","fSids","get","length","JSON","stringify","sidFeatures","getSidFeatures","map","toSidFeature","filter","nonEmptySid","field","createSidFeature","sfC","sfB","compare","a","b","matches","sidA","some","sidB","sourceDb","sourceId","mismatches"],"mappings":"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","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';\nimport {validateSidFieldSubfieldCounts, getSubfieldValues} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');\nconst debugData = debug.extend('data');\n\n/*\n\nSID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:\n\n SID__ $c 123457 $b helka\n SID__ $c (ANDL100020)1077305 $b sata\n SID__ $c VER999999 $ FI-KV\n\nallSourceIds matching feature is formatted as [{sourceDb: \"helka\", sourceId: \"123457\"}, {sourceDb: \"sata\", sourceId: \"(ANDL100020)1077305\"}, {sourceDb: \"FI-KV\", sourceId: \"VER999999\"}]\n- no normalization / prefix deletions etc. in the feature\n\nNote: All Melinda records that have a matching records in a local db do NOT have SID for that local records,\n existence of a SID field depends on how the record has been added to Melinda and how it has been handled\n afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db\n after the matching record is removed from the local db.\n\nRecords with mismatching local ids for matching local db are a strong mismatch.\nRecords with matching local ids for matching local db are a very good match.\n\n*/\n\nexport default () => ({\n name: 'All source IDs',\n extract: record => {\n debug(`Creating match detection features for all local source id's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n const sidFeatures = getSidFeatures(fSids);\n debugData(`SID-features (${sidFeatures.length}): ${JSON.stringify(sidFeatures)}`);\n\n return sidFeatures;\n\n function getSidFeatures(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to sidFeatures, filter out empty strings\n const sidFeatures = fSids.map(toSidFeature).filter(nonEmptySid => nonEmptySid);\n return sidFeatures;\n\n function toSidFeature(field) {\n debug(`Getting feature from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidFeature(field) : '';\n\n function createSidFeature(field) {\n debug(`Creating feature from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n debugData(`sourceDb: ${sfB}, sourceId: ${sfC}`);\n return {'sourceDb': sfB, 'sourceId': sfC};\n }\n }\n\n }\n\n },\n compare: (a, b) => {\n\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&\n sidA.sourceId === sidB.sourceId));\n debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);\n\n const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&\n sidA.sourceId !== sidB.sourceId));\n debugData(`Mismatches (${mismatches.length}): ${JSON.stringify(mismatches)}`);\n\n // If there's at least one mismatching source ID from matching source db\n if (mismatches.length > 0) {\n return -1;\n }\n\n // If there's at least one matching source ID from matching source db\n if (matches.length > 0) {\n return 1;\n }\n\n // If there are no source IDs with matching sources\n return 0;\n\n }\n});\n"],"file":"all-source-ids.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/authors.js"],"names":["nameTreshold","name","extract","record","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue"],"mappings":";;;;;;;AA4BA;;AA5BA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/authors.js"],"names":["nameTreshold","name","extract","record","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue"],"mappings":"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","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 {LevenshteinDistance as leven} from 'natural';\n\nexport default ({nameTreshold = 10} = {}) => ({\n name: 'Authors',\n extract: record => record.get(/^(?<def>100|700)$/u)\n .map(({subfields}) => {\n return subfields\n .filter(({code, value}) => code && value)\n .filter(({code}) => ['a', '0'].includes(code))\n .map(toObj)\n .reduce((acc, v) => ({...acc, ...v}), {});\n\n function toObj({code, value}) {\n if (code === 'a') {\n return {name: value.replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase()};\n }\n\n return {id: value};\n }\n }),\n compare: (a, b) => {\n const maxAuthors = a.length > b.length ? a.length : b.length;\n const matchingIds = findMatchingIds();\n\n if (maxAuthors >= 3 && matchingIds >= 3) {\n return 0.3;\n }\n\n const matchingNames = findMatchingNames();\n const idPoints = matchingIds / maxAuthors * 0.3;\n const namePoints = matchingNames / maxAuthors * 0.2;\n const totalPoints = idPoints + namePoints;\n\n return totalPoints <= 0.2 ? totalPoints : 0.2;\n\n function findMatchingIds() {\n return findMatches('id', (a, b) => a === b);\n }\n\n function findMatchingNames() {\n return findMatches('name', (a, b) => {\n const distance = leven(a, b);\n\n if (distance === 0) {\n return true;\n }\n\n const maxLength = getMaxLength();\n const percentage = distance / maxLength * 100;\n\n return percentage <= nameTreshold;\n\n function getMaxLength() {\n return a.length > b.length ? a.length : b.length;\n }\n });\n }\n\n function findMatches(key, cb) {\n const valuesA = a.filter(o => o[key]).map(o => o[key]);\n const valuesB = b.filter(o => o[key]).map(o => o[key]);\n const allValues = valuesA.concat(valuesB);\n\n return allValues.reduce((acc, value) => {\n const occurrance = allValues.filter(otherValue => cb(value, otherValue)).length;\n return occurrance >= 2 ? acc + 1 : acc;\n }, 0);\n }\n }\n});\n"],"file":"authors.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/bibliographic-level.js"],"names":["name","extract","r","leader","compare","a","b"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/bibliographic-level.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,qBADc;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: 'Bibliographic level',\n extract: r => r.leader[7] ? [r.leader[7]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2\n});\n"],"file":"bibliographic-level.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/match-detection/features/bib/host-component.js"],"names":["name","extract","r","get","length","compare","a","b"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../../../src/match-detection/features/bib/host-component.js"],"names":["name","extract","r","get","length","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,uBADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,GAAF,CAAM,QAAN,EAAgBC,MAAhB,GAAyB,CAAzB,GAA6B,CAAC,WAAD,CAA7B,GAA6C,CAAC,MAAD,CAFvC;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: 'Host/Component record',\n extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],\n compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0\n});\n"],"file":"host-component.js"}
|