@natlibfi/melinda-record-matching 2.2.1-alpha.1 → 2.2.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candidate-search/candidate-search-utils.js +55 -0
- package/dist/candidate-search/candidate-search-utils.js.map +1 -0
- package/dist/candidate-search/index.js +258 -0
- package/dist/candidate-search/index.js.map +1 -0
- package/dist/candidate-search/index.spec.js +148 -0
- package/dist/candidate-search/index.spec.js.map +1 -0
- package/dist/candidate-search/query-list/bib.js +230 -0
- package/dist/candidate-search/query-list/bib.js.map +1 -0
- package/dist/candidate-search/query-list/bib.spec.js +63 -0
- package/dist/candidate-search/query-list/bib.spec.js.map +1 -0
- package/dist/candidate-search/query-list/index.js +61 -0
- package/dist/candidate-search/query-list/index.js.map +1 -0
- package/dist/index.js +559 -0
- package/dist/index.js.map +1 -0
- package/dist/index.spec.js +125 -0
- package/dist/index.spec.js.map +1 -0
- package/dist/match-detection/features/bib/all-source-ids.js +116 -0
- package/dist/match-detection/features/bib/all-source-ids.js.map +1 -0
- package/dist/match-detection/features/bib/authors.js +107 -0
- package/dist/match-detection/features/bib/authors.js.map +1 -0
- package/dist/match-detection/features/bib/bibliographic-level.js +39 -0
- package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -0
- package/dist/match-detection/features/bib/host-component.js +39 -0
- package/dist/match-detection/features/bib/host-component.js.map +1 -0
- package/dist/match-detection/features/bib/index.js +91 -0
- package/dist/match-detection/features/bib/index.js.map +1 -0
- package/dist/match-detection/features/bib/index.spec.js +87 -0
- package/dist/match-detection/features/bib/index.spec.js.map +1 -0
- package/dist/match-detection/features/bib/isbn.js +50 -0
- package/dist/match-detection/features/bib/isbn.js.map +1 -0
- package/dist/match-detection/features/bib/issn.js +50 -0
- package/dist/match-detection/features/bib/issn.js.map +1 -0
- package/dist/match-detection/features/bib/language.js +98 -0
- package/dist/match-detection/features/bib/language.js.map +1 -0
- package/dist/match-detection/features/bib/melinda-id.js +47 -0
- package/dist/match-detection/features/bib/melinda-id.js.map +1 -0
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +88 -0
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -0
- package/dist/match-detection/features/bib/other-standard-identifier.js +50 -0
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +1 -0
- package/dist/match-detection/features/bib/publication-time.js +47 -0
- package/dist/match-detection/features/bib/publication-time.js.map +1 -0
- package/dist/match-detection/features/bib/record-type.js +41 -0
- package/dist/match-detection/features/bib/record-type.js.map +1 -0
- package/dist/match-detection/features/bib/standard-identifier-factory.js +112 -0
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -0
- package/dist/match-detection/features/bib/title.js +78 -0
- package/dist/match-detection/features/bib/title.js.map +1 -0
- package/dist/match-detection/features/index.js +11 -0
- package/dist/match-detection/features/index.js.map +1 -0
- package/dist/match-detection/index.js +162 -0
- package/dist/match-detection/index.js.map +1 -0
- package/dist/match-detection/index.spec.js +88 -0
- package/dist/match-detection/index.spec.js.map +1 -0
- package/dist/matching-utils.js +95 -0
- package/dist/matching-utils.js.map +1 -0
- package/package.json +18 -17
- package/src/candidate-search/query-list/bib.js +19 -18
- package/src/candidate-search/query-list/index.js +1 -1
- package/src/match-detection/features/bib/authors.js +5 -2
- package/src/match-detection/features/bib/language.js +2 -2
- package/src/match-detection/features/bib/publication-time.js +8 -3
- package/src/match-detection/features/bib/record-type.js +2 -0
- package/src/match-detection/features/bib/standard-identifier-factory.js +4 -3
- package/src/match-detection/features/bib/title.js +6 -4
- package/src/matching-utils.js +13 -4
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _chai = require("chai");
|
|
4
|
+
var _fixura = require("@natlibfi/fixura");
|
|
5
|
+
var _fixugenHttpClient = _interopRequireDefault(require("@natlibfi/fixugen-http-client"));
|
|
6
|
+
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
|
+
var _ = _interopRequireWildcard(require("."));
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
15
|
+
*
|
|
16
|
+
* Melinda record matching modules for Javascript
|
|
17
|
+
*
|
|
18
|
+
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
19
|
+
*
|
|
20
|
+
* This file is part of melinda-record-matching-js
|
|
21
|
+
*
|
|
22
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
23
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
24
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
25
|
+
* License, or (at your option) any later version.
|
|
26
|
+
*
|
|
27
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
28
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30
|
+
* GNU Lesser General Public License for more details.
|
|
31
|
+
*
|
|
32
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
33
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34
|
+
*
|
|
35
|
+
* @licend The above is the entire license notice
|
|
36
|
+
* for the JavaScript code in this file.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:index:test');
|
|
41
|
+
const debugData = debug.extend('data');
|
|
42
|
+
describe('INDEX', () => {
|
|
43
|
+
(0, _fixugenHttpClient.default)({
|
|
44
|
+
callback,
|
|
45
|
+
path: [__dirname, '..', 'test-fixtures', 'index'],
|
|
46
|
+
recurse: false,
|
|
47
|
+
fixura: {
|
|
48
|
+
reader: _fixura.READERS.JSON
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
async function callback({
|
|
52
|
+
getFixture,
|
|
53
|
+
options,
|
|
54
|
+
enabled = true,
|
|
55
|
+
expectedMatchStatus,
|
|
56
|
+
expectedStopReason,
|
|
57
|
+
expectedFailures
|
|
58
|
+
}) {
|
|
59
|
+
if (!enabled) {
|
|
60
|
+
debug(`Disabled test!`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const record = new _marcRecord.MarcRecord(getFixture('inputRecord.json'), {
|
|
64
|
+
subfieldValues: false
|
|
65
|
+
});
|
|
66
|
+
const expectedMatches = getFixture('expectedMatches.json');
|
|
67
|
+
const expectedNonMatches = getFixture('expectedNonMatches.json') || [];
|
|
68
|
+
const match = (0, _.default)(formatOptions());
|
|
69
|
+
const {
|
|
70
|
+
matches,
|
|
71
|
+
matchStatus,
|
|
72
|
+
nonMatches,
|
|
73
|
+
conversionFailures
|
|
74
|
+
} = await match(record);
|
|
75
|
+
debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);
|
|
76
|
+
(0, _chai.expect)(matchStatus.status).to.eql(expectedMatchStatus);
|
|
77
|
+
(0, _chai.expect)(matchStatus.stopReason).to.eql(expectedStopReason);
|
|
78
|
+
const formattedMatchResult = formatRecordResults(matches);
|
|
79
|
+
(0, _chai.expect)(formattedMatchResult).to.eql(expectedMatches);
|
|
80
|
+
const formattedNonMatchResult = formatRecordResults(nonMatches);
|
|
81
|
+
(0, _chai.expect)(formattedNonMatchResult).to.eql(expectedNonMatches);
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line functional/no-conditional-statement
|
|
84
|
+
if (expectedFailures) {
|
|
85
|
+
(0, _chai.expect)(conversionFailures).to.eql(expectedFailures);
|
|
86
|
+
}
|
|
87
|
+
function formatOptions() {
|
|
88
|
+
const contextFeatures = _.matchDetection.features[options.detection.strategy.type];
|
|
89
|
+
return {
|
|
90
|
+
...options,
|
|
91
|
+
search: {
|
|
92
|
+
...options.search
|
|
93
|
+
},
|
|
94
|
+
detection: {
|
|
95
|
+
...options.detect,
|
|
96
|
+
strategy: options.detection.strategy.features.map(v => contextFeatures[v]())
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function formatRecordResults(matches) {
|
|
101
|
+
if (matches) {
|
|
102
|
+
debugData(JSON.stringify(matches));
|
|
103
|
+
return matches.map(match => ({
|
|
104
|
+
...match,
|
|
105
|
+
candidate: formatCandidate(match.candidate)
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Format candidate to remove validationOptions from record
|
|
112
|
+
function formatCandidate({
|
|
113
|
+
id,
|
|
114
|
+
record
|
|
115
|
+
}) {
|
|
116
|
+
const newId = id;
|
|
117
|
+
const newRecord = record;
|
|
118
|
+
return {
|
|
119
|
+
id: newId,
|
|
120
|
+
record: newRecord.toObject()
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=index.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","names":["debug","createDebugLogger","debugData","extend","describe","generateTests","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","enabled","expectedMatchStatus","expectedStopReason","expectedFailures","record","MarcRecord","subfieldValues","expectedMatches","expectedNonMatches","match","createMatchInterface","formatOptions","matches","matchStatus","nonMatches","conversionFailures","length","status","stopReason","expect","to","eql","formattedMatchResult","formatRecordResults","formattedNonMatchResult","contextFeatures","matchDetection","features","detection","strategy","type","search","detect","map","v","stringify","candidate","formatCandidate","id","newId","newRecord","toObject"],"sources":["../src/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-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {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 '.';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:index:test');\nconst debugData = debug.extend('data');\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, expectedMatchStatus, expectedStopReason, expectedFailures}) {\n\n if (!enabled) {\n debug(`Disabled test!`);\n return;\n }\n\n const record = new MarcRecord(getFixture('inputRecord.json'), {subfieldValues: false});\n const expectedMatches = getFixture('expectedMatches.json');\n const expectedNonMatches = getFixture('expectedNonMatches.json') || [];\n\n\n const match = createMatchInterface(formatOptions());\n const {matches, matchStatus, nonMatches, conversionFailures} = await match(record);\n debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);\n\n expect(matchStatus.status).to.eql(expectedMatchStatus);\n expect(matchStatus.stopReason).to.eql(expectedStopReason);\n\n const formattedMatchResult = formatRecordResults(matches);\n expect(formattedMatchResult).to.eql(expectedMatches);\n\n const formattedNonMatchResult = formatRecordResults(nonMatches);\n expect(formattedNonMatchResult).to.eql(expectedNonMatches);\n\n // eslint-disable-next-line functional/no-conditional-statement\n if (expectedFailures) {\n expect(conversionFailures).to.eql(expectedFailures);\n }\n\n function formatOptions() {\n const contextFeatures = matchDetection.features[options.detection.strategy.type];\n\n return {\n ...options,\n search: {\n ...options.search\n },\n detection: {\n ...options.detect,\n strategy: options.detection.strategy.features.map(v => contextFeatures[v]())\n }\n };\n }\n\n function formatRecordResults(matches) {\n if (matches) {\n debugData(JSON.stringify(matches));\n return matches.map((match) => ({\n ...match,\n candidate: formatCandidate(match.candidate)\n }));\n }\n return [];\n }\n\n // Format candidate to remove validationOptions from record\n function formatCandidate({id, record}) {\n const newId = id;\n const newRecord = record;\n return {\n id: newId,\n record: newRecord.toObject()\n };\n }\n\n\n }\n\n});\n"],"mappings":";;AA4BA;AACA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IAAIA,OAAO,EAAE;QACX1B,SAAS,CAACW,IAAI,CAACsC,SAAS,CAACvB,OAAO,CAAC,CAAC;QAClC,OAAOA,OAAO,CAACqB,GAAG,CAAExB,KAAK,KAAM;UAC7B,GAAGA,KAAK;UACR2B,SAAS,EAAEC,eAAe,CAAC5B,KAAK,CAAC2B,SAAS;QAC5C,CAAC,CAAC,CAAC;MACL;MACA,OAAO,EAAE;IACX;;IAEA;IACA,SAASC,eAAe,CAAC;MAACC,EAAE;MAAElC;IAAM,CAAC,EAAE;MACrC,MAAMmC,KAAK,GAAGD,EAAE;MAChB,MAAME,SAAS,GAAGpC,MAAM;MACxB,OAAO;QACLkC,EAAE,EAAEC,KAAK;QACTnC,MAAM,EAAEoC,SAAS,CAACC,QAAQ;MAC5B,CAAC;IACH;EAGF;AAEF,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
+
var _matchingUtils = require("../../../matching-utils");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/* eslint-disable max-statements */
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
14
|
+
*
|
|
15
|
+
* Melinda record matching modules for Javascript
|
|
16
|
+
*
|
|
17
|
+
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
18
|
+
*
|
|
19
|
+
* This file is part of melinda-record-matching-js
|
|
20
|
+
*
|
|
21
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
22
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
23
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
24
|
+
* License, or (at your option) any later version.
|
|
25
|
+
*
|
|
26
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
27
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29
|
+
* GNU Lesser General Public License for more details.
|
|
30
|
+
*
|
|
31
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
32
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
+
*
|
|
34
|
+
* @licend The above is the entire license notice
|
|
35
|
+
* for the JavaScript code in this file.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');
|
|
40
|
+
const debugData = debug.extend('data');
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
|
|
44
|
+
SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
|
|
45
|
+
|
|
46
|
+
SID__ $c 123457 $b helka
|
|
47
|
+
SID__ $c (ANDL100020)1077305 $b sata
|
|
48
|
+
SID__ $c VER999999 $ FI-KV
|
|
49
|
+
|
|
50
|
+
allSourceIds matching feature is formatted as [{sourceDb: "helka", sourceId: "123457"}, {sourceDb: "sata", sourceId: "(ANDL100020)1077305"}, {sourceDb: "FI-KV", sourceId: "VER999999"}]
|
|
51
|
+
- no normalization / prefix deletions etc. in the feature
|
|
52
|
+
|
|
53
|
+
Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,
|
|
54
|
+
existence of a SID field depends on how the record has been added to Melinda and how it has been handled
|
|
55
|
+
afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
|
|
56
|
+
after the matching record is removed from the local db.
|
|
57
|
+
|
|
58
|
+
Records with mismatching local ids for matching local db are a strong mismatch.
|
|
59
|
+
Records with matching local ids for matching local db are a very good match.
|
|
60
|
+
|
|
61
|
+
*/
|
|
62
|
+
var _default = () => ({
|
|
63
|
+
name: 'All source IDs',
|
|
64
|
+
extract: record => {
|
|
65
|
+
debug(`Creating match detection features for all local source id's`);
|
|
66
|
+
const fSids = record.get('SID');
|
|
67
|
+
debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
|
|
68
|
+
const sidFeatures = getSidFeatures(fSids);
|
|
69
|
+
debugData(`SID-features (${sidFeatures.length}): ${JSON.stringify(sidFeatures)}`);
|
|
70
|
+
return sidFeatures;
|
|
71
|
+
function getSidFeatures(fSids) {
|
|
72
|
+
debug(`Getting Sid strings from SID fields`);
|
|
73
|
+
|
|
74
|
+
// Map SID fields to sidFeatures, filter out empty strings
|
|
75
|
+
const sidFeatures = fSids.map(toSidFeature).filter(nonEmptySid => nonEmptySid);
|
|
76
|
+
return sidFeatures;
|
|
77
|
+
function toSidFeature(field) {
|
|
78
|
+
debug(`Getting feature from a field`);
|
|
79
|
+
return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidFeature(field) : '';
|
|
80
|
+
function createSidFeature(field) {
|
|
81
|
+
debug(`Creating feature from a field`);
|
|
82
|
+
const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
|
|
83
|
+
const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
|
|
84
|
+
debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
|
|
85
|
+
debugData(`sourceDb: ${sfB}, sourceId: ${sfC}`);
|
|
86
|
+
return {
|
|
87
|
+
'sourceDb': sfB,
|
|
88
|
+
'sourceId': sfC
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
compare: (a, b) => {
|
|
95
|
+
debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
|
|
96
|
+
const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId === sidB.sourceId));
|
|
97
|
+
debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);
|
|
98
|
+
const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId !== sidB.sourceId));
|
|
99
|
+
debugData(`Mismatches (${mismatches.length}): ${JSON.stringify(mismatches)}`);
|
|
100
|
+
|
|
101
|
+
// If there's at least one mismatching source ID from matching source db
|
|
102
|
+
if (mismatches.length > 0) {
|
|
103
|
+
return -1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// If there's at least one matching source ID from matching source db
|
|
107
|
+
if (matches.length > 0) {
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// If there are no source IDs with matching sources
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
exports.default = _default;
|
|
116
|
+
//# sourceMappingURL=all-source-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-source-ids.js","names":["debug","createDebugLogger","debugData","extend","name","extract","record","fSids","get","length","JSON","stringify","sidFeatures","getSidFeatures","map","toSidFeature","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidFeature","sfC","getSubfieldValues","sfB","compare","a","b","matches","sidA","some","sidB","sourceDb","sourceId","mismatches"],"sources":["../../../../src/match-detection/features/bib/all-source-ids.js"],"sourcesContent":["/* eslint-disable max-statements */\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 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"],"mappings":";;;;;;AA6BA;AACA;AAA0F;AA9B1F;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;;AAKA,MAAMA,KAAK,GAAG,IAAAC,cAAiB,EAAC,2EAA2E,CAAC;AAC5G,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAnBA,eAqBe,OAAO;EACpBC,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEC,MAAM,IAAI;IACjBN,KAAK,CAAE,6DAA4D,CAAC;IAEpE,MAAMO,KAAK,GAAGD,MAAM,CAACE,GAAG,CAAC,KAAK,CAAC;IAC/BN,SAAS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AAYQ,IAAI,CAACC,SAAS,CAACc,CAAC,CAAE,QAAOf,IAAI,CAACC,SAAS,CAACe,CAAC,CAAE,EAAC,CAAC;IAEpE,MAAMC,OAAO,GAAGF,CAAC,CAACT,MAAM,CAACY,IAAI,IAAIF,CAAC,CAACG,IAAI,CAACC,IAAI,IAAIF,IAAI,CAACG,QAAQ,KAAKD,IAAI,CAACC,QAAQ,IACvEH,IAAI,CAACI,QAAQ,KAAKF,IAAI,CAACE,QAAQ,CAAC,CAAC;IACzC9B,SAAS,CAAE,YAAWyB,OAAO,CAAClB,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACgB,OAAO,CAAE,EAAC,CAAC;IAEpE,MAAMM,UAAU,GAAGR,CAAC,CAACT,MAAM,CAACY,IAAI,IAAIF,CAAC,CAACG,IAAI,CAACC,IAAI,IAAIF,IAAI,CAACG,QAAQ,KAAKD,IAAI,CAACC,QAAQ,IAChFH,IAAI,CAACI,QAAQ,KAAKF,IAAI,CAACE,QAAQ,CAAC,CAAC;IACnC9B,SAAS,CAAE,eAAc+B,UAAU,CAACxB,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACsB,UAAU,CAAE,EAAC,CAAC;;IAE7E;IACA,IAAIA,UAAU,CAACxB,MAAM,GAAG,CAAC,EAAE;MACzB,OAAO,CAAC,CAAC;IACX;;IAEA;IACA,IAAIkB,OAAO,CAAClB,MAAM,GAAG,CAAC,EAAE;MACtB,OAAO,CAAC;IACV;;IAEA;IACA,OAAO,CAAC;EAEV;AACF,CAAC,CAAC;AAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _natural = require("natural");
|
|
8
|
+
var _matchingUtils = require("../../../matching-utils");
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
12
|
+
*
|
|
13
|
+
* Melinda record matching modules for Javascript
|
|
14
|
+
*
|
|
15
|
+
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
16
|
+
*
|
|
17
|
+
* This file is part of melinda-record-matching-js
|
|
18
|
+
*
|
|
19
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
20
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
21
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
22
|
+
* License, or (at your option) any later version.
|
|
23
|
+
*
|
|
24
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
25
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
26
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
27
|
+
* GNU Lesser General Public License for more details.
|
|
28
|
+
*
|
|
29
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
30
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
31
|
+
*
|
|
32
|
+
* @licend The above is the entire license notice
|
|
33
|
+
* for the JavaScript code in this file.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
// We should extract also organisational authors (110/710)
|
|
37
|
+
var _default = ({
|
|
38
|
+
nameTreshold = 10
|
|
39
|
+
} = {}) => ({
|
|
40
|
+
name: 'Authors',
|
|
41
|
+
extract: record => record.get(/^(?<def>100|700)$/u).map(({
|
|
42
|
+
subfields
|
|
43
|
+
}) => {
|
|
44
|
+
return subfields.filter(({
|
|
45
|
+
code,
|
|
46
|
+
value
|
|
47
|
+
}) => code && value).filter(({
|
|
48
|
+
code
|
|
49
|
+
}) => ['a', '0'].includes(code)).map(toObj).reduce((acc, v) => ({
|
|
50
|
+
...acc,
|
|
51
|
+
...v
|
|
52
|
+
}), {});
|
|
53
|
+
function toObj({
|
|
54
|
+
code,
|
|
55
|
+
value
|
|
56
|
+
}) {
|
|
57
|
+
if (code === 'a') {
|
|
58
|
+
return {
|
|
59
|
+
name: (0, _matchingUtils.testStringOrNumber)(value) ? String(value).replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase() : ''
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
id: value
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
compare: (a, b) => {
|
|
68
|
+
const maxAuthors = a.length > b.length ? a.length : b.length;
|
|
69
|
+
const matchingIds = findMatchingIds();
|
|
70
|
+
if (maxAuthors >= 3 && matchingIds >= 3) {
|
|
71
|
+
return 0.3;
|
|
72
|
+
}
|
|
73
|
+
const matchingNames = findMatchingNames();
|
|
74
|
+
const idPoints = matchingIds / maxAuthors * 0.3;
|
|
75
|
+
const namePoints = matchingNames / maxAuthors * 0.2;
|
|
76
|
+
const totalPoints = idPoints + namePoints;
|
|
77
|
+
return totalPoints <= 0.2 ? totalPoints : 0.2;
|
|
78
|
+
function findMatchingIds() {
|
|
79
|
+
return findMatches('id', (a, b) => a === b);
|
|
80
|
+
}
|
|
81
|
+
function findMatchingNames() {
|
|
82
|
+
return findMatches('name', (a, b) => {
|
|
83
|
+
const distance = (0, _natural.LevenshteinDistance)(a, b);
|
|
84
|
+
if (distance === 0) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const maxLength = getMaxLength();
|
|
88
|
+
const percentage = distance / maxLength * 100;
|
|
89
|
+
return percentage <= nameTreshold;
|
|
90
|
+
function getMaxLength() {
|
|
91
|
+
return a.length > b.length ? a.length : b.length;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function findMatches(key, cb) {
|
|
96
|
+
const valuesA = a.filter(o => o[key]).map(o => o[key]);
|
|
97
|
+
const valuesB = b.filter(o => o[key]).map(o => o[key]);
|
|
98
|
+
const allValues = valuesA.concat(valuesB);
|
|
99
|
+
return allValues.reduce((acc, value) => {
|
|
100
|
+
const occurrance = allValues.filter(otherValue => cb(value, otherValue)).length;
|
|
101
|
+
return occurrance >= 2 ? acc + 1 : acc;
|
|
102
|
+
}, 0);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
exports.default = _default;
|
|
107
|
+
//# sourceMappingURL=authors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authors.js","names":["nameTreshold","name","extract","record","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","testStringOrNumber","String","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","leven","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue"],"sources":["../../../../src/match-detection/features/bib/authors.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {LevenshteinDistance as leven} from 'natural';\nimport {testStringOrNumber} from '../../../matching-utils';\n\n// We should extract also organisational authors (110/710)\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: testStringOrNumber(value) ? String(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"],"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;AAAA,eAEe,CAAC;EAACA,YAAY,GAAG;AAAE,CAAC,GAAG,CAAC,CAAC,MAAM;EAC5CC,IAAI,EAAE,SAAS;EACfC,OAAO,EAAEC,MAAM,IAAIA,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC,C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AC,CAACC,GAAG,EAAEJ,KAAK,KAAK;QACtC,MAAMoC,UAAU,GAAGF,SAAS,CAACpC,MAAM,CAACuC,UAAU,IAAIP,EAAE,CAAC9B,KAAK,EAAEqC,UAAU,CAAC,CAAC,CAACtB,MAAM;QAC/E,OAAOqB,UAAU,IAAI,CAAC,GAAGhC,GAAG,GAAG,CAAC,GAAGA,GAAG;MACxC,CAAC,EAAE,CAAC,CAAC;IACP;EACF;AACF,CAAC,CAAC;AAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
+
*
|
|
11
|
+
* Melinda record matching modules for Javascript
|
|
12
|
+
*
|
|
13
|
+
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
14
|
+
*
|
|
15
|
+
* This file is part of melinda-record-matching-js
|
|
16
|
+
*
|
|
17
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
18
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
19
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
+
* License, or (at your option) any later version.
|
|
21
|
+
*
|
|
22
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
23
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
+
* GNU Lesser General Public License for more details.
|
|
26
|
+
*
|
|
27
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
*
|
|
30
|
+
* @licend The above is the entire license notice
|
|
31
|
+
* for the JavaScript code in this file.
|
|
32
|
+
*
|
|
33
|
+
*/var _default = () => ({
|
|
34
|
+
name: 'Bibliographic level',
|
|
35
|
+
extract: r => r.leader[7] ? [r.leader[7]] : [],
|
|
36
|
+
compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2
|
|
37
|
+
});
|
|
38
|
+
exports.default = _default;
|
|
39
|
+
//# sourceMappingURL=bibliographic-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bibliographic-level.js","names":["name","extract","r","leader","compare","a","b"],"sources":["../../../../src/match-detection/features/bib/bibliographic-level.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport default () => ({\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"],"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,EA1BA,eA4Be,OAAO;EACpBA,IAAI,EAAE,qBAAqB;EAC3BC,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC,GAAG,CAACD,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;EAC9CC,OAAO,EAAE,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
+
*
|
|
11
|
+
* Melinda record matching modules for Javascript
|
|
12
|
+
*
|
|
13
|
+
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
14
|
+
*
|
|
15
|
+
* This file is part of melinda-record-matching-js
|
|
16
|
+
*
|
|
17
|
+
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
18
|
+
* it under the terms of the GNU Lesser General Public License as
|
|
19
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
+
* License, or (at your option) any later version.
|
|
21
|
+
*
|
|
22
|
+
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
23
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
+
* GNU Lesser General Public License for more details.
|
|
26
|
+
*
|
|
27
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
*
|
|
30
|
+
* @licend The above is the entire license notice
|
|
31
|
+
* for the JavaScript code in this file.
|
|
32
|
+
*
|
|
33
|
+
*/var _default = () => ({
|
|
34
|
+
name: 'Host/Component record',
|
|
35
|
+
extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],
|
|
36
|
+
compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0
|
|
37
|
+
});
|
|
38
|
+
exports.default = _default;
|
|
39
|
+
//# sourceMappingURL=host-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-component.js","names":["name","extract","r","get","length","compare","a","b"],"sources":["../../../../src/match-detection/features/bib/host-component.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport default () => ({\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"],"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,EA1BA,eA4Be,OAAO;EACpBA,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,GAAG,CAAC,QAAQ,CAAC,CAACC,MAAM,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;EACnEC,OAAO,EAAE,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "allSourceIds", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _allSourceIds.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "authors", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _authors.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "bibliographicLevel", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _bibliographicLevel.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "hostComponent", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _hostComponent.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "isbn", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _isbn.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "issn", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _issn.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "language", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _language.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "melindaId", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _melindaId.default;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "otherStandardIdentifier", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _otherStandardIdentifier.default;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "publicationTime", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _publicationTime.default;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "recordType", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _recordType.default;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "title", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _title.default;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var _hostComponent = _interopRequireDefault(require("./host-component"));
|
|
79
|
+
var _isbn = _interopRequireDefault(require("./isbn"));
|
|
80
|
+
var _issn = _interopRequireDefault(require("./issn"));
|
|
81
|
+
var _otherStandardIdentifier = _interopRequireDefault(require("./other-standard-identifier"));
|
|
82
|
+
var _title = _interopRequireDefault(require("./title"));
|
|
83
|
+
var _authors = _interopRequireDefault(require("./authors"));
|
|
84
|
+
var _recordType = _interopRequireDefault(require("./record-type"));
|
|
85
|
+
var _publicationTime = _interopRequireDefault(require("./publication-time"));
|
|
86
|
+
var _language = _interopRequireDefault(require("./language"));
|
|
87
|
+
var _bibliographicLevel = _interopRequireDefault(require("./bibliographic-level"));
|
|
88
|
+
var _melindaId = _interopRequireDefault(require("./melinda-id"));
|
|
89
|
+
var _allSourceIds = _interopRequireDefault(require("./all-source-ids"));
|
|
90
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/match-detection/features/bib/index.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport {default as hostComponent} from './host-component';\nexport {default as isbn} from './isbn';\nexport {default as issn} from './issn';\nexport {default as otherStandardIdentifier} from './other-standard-identifier';\nexport {default as title} from './title';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as language} from './language';\nexport {default as bibliographicLevel} from './bibliographic-level';\nexport {default as melindaId} from './melinda-id';\nexport {default as allSourceIds} from './all-source-ids';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAyD"}
|