@natlibfi/melinda-record-matching 2.2.1-alpha.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candidate-search/candidate-search-utils.js +3 -6
- package/dist/candidate-search/candidate-search-utils.js.map +1 -1
- package/dist/candidate-search/index.js +18 -33
- package/dist/candidate-search/index.js.map +1 -1
- package/dist/candidate-search/index.spec.js +17 -30
- package/dist/candidate-search/index.spec.js.map +1 -1
- package/dist/candidate-search/query-list/bib.js +27 -49
- package/dist/candidate-search/query-list/bib.js.map +1 -1
- package/dist/candidate-search/query-list/bib.spec.js +1 -10
- package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
- package/dist/candidate-search/query-list/index.js +3 -9
- package/dist/candidate-search/query-list/index.js.map +1 -1
- package/dist/index.js +46 -65
- package/dist/index.js.map +1 -1
- package/dist/index.spec.js +13 -21
- package/dist/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/all-source-ids.js +10 -16
- package/dist/match-detection/features/bib/all-source-ids.js.map +1 -1
- package/dist/match-detection/features/bib/authors.js +2 -15
- package/dist/match-detection/features/bib/authors.js.map +1 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +1 -4
- package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -1
- package/dist/match-detection/features/bib/host-component.js +1 -4
- package/dist/match-detection/features/bib/host-component.js.map +1 -1
- package/dist/match-detection/features/bib/index.js +0 -13
- package/dist/match-detection/features/bib/index.js.map +1 -1
- package/dist/match-detection/features/bib/index.spec.js +1 -11
- package/dist/match-detection/features/bib/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/isbn.js +1 -6
- package/dist/match-detection/features/bib/isbn.js.map +1 -1
- package/dist/match-detection/features/bib/issn.js +1 -6
- package/dist/match-detection/features/bib/issn.js.map +1 -1
- package/dist/match-detection/features/bib/language.js +4 -19
- package/dist/match-detection/features/bib/language.js.map +1 -1
- package/dist/match-detection/features/bib/melinda-id.js +1 -6
- package/dist/match-detection/features/bib/melinda-id.js.map +1 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +2 -14
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +1 -6
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +1 -1
- package/dist/match-detection/features/bib/publication-time.js +0 -4
- package/dist/match-detection/features/bib/publication-time.js.map +1 -1
- package/dist/match-detection/features/bib/record-type.js +0 -2
- package/dist/match-detection/features/bib/record-type.js.map +1 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +1 -16
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -1
- package/dist/match-detection/features/bib/title.js +1 -18
- package/dist/match-detection/features/bib/title.js.map +1 -1
- package/dist/match-detection/features/index.js +0 -4
- package/dist/match-detection/features/index.js.map +1 -1
- package/dist/match-detection/index.js +0 -22
- package/dist/match-detection/index.js.map +1 -1
- package/dist/match-detection/index.spec.js +3 -14
- package/dist/match-detection/index.spec.js.map +1 -1
- package/dist/matching-utils.js +3 -12
- package/dist/matching-utils.js.map +1 -1
- package/package.json +17 -17
|
@@ -8,15 +8,10 @@ exports.bibMelindaIds = bibMelindaIds;
|
|
|
8
8
|
exports.bibSourceIds = bibSourceIds;
|
|
9
9
|
exports.bibStandardIdentifiers = bibStandardIdentifiers;
|
|
10
10
|
exports.bibTitle = bibTitle;
|
|
11
|
-
|
|
12
11
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
|
|
14
12
|
var _candidateSearchUtils = require("../candidate-search-utils");
|
|
15
|
-
|
|
16
13
|
var _matchingUtils = require("../../matching-utils");
|
|
17
|
-
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
15
|
/**
|
|
21
16
|
*
|
|
22
17
|
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
@@ -44,6 +39,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
44
39
|
* for the JavaScript code in this file.
|
|
45
40
|
*
|
|
46
41
|
*/
|
|
42
|
+
|
|
47
43
|
function bibSourceIds(record) {
|
|
48
44
|
/* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records
|
|
49
45
|
SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
|
|
@@ -62,36 +58,33 @@ function bibSourceIds(record) {
|
|
|
62
58
|
afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
|
|
63
59
|
after the matching record is removed from the local db.
|
|
64
60
|
*/
|
|
61
|
+
|
|
65
62
|
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');
|
|
66
|
-
const debugData = debug.extend('data');
|
|
63
|
+
const debugData = debug.extend('data');
|
|
64
|
+
//const debugInfo = debug.extend('info');
|
|
67
65
|
|
|
68
66
|
debug(`Creating queries for sourceid's`);
|
|
69
67
|
const fSids = record.get('SID');
|
|
70
68
|
debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
|
|
71
69
|
return fSids.length > 0 ? toSidQueries(fSids) : [];
|
|
72
|
-
|
|
73
70
|
function toSidQueries(fSids) {
|
|
74
71
|
debug(`Creating actual queries for sourceid's`);
|
|
75
72
|
const sidStrings = getSidStrings(fSids);
|
|
76
|
-
|
|
77
73
|
if (sidStrings.length < 1) {
|
|
78
74
|
debug(`No identifiers found, no queries created.`);
|
|
79
75
|
return [];
|
|
80
76
|
}
|
|
81
|
-
|
|
82
77
|
const sidQueries = (0, _candidateSearchUtils.toQueries)(sidStrings, 'melinda.sourceid');
|
|
83
78
|
return sidQueries;
|
|
84
|
-
|
|
85
79
|
function getSidStrings(fSids) {
|
|
86
|
-
debug(`Getting Sid strings from SID fields`);
|
|
80
|
+
debug(`Getting Sid strings from SID fields`);
|
|
87
81
|
|
|
82
|
+
// Map SID fields to valid sidStrings, filter out empty strings
|
|
88
83
|
const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);
|
|
89
84
|
return sidStrings;
|
|
90
|
-
|
|
91
85
|
function toSidString(field) {
|
|
92
86
|
debug(`Getting string from a field`);
|
|
93
87
|
return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidString(field) : '';
|
|
94
|
-
|
|
95
88
|
function createSidString(field) {
|
|
96
89
|
debug(`Creating string from a field`);
|
|
97
90
|
const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
|
|
@@ -101,14 +94,12 @@ function bibSourceIds(record) {
|
|
|
101
94
|
debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
|
|
102
95
|
return cleanedSfC.concat(cleanedSfB);
|
|
103
96
|
}
|
|
104
|
-
|
|
105
97
|
function removeSourcePrefix(subfieldValue) {
|
|
106
98
|
const sourcePrefixRegex = /^(?<sourcePrefix>\([A-Za-z0-9-]+\))(?<id>.+)$/u;
|
|
107
99
|
const normalizedValue = (0, _matchingUtils.testStringOrNumber)(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';
|
|
108
100
|
debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);
|
|
109
101
|
return normalizedValue;
|
|
110
102
|
}
|
|
111
|
-
|
|
112
103
|
function normalizeSidSubfieldValue(subfieldValue) {
|
|
113
104
|
debugData(`Normalizing ${subfieldValue}`);
|
|
114
105
|
const normalizeAwayRegex = /[- ]/u;
|
|
@@ -118,95 +109,88 @@ function bibSourceIds(record) {
|
|
|
118
109
|
}
|
|
119
110
|
}
|
|
120
111
|
}
|
|
121
|
-
|
|
122
112
|
function bibMelindaIds(record) {
|
|
123
113
|
// Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records
|
|
114
|
+
|
|
124
115
|
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');
|
|
125
116
|
const debugData = debug.extend('data');
|
|
126
|
-
debug(`Creating queries for MelindaIds`);
|
|
117
|
+
debug(`Creating queries for MelindaIds`);
|
|
118
|
+
|
|
119
|
+
// Note: Melinda-ID's for search queries are created just from records f035a's and f035z's
|
|
127
120
|
// Both (FI-MELINDA)- and FCC-prefixed forms are found
|
|
128
121
|
// f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA
|
|
129
|
-
|
|
130
122
|
const melindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
|
|
131
123
|
debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);
|
|
132
|
-
|
|
133
124
|
if (melindaIds.length < 1) {
|
|
134
125
|
debug(`No identifiers found, no queries created.`);
|
|
135
126
|
return [];
|
|
136
127
|
}
|
|
137
|
-
|
|
138
128
|
return (0, _candidateSearchUtils.toQueries)(melindaIds, 'melinda.melindaid');
|
|
139
|
-
}
|
|
140
|
-
// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?
|
|
141
|
-
|
|
129
|
+
}
|
|
142
130
|
|
|
131
|
+
// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05
|
|
132
|
+
// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?
|
|
143
133
|
function bibHostComponents(record) {
|
|
144
134
|
const id = getHostId();
|
|
145
135
|
return (0, _matchingUtils.testStringOrNumber)(id) ? [`melinda.partsofhost=${id}`] : [];
|
|
146
|
-
|
|
147
136
|
function getHostId() {
|
|
148
137
|
const [field] = record.get(/^773$/u);
|
|
149
|
-
|
|
150
138
|
if (field) {
|
|
151
139
|
const {
|
|
152
140
|
value
|
|
153
141
|
} = field.subfields.find(({
|
|
154
142
|
code
|
|
155
143
|
}) => code === 'w') || {};
|
|
156
|
-
|
|
157
144
|
if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FI-MELINDA\)/u.test(String(value))) {
|
|
158
145
|
return String(value).replace(/^\(FI-MELINDA\)/u, '');
|
|
159
146
|
}
|
|
160
|
-
|
|
161
147
|
if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FIN01\)/u.test(String(value))) {
|
|
162
148
|
return String(value).replace(/^\(FIN01\)/u, '');
|
|
163
149
|
}
|
|
164
|
-
|
|
165
150
|
return false;
|
|
166
151
|
}
|
|
167
|
-
|
|
168
152
|
return false;
|
|
169
153
|
}
|
|
170
|
-
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to
|
|
171
157
|
// (probably) to *headings* index TIT
|
|
172
158
|
// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search
|
|
159
|
+
|
|
173
160
|
// Headings index TIT drops articles etc. from the start of the title according to the filing indicator
|
|
174
161
|
// Currently filing indicator is not implemented - if the title starts with an article and the Melinda
|
|
175
162
|
// record is correctly catalogued using a filing indicator -> dc.title search won't match
|
|
176
163
|
|
|
177
|
-
|
|
178
164
|
function bibTitle(record) {
|
|
179
165
|
const title = getTitle();
|
|
180
166
|
const booleanStartWords = ['and', 'or', 'nor', 'not'];
|
|
181
|
-
|
|
182
167
|
if ((0, _matchingUtils.testStringOrNumber)(title)) {
|
|
183
|
-
const formatted = String(title).replace(/[^\w\s\p{Alphabetic}]/gu, '')
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word)); // Prevent too many matches by having a minimum length requirement
|
|
168
|
+
const formatted = String(title).replace(/[^\w\s\p{Alphabetic}]/gu, '')
|
|
169
|
+
// Clean up concurrent spaces from fe. subfield changes
|
|
170
|
+
.replace(/ +/gu, ' ').trim().slice(0, 30).trim();
|
|
187
171
|
|
|
172
|
+
// use word search for titles starting with a boolean
|
|
173
|
+
const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));
|
|
174
|
+
// Prevent too many matches by having a minimum length requirement
|
|
188
175
|
return formatted.length >= 5 ? [`dc.title="${useWordSearch ? '' : '^'}${formatted}*"`] : [];
|
|
189
176
|
}
|
|
190
|
-
|
|
191
177
|
return [];
|
|
192
|
-
|
|
193
178
|
function getTitle() {
|
|
194
179
|
const [field] = record.get(/^245$/u);
|
|
195
|
-
|
|
196
180
|
if (field) {
|
|
197
181
|
return field.subfields.filter(({
|
|
198
182
|
code
|
|
199
183
|
}) => ['a', 'b'].includes(code)).map(({
|
|
200
184
|
value
|
|
201
|
-
}) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
|
|
185
|
+
}) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
|
|
186
|
+
// In Melinda's index subfield separators are indexed as ' '
|
|
202
187
|
.join(' ');
|
|
203
188
|
}
|
|
204
|
-
|
|
205
189
|
return false;
|
|
206
190
|
}
|
|
207
|
-
}
|
|
208
|
-
|
|
191
|
+
}
|
|
209
192
|
|
|
193
|
+
// eslint-disable-next-line max-statements
|
|
210
194
|
function bibStandardIdentifiers(record) {
|
|
211
195
|
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');
|
|
212
196
|
const debugData = debug.extend('data');
|
|
@@ -217,33 +201,27 @@ function bibStandardIdentifiers(record) {
|
|
|
217
201
|
debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);
|
|
218
202
|
debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);
|
|
219
203
|
debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);
|
|
220
|
-
|
|
221
204
|
if (uniqueIdentifiers.length < 1) {
|
|
222
205
|
debug(`No identifiers found, no queries created.`);
|
|
223
206
|
return [];
|
|
224
207
|
}
|
|
225
|
-
|
|
226
208
|
return (0, _candidateSearchUtils.toQueries)(uniqueIdentifiers, 'dc.identifier');
|
|
227
|
-
|
|
228
209
|
function toIdentifiers({
|
|
229
210
|
tag,
|
|
230
211
|
subfields
|
|
231
212
|
}) {
|
|
232
213
|
const issnIsbnReqExp = /^[A-Za-z0-9-]+$/u;
|
|
233
214
|
const otherIdReqExp = /^[A-Za-z0-9-:]+$/u;
|
|
234
|
-
|
|
235
215
|
if (tag === '022') {
|
|
236
216
|
return subfields.filter(sub => ['a', 'z', 'y'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
|
|
237
217
|
value
|
|
238
218
|
}) => String(value));
|
|
239
219
|
}
|
|
240
|
-
|
|
241
220
|
if (tag === '020') {
|
|
242
221
|
return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
|
|
243
222
|
value
|
|
244
223
|
}) => String(value));
|
|
245
224
|
}
|
|
246
|
-
|
|
247
225
|
return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && otherIdReqExp.test(String(sub.value))).map(({
|
|
248
226
|
value
|
|
249
227
|
}) => String(value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bib.js","names":["bibSourceIds","record","debug","createDebugLogger","debugData","extend","fSids","get","length","JSON","stringify","toSidQueries","sidStrings","getSidStrings","sidQueries","toQueries","map","toSidString","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidString","sfC","getSubfieldValues","sfB","cleanedSfC","removeSourcePrefix","normalizeSidSubfieldValue","cleanedSfB","concat","subfieldValue","sourcePrefixRegex","normalizedValue","testStringOrNumber","String","replace","normalizeAwayRegex","bibMelindaIds","melindaIds","getMelindaIdsF035","bibHostComponents","id","getHostId","value","subfields","find","code","test","bibTitle","title","getTitle","booleanStartWords","formatted","trim","slice","useWordSearch","some","word","toLowerCase","startsWith","includes","join","bibStandardIdentifiers","fields","identifiers","toIdentifiers","uniqueIdentifiers","Set","tag","issnIsbnReqExp","otherIdReqExp","sub"],"sources":["../../../src/candidate-search/query-list/bib.js"],"sourcesContent":["\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues, testStringOrNumber} from '../../matching-utils';\n\n\nexport function bibSourceIds(record) {\n\n /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records\n SID-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 SID__ $c /10024/508126 $ REPO_THESEUS\n\n In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:\n Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted\n\n 1234567helka\n 1077305sata\n VER999999FIKV\n /10024/508126REPO_THESEUS\n\n Note: 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\n */\n\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');\n const debugData = debug.extend('data');\n //const debugInfo = debug.extend('info');\n\n debug(`Creating queries for sourceid's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n return fSids.length > 0 ? toSidQueries(fSids) : [];\n\n function toSidQueries(fSids) {\n debug(`Creating actual queries for sourceid's`);\n\n const sidStrings = getSidStrings(fSids);\n\n if (sidStrings.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n const sidQueries = toQueries(sidStrings, 'melinda.sourceid');\n\n return sidQueries;\n\n function getSidStrings(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to valid sidStrings, filter out empty strings\n const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);\n return sidStrings;\n\n function toSidString(field) {\n debug(`Getting string from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidString(field) : '';\n\n function createSidString(field) {\n debug(`Creating string from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));\n const cleanedSfB = normalizeSidSubfieldValue(sfB);\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n return cleanedSfC.concat(cleanedSfB);\n }\n\n function removeSourcePrefix(subfieldValue) {\n const sourcePrefixRegex = (/^(?<sourcePrefix>\\([A-Za-z0-9-]+\\))(?<id>.+)$/u);\n const normalizedValue = testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';\n debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);\n return normalizedValue;\n }\n\n function normalizeSidSubfieldValue(subfieldValue) {\n debugData(`Normalizing ${subfieldValue}`);\n const normalizeAwayRegex = (/[- ]/u);\n return testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';\n }\n\n }\n }\n }\n}\n\nexport function bibMelindaIds(record) {\n // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');\n const debugData = debug.extend('data');\n debug(`Creating queries for MelindaIds`);\n\n // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's\n // Both (FI-MELINDA)- and FCC-prefixed forms are found\n // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA\n const melindaIds = getMelindaIdsF035(record);\n\n debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);\n\n if (melindaIds.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(melindaIds, 'melinda.melindaid');\n}\n\n\n// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05\n// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?\nexport function bibHostComponents(record) {\n const id = getHostId();\n return testStringOrNumber(id) ? [`melinda.partsofhost=${id}`] : [];\n\n function getHostId() {\n const [field] = record.get(/^773$/u);\n\n if (field) {\n const {value} = field.subfields.find(({code}) => code === 'w') || {};\n\n if (testStringOrNumber(value) && (/^\\(FI-MELINDA\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FI-MELINDA\\)/u, '');\n }\n\n if (testStringOrNumber(value) && (/^\\(FIN01\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FIN01\\)/u, '');\n }\n\n return false;\n }\n return false;\n }\n}\n\n// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to\n// (probably) to *headings* index TIT\n// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search\n\n// Headings index TIT drops articles etc. from the start of the title according to the filing indicator\n// Currently filing indicator is not implemented - if the title starts with an article and the Melinda\n// record is correctly catalogued using a filing indicator -> dc.title search won't match\n\nexport function bibTitle(record) {\n const title = getTitle();\n const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\n if (testStringOrNumber(title)) {\n const formatted = String(title)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for titles starting with a boolean\n const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n // Prevent too many matches by having a minimum length requirement\n return formatted.length >= 5 ? [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`] : [];\n }\n\n return [];\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n return field.subfields\n .filter(({code}) => ['a', 'b'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n }\n return false;\n }\n}\n\n// eslint-disable-next-line max-statements\nexport function bibStandardIdentifiers(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');\n const debugData = debug.extend('data');\n debug(`Creating queries for standard identifiers`);\n\n const fields = record.get(/^(?<def>020|022|024)$/u);\n const identifiers = [].concat(...fields.map(toIdentifiers));\n const uniqueIdentifiers = [...new Set(identifiers)];\n\n debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);\n debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);\n debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);\n\n if (uniqueIdentifiers.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(uniqueIdentifiers, 'dc.identifier');\n\n function toIdentifiers({tag, subfields}) {\n const issnIsbnReqExp = (/^[A-Za-z0-9-]+$/u);\n const otherIdReqExp = (/^[A-Za-z0-9-:]+$/u);\n\n if (tag === '022') {\n return subfields\n .filter(sub => ['a', 'z', 'y'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n if (tag === '020') {\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && otherIdReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n}\n"],"mappings":";;;;;;;;;;;AA4BA;;AACA;;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;AAMO,SAASA,YAAT,CAAsBC,MAAtB,EAA8B;EAEnC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAQE,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAkB,qEAAlB,CAAd;EACA,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAN,CAAa,MAAb,CAAlB,CA3BmC,CA4BnC;;EAEAH,KAAK,CAAE,iCAAF,CAAL;EAEA,MAAMI,KAAK,GAAGL,MAAM,CAACM,GAAP,CAAW,KAAX,CAAd;EACAH,SAAS,CAAE,eAAcE,KAAK,CAACE,MAAO,MAAKC,IAAI,CAACC,SAAL,CAAeJ,KAAf,CAAsB,EAAxD,CAAT;EAEA,OAAOA,KAAK,CAACE,MAAN,GAAe,CAAf,GAAmBG,YAAY,CAACL,KAAD,CAA/B,GAAyC,EAAhD;;EAEA,SAASK,YAAT,CAAsBL,KAAtB,EAA6B;IAC3BJ,KAAK,CAAE,wCAAF,CAAL;IAEA,MAAMU,UAAU,GAAGC,aAAa,CAACP,KAAD,CAAhC;;IAEA,IAAIM,UAAU,CAACJ,MAAX,GAAoB,CAAxB,EAA2B;MACzBN,KAAK,CAAE,2CAAF,CAAL;MACA,OAAO,EAAP;IACD;;IAED,MAAMY,UAAU,GAAG,IAAAC,+BAAA,EAAUH,UAAV,EAAsB,kBAAtB,CAAnB;IAEA,OAAOE,UAAP;;IAEA,SAASD,aAAT,CAAuBP,KAAvB,EAA8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D,KAAaT,MAAM,CAACS,KAAD,CAFnB,CAAP;IAGD;;IAED,OAAOC,SAAS,CACb3B,MADI,CACGsD,GAAG,IAAI,CAAC,GAAD,EAAM,GAAN,EAAWX,QAAX,CAAoBW,GAAG,CAACzB,IAAxB,KAAiC,IAAAb,iCAAA,EAAmBsC,GAAG,CAAC5B,KAAvB,CAAjC,IAAkE2B,aAAa,CAACvB,IAAd,CAAmBb,MAAM,CAACqC,GAAG,CAAC5B,KAAL,CAAzB,CAD5E,EAEJ5B,GAFI,CAEA,CAAC;MAAC4B;IAAD,CAAD,KAAaT,MAAM,CAACS,KAAD,CAFnB,CAAP;EAGD;AACF"}
|
|
1
|
+
{"version":3,"file":"bib.js","names":["bibSourceIds","record","debug","createDebugLogger","debugData","extend","fSids","get","length","JSON","stringify","toSidQueries","sidStrings","getSidStrings","sidQueries","toQueries","map","toSidString","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidString","sfC","getSubfieldValues","sfB","cleanedSfC","removeSourcePrefix","normalizeSidSubfieldValue","cleanedSfB","concat","subfieldValue","sourcePrefixRegex","normalizedValue","testStringOrNumber","String","replace","normalizeAwayRegex","bibMelindaIds","melindaIds","getMelindaIdsF035","bibHostComponents","id","getHostId","value","subfields","find","code","test","bibTitle","title","getTitle","booleanStartWords","formatted","trim","slice","useWordSearch","some","word","toLowerCase","startsWith","includes","join","bibStandardIdentifiers","fields","identifiers","toIdentifiers","uniqueIdentifiers","Set","tag","issnIsbnReqExp","otherIdReqExp","sub"],"sources":["../../../src/candidate-search/query-list/bib.js"],"sourcesContent":["\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues, testStringOrNumber} from '../../matching-utils';\n\n\nexport function bibSourceIds(record) {\n\n /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records\n SID-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 SID__ $c /10024/508126 $ REPO_THESEUS\n\n In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:\n Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted\n\n 1234567helka\n 1077305sata\n VER999999FIKV\n /10024/508126REPO_THESEUS\n\n Note: 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\n */\n\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');\n const debugData = debug.extend('data');\n //const debugInfo = debug.extend('info');\n\n debug(`Creating queries for sourceid's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n return fSids.length > 0 ? toSidQueries(fSids) : [];\n\n function toSidQueries(fSids) {\n debug(`Creating actual queries for sourceid's`);\n\n const sidStrings = getSidStrings(fSids);\n\n if (sidStrings.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n const sidQueries = toQueries(sidStrings, 'melinda.sourceid');\n\n return sidQueries;\n\n function getSidStrings(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to valid sidStrings, filter out empty strings\n const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);\n return sidStrings;\n\n function toSidString(field) {\n debug(`Getting string from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidString(field) : '';\n\n function createSidString(field) {\n debug(`Creating string from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));\n const cleanedSfB = normalizeSidSubfieldValue(sfB);\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n return cleanedSfC.concat(cleanedSfB);\n }\n\n function removeSourcePrefix(subfieldValue) {\n const sourcePrefixRegex = (/^(?<sourcePrefix>\\([A-Za-z0-9-]+\\))(?<id>.+)$/u);\n const normalizedValue = testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';\n debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);\n return normalizedValue;\n }\n\n function normalizeSidSubfieldValue(subfieldValue) {\n debugData(`Normalizing ${subfieldValue}`);\n const normalizeAwayRegex = (/[- ]/u);\n return testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';\n }\n\n }\n }\n }\n}\n\nexport function bibMelindaIds(record) {\n // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');\n const debugData = debug.extend('data');\n debug(`Creating queries for MelindaIds`);\n\n // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's\n // Both (FI-MELINDA)- and FCC-prefixed forms are found\n // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA\n const melindaIds = getMelindaIdsF035(record);\n\n debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);\n\n if (melindaIds.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(melindaIds, 'melinda.melindaid');\n}\n\n\n// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05\n// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?\nexport function bibHostComponents(record) {\n const id = getHostId();\n return testStringOrNumber(id) ? [`melinda.partsofhost=${id}`] : [];\n\n function getHostId() {\n const [field] = record.get(/^773$/u);\n\n if (field) {\n const {value} = field.subfields.find(({code}) => code === 'w') || {};\n\n if (testStringOrNumber(value) && (/^\\(FI-MELINDA\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FI-MELINDA\\)/u, '');\n }\n\n if (testStringOrNumber(value) && (/^\\(FIN01\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FIN01\\)/u, '');\n }\n\n return false;\n }\n return false;\n }\n}\n\n// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to\n// (probably) to *headings* index TIT\n// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search\n\n// Headings index TIT drops articles etc. from the start of the title according to the filing indicator\n// Currently filing indicator is not implemented - if the title starts with an article and the Melinda\n// record is correctly catalogued using a filing indicator -> dc.title search won't match\n\nexport function bibTitle(record) {\n const title = getTitle();\n const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\n if (testStringOrNumber(title)) {\n const formatted = String(title)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for titles starting with a boolean\n const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n // Prevent too many matches by having a minimum length requirement\n return formatted.length >= 5 ? [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`] : [];\n }\n\n return [];\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n return field.subfields\n .filter(({code}) => ['a', 'b'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n }\n return false;\n }\n}\n\n// eslint-disable-next-line max-statements\nexport function bibStandardIdentifiers(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');\n const debugData = debug.extend('data');\n debug(`Creating queries for standard identifiers`);\n\n const fields = record.get(/^(?<def>020|022|024)$/u);\n const identifiers = [].concat(...fields.map(toIdentifiers));\n const uniqueIdentifiers = [...new Set(identifiers)];\n\n debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);\n debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);\n debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);\n\n if (uniqueIdentifiers.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(uniqueIdentifiers, 'dc.identifier');\n\n function toIdentifiers({tag, subfields}) {\n const issnIsbnReqExp = (/^[A-Za-z0-9-]+$/u);\n const otherIdReqExp = (/^[A-Za-z0-9-:]+$/u);\n\n if (tag === '022') {\n return subfields\n .filter(sub => ['a', 'z', 'y'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n if (tag === '020') {\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && otherIdReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n}\n"],"mappings":";;;;;;;;;;AA4BA;AACA;AACA;AAA8H;AA7B9H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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H5B,GAAG,CAAC,CAAC;MAAC4B;IAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;EACpC;AACF"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
4
|
-
|
|
5
4
|
var _fixura = require("@natlibfi/fixura");
|
|
6
|
-
|
|
7
5
|
var _chai = require("chai");
|
|
8
|
-
|
|
9
6
|
var _marcRecord = require("@natlibfi/marc-record");
|
|
10
|
-
|
|
11
7
|
var generators = _interopRequireWildcard(require("./bib"));
|
|
12
|
-
|
|
13
8
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
|
|
15
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
|
|
17
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
11
|
/**
|
|
20
12
|
*
|
|
21
13
|
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
@@ -43,6 +35,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
43
35
|
* for the JavaScript code in this file.
|
|
44
36
|
*
|
|
45
37
|
*/
|
|
38
|
+
|
|
46
39
|
describe('candidate-search/query-list/bib/', () => {
|
|
47
40
|
(0, _fixugen.default)({
|
|
48
41
|
path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
|
|
@@ -60,11 +53,9 @@ describe('candidate-search/query-list/bib/', () => {
|
|
|
60
53
|
const record = new _marcRecord.MarcRecord(inputRecord, {
|
|
61
54
|
subfieldValues: false
|
|
62
55
|
});
|
|
63
|
-
|
|
64
56
|
if (!enabled) {
|
|
65
57
|
return;
|
|
66
58
|
}
|
|
67
|
-
|
|
68
59
|
(0, _chai.expect)(generate(record)).to.eql(expectedQuery);
|
|
69
60
|
}
|
|
70
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bib.spec.js","names":["describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","generators","record","MarcRecord","subfieldValues","expect","to","eql"],"sources":["../../../src/candidate-search/query-list/bib.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 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"],"mappings":";;AA4BA
|
|
1
|
+
{"version":3,"file":"bib.spec.js","names":["describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","generators","record","MarcRecord","subfieldValues","expect","to","eql"],"sources":["../../../src/candidate-search/query-list/bib.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 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"],"mappings":";;AA4BA;AACA;AACA;AACA;AACA;AAAoC;AAAA;AAAA;AAhCpC;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,kCAAkC,EAAE,MAAM;EACjD,IAAAC,gBAAa,EAAC;IACZC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,KAAK,CAAC;IAC7FC,eAAe,EAAE,IAAI;IACrBC,MAAM,EAAE;MACNC,MAAM,EAAEC,eAAO,CAACC;IAClB,CAAC;IACDC,QAAQ,EAAE,CAAC;MAACC,IAAI;MAAEC,WAAW;MAAEC,aAAa;MAAEC,OAAO,GAAG;IAAI,CAAC,KAAK;MAChE,MAAMC,QAAQ,GAAGC,UAAU,CAACL,IAAI,CAAC;MACjC,MAAMM,MAAM,GAAG,IAAIC,sBAAU,CAACN,WAAW,EAAE;QAACO,cAAc,EAAE;MAAK,CAAC,CAAC;MAEnE,IAAI,CAACL,OAAO,EAAE;QACZ;MACF;MAEA,IAAAM,YAAM,EAACL,QAAQ,CAACE,MAAM,CAAC,CAAC,CAACI,EAAE,CAACC,GAAG,CAACT,aAAa,CAAC;IAChD;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.searchTypes = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var bib = _interopRequireWildcard(require("./bib"));
|
|
9
|
-
|
|
10
8
|
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
|
-
|
|
12
9
|
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
|
-
|
|
14
10
|
/**
|
|
15
11
|
*
|
|
16
12
|
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
@@ -38,6 +34,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
38
34
|
* for the JavaScript code in this file.
|
|
39
35
|
*
|
|
40
36
|
*/
|
|
37
|
+
|
|
41
38
|
const searchTypes = {
|
|
42
39
|
bib: {
|
|
43
40
|
standardIdentifiers: 'bibStandardIdentifiers',
|
|
@@ -48,20 +45,17 @@ const searchTypes = {
|
|
|
48
45
|
}
|
|
49
46
|
};
|
|
50
47
|
exports.searchTypes = searchTypes;
|
|
51
|
-
|
|
52
48
|
var _default = (record, searchSpec) => {
|
|
53
|
-
const extractors = {
|
|
49
|
+
const extractors = {
|
|
50
|
+
...bib
|
|
54
51
|
};
|
|
55
52
|
return searchSpec.map(generateQueryExtractor).map(cb => cb(record)).flat();
|
|
56
|
-
|
|
57
53
|
function generateQueryExtractor(type) {
|
|
58
54
|
if (extractors[type]) {
|
|
59
55
|
return extractors[type];
|
|
60
56
|
}
|
|
61
|
-
|
|
62
57
|
throw new Error(`Unknown search type: ${type}`);
|
|
63
58
|
}
|
|
64
59
|
};
|
|
65
|
-
|
|
66
60
|
exports.default = _default;
|
|
67
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["searchTypes","bib","standardIdentifiers","hostComponents","title","melindaId","sourceIds","record","searchSpec","extractors","map","generateQueryExtractor","cb","flat","type","Error"],"sources":["../../../src/candidate-search/query-list/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-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 * 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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["searchTypes","bib","standardIdentifiers","hostComponents","title","melindaId","sourceIds","record","searchSpec","extractors","map","generateQueryExtractor","cb","flat","type","Error"],"sources":["../../../src/candidate-search/query-list/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-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 * 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"],"mappings":";;;;;;AA4BA;AAA6B;AAAA;AA5B7B;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;EACzBC,GAAG,EAAE;IACHC,mBAAmB,EAAE,wBAAwB;IAC7CC,cAAc,EAAE,mBAAmB;IACnCC,KAAK,EAAE,UAAU;IACjBC,SAAS,EAAE,eAAe;IAC1BC,SAAS,EAAE;EACb;AACF,CAAC;AAAC;AAAA,eAEa,CAACC,MAAM,EAAEC,UAAU,KAAK;EACrC,MAAMC,UAAU,GAAG;IAAC,GAAGR;EAAG,CAAC;EAE3B,OAAOO,UAAU,CACdE,GAAG,CAACC,sBAAsB,CAAC,CAC3BD,GAAG,CAACE,EAAE,IAAIA,EAAE,CAACL,MAAM,CAAC,CAAC,CACrBM,IAAI,EAAE;EAET,SAASF,sBAAsB,CAACG,IAAI,EAAE;IACpC,IAAIL,UAAU,CAACK,IAAI,CAAC,EAAE;MACpB,OAAOL,UAAU,CAACK,IAAI,CAAC;IACzB;IAEA,MAAM,IAAIC,KAAK,CAAE,wBAAuBD,IAAK,EAAC,CAAC;EACjD;AACF,CAAC;AAAA"}
|