@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/melinda-node-tests.yml +13 -9
- package/LICENSE.txt +21 -165
- package/README.md +2 -2
- package/dist/candidate-search/candidate-search-utils.js +6 -43
- package/dist/candidate-search/candidate-search-utils.js.map +7 -1
- package/dist/candidate-search/choose-queries.js +75 -0
- package/dist/candidate-search/choose-queries.js.map +7 -0
- package/dist/candidate-search/index.js +89 -225
- package/dist/candidate-search/index.js.map +7 -1
- package/dist/candidate-search/index.test.js +92 -0
- package/dist/candidate-search/index.test.js.map +7 -0
- package/dist/candidate-search/query-list/bib.js +141 -320
- package/dist/candidate-search/query-list/bib.js.map +7 -1
- package/dist/candidate-search/query-list/bib.test.js +34 -0
- package/dist/candidate-search/query-list/bib.test.js.map +7 -0
- package/dist/candidate-search/query-list/component.js +87 -0
- package/dist/candidate-search/query-list/component.js.map +7 -0
- package/dist/candidate-search/query-list/index.js +39 -52
- package/dist/candidate-search/query-list/index.js.map +7 -1
- package/dist/cli.js +138 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.js +87 -462
- package/dist/index.js.map +7 -1
- package/dist/index.test.js +69 -0
- package/dist/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/all-source-ids.js +20 -91
- package/dist/match-detection/features/bib/all-source-ids.js.map +7 -1
- package/dist/match-detection/features/bib/authors.js +20 -76
- package/dist/match-detection/features/bib/authors.js.map +7 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +4 -40
- package/dist/match-detection/features/bib/bibliographic-level.js.map +7 -1
- package/dist/match-detection/features/bib/host-component.js +5 -41
- package/dist/match-detection/features/bib/host-component.js.map +7 -1
- package/dist/match-detection/features/bib/index.js +17 -119
- package/dist/match-detection/features/bib/index.js.map +7 -1
- package/dist/match-detection/features/bib/index.test.js +40 -0
- package/dist/match-detection/features/bib/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/isbn.js +13 -69
- package/dist/match-detection/features/bib/isbn.js.map +7 -1
- package/dist/match-detection/features/bib/issn.js +5 -50
- package/dist/match-detection/features/bib/issn.js.map +7 -1
- package/dist/match-detection/features/bib/language.js +25 -86
- package/dist/match-detection/features/bib/language.js.map +7 -1
- package/dist/match-detection/features/bib/media-type.js +12 -64
- package/dist/match-detection/features/bib/media-type.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-id.js +5 -47
- package/dist/match-detection/features/bib/melinda-id.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +16 -67
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +5 -51
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +49 -189
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +10 -53
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time.js +8 -46
- package/dist/match-detection/features/bib/publication-time.js.map +7 -1
- package/dist/match-detection/features/bib/record-type.js +4 -43
- package/dist/match-detection/features/bib/record-type.js.map +7 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +47 -163
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/title-version-original.js +11 -53
- package/dist/match-detection/features/bib/title-version-original.js.map +7 -1
- package/dist/match-detection/features/bib/title.js +20 -72
- package/dist/match-detection/features/bib/title.js.map +7 -1
- package/dist/match-detection/features/index.js +3 -11
- package/dist/match-detection/features/index.js.map +7 -1
- package/dist/match-detection/index.js +35 -150
- package/dist/match-detection/index.js.map +7 -1
- package/dist/match-detection/index.test.js +44 -0
- package/dist/match-detection/index.test.js.map +7 -0
- package/dist/matching-utils.js +38 -102
- package/dist/matching-utils.js.map +7 -1
- package/eslint.config.js +52 -0
- package/example.env +4 -0
- package/package.json +29 -78
- package/src/candidate-search/candidate-search-utils.js +1 -28
- package/src/candidate-search/choose-queries.js +93 -0
- package/src/candidate-search/index.js +85 -119
- package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
- package/src/candidate-search/query-list/bib.js +54 -55
- package/src/candidate-search/query-list/bib.test.js +38 -0
- package/src/candidate-search/query-list/component.js +127 -0
- package/src/candidate-search/query-list/index.js +31 -35
- package/src/cli.js +177 -0
- package/src/index.js +27 -68
- package/src/{index.spec.js → index.test.js} +11 -42
- package/src/match-detection/features/bib/all-source-ids.js +2 -29
- package/src/match-detection/features/bib/authors.js +5 -30
- package/src/match-detection/features/bib/bibliographic-level.js +0 -27
- package/src/match-detection/features/bib/host-component.js +0 -27
- package/src/match-detection/features/bib/index.js +16 -43
- package/src/match-detection/features/bib/index.test.js +52 -0
- package/src/match-detection/features/bib/isbn.js +2 -29
- package/src/match-detection/features/bib/issn.js +1 -28
- package/src/match-detection/features/bib/language.js +5 -32
- package/src/match-detection/features/bib/media-type.js +2 -28
- package/src/match-detection/features/bib/melinda-id.js +1 -28
- package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
- package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
- package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
- package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
- package/src/match-detection/features/bib/publication-time.js +2 -28
- package/src/match-detection/features/bib/record-type.js +0 -27
- package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
- package/src/match-detection/features/bib/title-version-original.js +2 -28
- package/src/match-detection/features/bib/title.js +6 -34
- package/src/match-detection/features/index.js +1 -28
- package/src/match-detection/index.js +1 -28
- package/src/match-detection/{index.spec.js → index.test.js} +9 -35
- package/src/matching-utils.js +8 -37
- package/dist/candidate-search/index.spec.js +0 -144
- package/dist/candidate-search/index.spec.js.map +0 -1
- package/dist/candidate-search/query-list/bib.spec.js +0 -64
- package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
- package/dist/index.spec.js +0 -127
- package/dist/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/index.spec.js +0 -93
- package/dist/match-detection/features/bib/index.spec.js.map +0 -1
- package/dist/match-detection/index.spec.js +0 -91
- package/dist/match-detection/index.spec.js.map +0 -1
- package/src/candidate-search/query-list/bib.spec.js +0 -54
- package/src/match-detection/features/bib/index.spec.js +0 -78
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
4
|
-
var _fixura = require("@natlibfi/fixura");
|
|
5
|
-
var _chai = require("chai");
|
|
6
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
|
-
var features = _interopRequireWildcard(require("."));
|
|
8
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
15
|
-
*
|
|
16
|
-
* Melinda record matching modules for Javascript
|
|
17
|
-
*
|
|
18
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
19
|
-
*
|
|
20
|
-
* This file is part of melinda-record-matching-js
|
|
21
|
-
*
|
|
22
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
23
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
24
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
25
|
-
* License, or (at your option) any later version.
|
|
26
|
-
*
|
|
27
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
28
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30
|
-
* GNU Lesser General Public License for more details.
|
|
31
|
-
*
|
|
32
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
33
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34
|
-
*
|
|
35
|
-
* @licend The above is the entire license notice
|
|
36
|
-
* for the JavaScript code in this file.
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib:test');
|
|
41
|
-
const debugData = debug.extend('data');
|
|
42
|
-
describe('match-detection/features/bib/', () => {
|
|
43
|
-
(0, _fixugen.default)({
|
|
44
|
-
path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],
|
|
45
|
-
useMetadataFile: true,
|
|
46
|
-
fixura: {
|
|
47
|
-
reader: _fixura.READERS.JSON
|
|
48
|
-
},
|
|
49
|
-
callback: ({
|
|
50
|
-
enabled = true,
|
|
51
|
-
feature,
|
|
52
|
-
options,
|
|
53
|
-
type,
|
|
54
|
-
...expectations
|
|
55
|
-
}) => {
|
|
56
|
-
if (!enabled) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
debug(`Testing: ${feature} ${type}`);
|
|
60
|
-
if (type === 'extract') {
|
|
61
|
-
const {
|
|
62
|
-
expectedFeatures,
|
|
63
|
-
inputRecord
|
|
64
|
-
} = expectations;
|
|
65
|
-
const record = new _marcRecord.MarcRecord(inputRecord, {
|
|
66
|
-
subfieldValues: false
|
|
67
|
-
});
|
|
68
|
-
debugData(`Record: ${record}`);
|
|
69
|
-
const {
|
|
70
|
-
extract
|
|
71
|
-
} = features[feature](options);
|
|
72
|
-
(0, _chai.expect)(extract({
|
|
73
|
-
record
|
|
74
|
-
})).to.eql(expectedFeatures);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (type === 'compare') {
|
|
78
|
-
const {
|
|
79
|
-
featuresA,
|
|
80
|
-
featuresB,
|
|
81
|
-
expectedPoints
|
|
82
|
-
} = expectations;
|
|
83
|
-
const {
|
|
84
|
-
compare
|
|
85
|
-
} = features[feature](options);
|
|
86
|
-
(0, _chai.expect)(compare(featuresA, featuresB)).to.equal(expectedPoints);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
throw new Error(`Invalid type ${type}`);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
//# sourceMappingURL=index.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","expect","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from '.';\nimport createDebugLogger from 'debug';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');\nconst debugData = debug.extend('data');\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\n callback: ({enabled = true, feature, options, type, ...expectations}) => {\n\n if (!enabled) {\n return;\n }\n\n debug(`Testing: ${feature} ${type}`);\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n debugData(`Record: ${record}`);\n const {extract} = features[feature](options);\n\n expect(extract({record})).to.eql(expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n expect(compare(featuresA, featuresB)).to.equal(expectedPoints);\n return;\n }\n\n throw new Error(`Invalid type ${type}`);\n }\n });\n});\n"],"mappings":";;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,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,CAACwC,OAAO,CAAC,CAACC,OAAO,CAAC;QAE5C,IAAAS,YAAM,EAACD,OAAO,CAAC;UAACH;QAAM,CAAC,CAAC,CAAC,CAACK,EAAE,CAACC,GAAG,CAACR,gBAAgB,CAAC;QAClD;MACF;MAEA,IAAIF,IAAI,KAAK,SAAS,EAAE;QACtB,MAAM;UAACW,SAAS;UAAEC,SAAS;UAAEC;QAAc,CAAC,GAAGZ,YAAY;QAC3D,MAAM;UAACa;QAAO,CAAC,GAAGxD,QAAQ,CAACwC,OAAO,CAAC,CAACC,OAAO,CAAC;QAE5C,IAAAS,YAAM,EAACM,OAAO,CAACH,SAAS,EAAEC,SAAS,CAAC,CAAC,CAACH,EAAE,CAACM,KAAK,CAACF,cAAc,CAAC;QAC9D;MACF;MAEA,MAAM,IAAIG,KAAK,CAAE,gBAAehB,IAAK,EAAC,CAAC;IACzC;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
4
|
-
var _fixura = require("@natlibfi/fixura");
|
|
5
|
-
var _chai = require("chai");
|
|
6
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
|
-
var features = _interopRequireWildcard(require("./features"));
|
|
8
|
-
var _ = _interopRequireDefault(require("."));
|
|
9
|
-
var _util = require("util");
|
|
10
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
17
|
-
*
|
|
18
|
-
* Melinda record matching modules for Javascript
|
|
19
|
-
*
|
|
20
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
21
|
-
*
|
|
22
|
-
* This file is part of melinda-record-matching-js
|
|
23
|
-
*
|
|
24
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
25
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
26
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
27
|
-
* License, or (at your option) any later version.
|
|
28
|
-
*
|
|
29
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
30
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
31
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
32
|
-
* GNU Lesser General Public License for more details.
|
|
33
|
-
*
|
|
34
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
35
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
36
|
-
*
|
|
37
|
-
* @licend The above is the entire license notice
|
|
38
|
-
* for the JavaScript code in this file.
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:test');
|
|
43
|
-
const debugData = debug.extend('data');
|
|
44
|
-
describe('match-detection', () => {
|
|
45
|
-
(0, _fixugen.default)({
|
|
46
|
-
path: [__dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],
|
|
47
|
-
useMetadataFile: true,
|
|
48
|
-
recurse: false,
|
|
49
|
-
fixura: {
|
|
50
|
-
reader: _fixura.READERS.JSON
|
|
51
|
-
},
|
|
52
|
-
callback: ({
|
|
53
|
-
getFixture,
|
|
54
|
-
options,
|
|
55
|
-
expectedResults,
|
|
56
|
-
array,
|
|
57
|
-
enabled = true
|
|
58
|
-
}) => {
|
|
59
|
-
if (!enabled) {
|
|
60
|
-
debug(`*** DISABLED TEST! ***`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const detect = (0, _.default)(formatOptions());
|
|
64
|
-
const recordA = new _marcRecord.MarcRecord(getFixture('recordA.json'), {
|
|
65
|
-
subfieldValues: false
|
|
66
|
-
});
|
|
67
|
-
debugData((0, _util.inspect)(recordA));
|
|
68
|
-
debug(`Our recordB is an array of records: ${array}`);
|
|
69
|
-
const recordB = array ? getFixture('recordB.json').map(recordJson => new _marcRecord.MarcRecord(recordJson, {
|
|
70
|
-
subfieldValues: false
|
|
71
|
-
})) : new _marcRecord.MarcRecord(getFixture('recordB.json'), {
|
|
72
|
-
subfieldValues: false
|
|
73
|
-
});
|
|
74
|
-
debugData((0, _util.inspect)(recordB));
|
|
75
|
-
const results = detect({
|
|
76
|
-
recordA,
|
|
77
|
-
recordB
|
|
78
|
-
});
|
|
79
|
-
debugData(`${JSON.stringify(results)}`);
|
|
80
|
-
(0, _chai.expect)(results).to.eql(expectedResults);
|
|
81
|
-
function formatOptions() {
|
|
82
|
-
const contextFeatures = features[options.strategy.type];
|
|
83
|
-
return {
|
|
84
|
-
...options,
|
|
85
|
-
strategy: options.strategy.features.map(v => contextFeatures[v]())
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
//# sourceMappingURL=index.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_","_util","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","callback","getFixture","options","expectedResults","array","enabled","detect","createDetectionInterface","formatOptions","recordA","MarcRecord","subfieldValues","inspect","recordB","map","recordJson","results","stringify","expect","to","eql","contextFeatures","strategy","type","v"],"sources":["../../src/match-detection/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from './features';\nimport createDetectionInterface from '.';\nimport {inspect} from 'util';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:test');\nconst debugData = debug.extend('data');\n\ndescribe('match-detection', () => {\n generateTests({\n path: [__dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({getFixture, options, expectedResults, array, enabled = true}) => {\n\n if (!enabled) {\n debug(`*** DISABLED TEST! ***`);\n return;\n }\n\n const detect = createDetectionInterface(formatOptions());\n const recordA = new MarcRecord(getFixture('recordA.json'), {subfieldValues: false});\n debugData(inspect(recordA));\n\n debug(`Our recordB is an array of records: ${array}`);\n const recordB = array\n ? getFixture('recordB.json').map(recordJson => new MarcRecord(recordJson, {subfieldValues: false}))\n : new MarcRecord(getFixture('recordB.json'), {subfieldValues: false});\n debugData(inspect(recordB));\n\n const results = detect({recordA, recordB});\n debugData(`${JSON.stringify(results)}`);\n\n expect(results).to.eql(expectedResults);\n\n function formatOptions() {\n const contextFeatures = features[options.strategy.type];\n\n return {\n ...options,\n strategy: options.strategy.features.map(v => contextFeatures[v]())\n };\n }\n }\n });\n});\n"],"mappings":";;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,CAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAT,sBAAA,CAAAC,OAAA;AAAsC,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA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ACC,IAAI,CAAC;QAEvD,OAAO;UACL,GAAGrB,OAAO;UACVoB,QAAQ,EAAEpB,OAAO,CAACoB,QAAQ,CAAC/D,QAAQ,CAACuD,GAAG,CAACU,CAAC,IAAIH,eAAe,CAACG,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;MACH;IACF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import generateTests from '@natlibfi/fixugen';
|
|
30
|
-
import {READERS} from '@natlibfi/fixura';
|
|
31
|
-
import {expect} from 'chai';
|
|
32
|
-
import {MarcRecord} from '@natlibfi/marc-record';
|
|
33
|
-
import * as generators from './bib';
|
|
34
|
-
|
|
35
|
-
describe('candidate-search/query-list/bib/', () => {
|
|
36
|
-
generateTests({
|
|
37
|
-
path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
|
|
38
|
-
useMetadataFile: true,
|
|
39
|
-
fixura: {
|
|
40
|
-
reader: READERS.JSON
|
|
41
|
-
},
|
|
42
|
-
callback: ({type, inputRecord, expectedQuery, enabled = true}) => {
|
|
43
|
-
const generate = generators[type];
|
|
44
|
-
const record = new MarcRecord(inputRecord, {subfieldValues: false});
|
|
45
|
-
|
|
46
|
-
if (!enabled) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const queryList = generate(record);
|
|
51
|
-
expect(queryList).to.eql(expectedQuery);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Melinda record matching modules for Javascript
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of melinda-record-matching-js
|
|
10
|
-
*
|
|
11
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import generateTests from '@natlibfi/fixugen';
|
|
30
|
-
import {READERS} from '@natlibfi/fixura';
|
|
31
|
-
import {expect} from 'chai';
|
|
32
|
-
import {MarcRecord} from '@natlibfi/marc-record';
|
|
33
|
-
import * as features from '.';
|
|
34
|
-
import createDebugLogger from 'debug';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');
|
|
38
|
-
const debugData = debug.extend('data');
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
describe('match-detection/features/bib/', () => {
|
|
42
|
-
generateTests({
|
|
43
|
-
path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],
|
|
44
|
-
useMetadataFile: true,
|
|
45
|
-
fixura: {
|
|
46
|
-
reader: READERS.JSON
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
callback: ({enabled = true, feature, options, type, ...expectations}) => {
|
|
50
|
-
|
|
51
|
-
if (!enabled) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
debug(`Testing: ${feature} ${type}`);
|
|
56
|
-
|
|
57
|
-
if (type === 'extract') {
|
|
58
|
-
const {expectedFeatures, inputRecord} = expectations;
|
|
59
|
-
const record = new MarcRecord(inputRecord, {subfieldValues: false});
|
|
60
|
-
debugData(`Record: ${record}`);
|
|
61
|
-
const {extract} = features[feature](options);
|
|
62
|
-
|
|
63
|
-
expect(extract({record})).to.eql(expectedFeatures);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (type === 'compare') {
|
|
68
|
-
const {featuresA, featuresB, expectedPoints} = expectations;
|
|
69
|
-
const {compare} = features[feature](options);
|
|
70
|
-
|
|
71
|
-
expect(compare(featuresA, featuresB)).to.equal(expectedPoints);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
throw new Error(`Invalid type ${type}`);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|