@natlibfi/melinda-record-matching 4.3.5 → 5.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.github/workflows/melinda-node-tests.yml +11 -7
  2. package/eslint.config.js +52 -0
  3. package/example.env +4 -0
  4. package/package.json +22 -90
  5. package/src/candidate-search/choose-queries.js +1 -3
  6. package/src/candidate-search/index.js +63 -89
  7. package/src/candidate-search/{index.spec.js → index.test.js} +19 -18
  8. package/src/candidate-search/query-list/bib.js +10 -4
  9. package/src/candidate-search/query-list/{bib.spec.js → bib.test.js} +8 -7
  10. package/src/candidate-search/query-list/component.js +127 -0
  11. package/src/candidate-search/query-list/index.js +23 -9
  12. package/src/cli.js +177 -0
  13. package/src/index.js +22 -37
  14. package/src/{index.spec.js → index.test.js} +11 -14
  15. package/src/match-detection/features/bib/all-source-ids.js +2 -2
  16. package/src/match-detection/features/bib/authors.js +3 -2
  17. package/src/match-detection/features/bib/index.js +16 -16
  18. package/src/match-detection/features/bib/{index.spec.js → index.test.js} +7 -6
  19. package/src/match-detection/features/bib/isbn.js +2 -2
  20. package/src/match-detection/features/bib/issn.js +1 -1
  21. package/src/match-detection/features/bib/language.js +5 -5
  22. package/src/match-detection/features/bib/media-type.js +1 -1
  23. package/src/match-detection/features/bib/melinda-id.js +1 -1
  24. package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -5
  25. package/src/match-detection/features/bib/other-standard-identifier.js +1 -1
  26. package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +6 -6
  27. package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -1
  28. package/src/match-detection/features/bib/publication-time.js +1 -1
  29. package/src/match-detection/features/bib/standard-identifier-factory.js +1 -2
  30. package/src/match-detection/features/bib/title-version-original.js +2 -1
  31. package/src/match-detection/features/bib/title.js +6 -5
  32. package/src/match-detection/features/index.js +1 -1
  33. package/src/match-detection/index.js +1 -1
  34. package/src/match-detection/{index.spec.js → index.test.js} +9 -8
  35. package/src/matching-utils.js +8 -9
  36. package/dist/candidate-search/candidate-search-utils.js +0 -29
  37. package/dist/candidate-search/candidate-search-utils.js.map +0 -1
  38. package/dist/candidate-search/choose-queries.js +0 -122
  39. package/dist/candidate-search/choose-queries.js.map +0 -1
  40. package/dist/candidate-search/index.js +0 -260
  41. package/dist/candidate-search/index.js.map +0 -1
  42. package/dist/candidate-search/index.spec.js +0 -133
  43. package/dist/candidate-search/index.spec.js.map +0 -1
  44. package/dist/candidate-search/query-list/bib.js +0 -458
  45. package/dist/candidate-search/query-list/bib.js.map +0 -1
  46. package/dist/candidate-search/query-list/bib.spec.js +0 -46
  47. package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
  48. package/dist/candidate-search/query-list/index.js +0 -47
  49. package/dist/candidate-search/query-list/index.js.map +0 -1
  50. package/dist/index.js +0 -555
  51. package/dist/index.js.map +0 -1
  52. package/dist/index.spec.js +0 -99
  53. package/dist/index.spec.js.map +0 -1
  54. package/dist/match-detection/features/bib/all-source-ids.js +0 -91
  55. package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
  56. package/dist/match-detection/features/bib/authors.js +0 -86
  57. package/dist/match-detection/features/bib/authors.js.map +0 -1
  58. package/dist/match-detection/features/bib/bibliographic-level.js +0 -15
  59. package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
  60. package/dist/match-detection/features/bib/host-component.js +0 -15
  61. package/dist/match-detection/features/bib/host-component.js.map +0 -1
  62. package/dist/match-detection/features/bib/index.js +0 -119
  63. package/dist/match-detection/features/bib/index.js.map +0 -1
  64. package/dist/match-detection/features/bib/index.spec.js +0 -65
  65. package/dist/match-detection/features/bib/index.spec.js.map +0 -1
  66. package/dist/match-detection/features/bib/isbn.js +0 -49
  67. package/dist/match-detection/features/bib/isbn.js.map +0 -1
  68. package/dist/match-detection/features/bib/issn.js +0 -24
  69. package/dist/match-detection/features/bib/issn.js.map +0 -1
  70. package/dist/match-detection/features/bib/language.js +0 -113
  71. package/dist/match-detection/features/bib/language.js.map +0 -1
  72. package/dist/match-detection/features/bib/media-type.js +0 -56
  73. package/dist/match-detection/features/bib/media-type.js.map +0 -1
  74. package/dist/match-detection/features/bib/melinda-id.js +0 -21
  75. package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
  76. package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -62
  77. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
  78. package/dist/match-detection/features/bib/other-standard-identifier.js +0 -25
  79. package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
  80. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -229
  81. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +0 -1
  82. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +0 -44
  83. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +0 -1
  84. package/dist/match-detection/features/bib/publication-time.js +0 -21
  85. package/dist/match-detection/features/bib/publication-time.js.map +0 -1
  86. package/dist/match-detection/features/bib/record-type.js +0 -18
  87. package/dist/match-detection/features/bib/record-type.js.map +0 -1
  88. package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -188
  89. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
  90. package/dist/match-detection/features/bib/title-version-original.js +0 -52
  91. package/dist/match-detection/features/bib/title-version-original.js.map +0 -1
  92. package/dist/match-detection/features/bib/title.js +0 -70
  93. package/dist/match-detection/features/bib/title.js.map +0 -1
  94. package/dist/match-detection/features/index.js +0 -11
  95. package/dist/match-detection/features/index.js.map +0 -1
  96. package/dist/match-detection/index.js +0 -174
  97. package/dist/match-detection/index.js.map +0 -1
  98. package/dist/match-detection/index.spec.js +0 -63
  99. package/dist/match-detection/index.spec.js.map +0 -1
  100. package/dist/matching-utils.js +0 -115
  101. package/dist/matching-utils.js.map +0 -1
@@ -1,458 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.bibAuthors = bibAuthors;
7
- exports.bibHostComponents = bibHostComponents;
8
- exports.bibMelindaIds = bibMelindaIds;
9
- exports.bibPublishers = bibPublishers;
10
- exports.bibSourceIds = bibSourceIds;
11
- exports.bibStandardIdentifiers = bibStandardIdentifiers;
12
- exports.bibTitle = bibTitle;
13
- exports.bibTitleAuthor = bibTitleAuthor;
14
- exports.bibTitleAuthorPublisher = bibTitleAuthorPublisher;
15
- exports.bibTitleAuthorYear = bibTitleAuthorYear;
16
- exports.bibTitleAuthorYearAlternates = bibTitleAuthorYearAlternates;
17
- exports.bibYear = bibYear;
18
- exports.checkUseWordSearch = checkUseWordSearch;
19
- var _debug = _interopRequireDefault(require("debug"));
20
- var _candidateSearchUtils = require("../candidate-search-utils");
21
- var _matchingUtils = require("../../matching-utils");
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query');
24
- function bibSourceIds(record) {
25
- /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records
26
- SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
27
- SID__ $c 123457 $b helka
28
- SID__ $c (ANDL100020)1077305 $b sata
29
- SID__ $c VER999999 $ FI-KV
30
- SID__ $c /10024/508126 $ REPO_THESEUS
31
- In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:
32
- Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted
33
- 1234567helka
34
- 1077305sata
35
- VER999999FIKV
36
- /10024/508126REPO_THESEUS
37
- Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,
38
- existence of a SID field depends on how the record has been added to Melinda and how it has been handled
39
- afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
40
- after the matching record is removed from the local db.
41
- */
42
-
43
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');
44
- const debugData = debug.extend('data');
45
- //const debugInfo = debug.extend('info');
46
-
47
- debug(`Creating queries for sourceid's`);
48
- const fSids = record.get('SID');
49
- debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
50
- return fSids.length > 0 ? toSidQueries(fSids) : [];
51
- function toSidQueries(fSids) {
52
- debug(`Creating actual queries for sourceid's`);
53
- const sidStrings = getSidStrings(fSids);
54
- if (sidStrings.length < 1) {
55
- debug(`No identifiers found, no queries created.`);
56
- return [];
57
- }
58
- const sidQueries = (0, _candidateSearchUtils.toQueries)(sidStrings, 'melinda.sourceid');
59
- return sidQueries;
60
- function getSidStrings(fSids) {
61
- debug(`Getting Sid strings from SID fields`);
62
-
63
- // Map SID fields to valid sidStrings, filter out empty strings
64
- const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);
65
- return sidStrings;
66
- function toSidString(field) {
67
- debug(`Getting string from a field`);
68
- return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidString(field) : '';
69
- function createSidString(field) {
70
- debug(`Creating string from a field`);
71
- const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
72
- const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
73
- const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));
74
- const cleanedSfB = normalizeSidSubfieldValue(sfB);
75
- debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
76
- return cleanedSfC.concat(cleanedSfB);
77
- }
78
- function removeSourcePrefix(subfieldValue) {
79
- const sourcePrefixRegex = /^(?<sourcePrefix>\([A-Za-z0-9-]+\))(?<id>.+)$/u;
80
- const normalizedValue = (0, _matchingUtils.testStringOrNumber)(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';
81
- debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);
82
- return normalizedValue;
83
- }
84
- function normalizeSidSubfieldValue(subfieldValue) {
85
- debugData(`Normalizing ${subfieldValue}`);
86
- const normalizeAwayRegex = /[- ]/u;
87
- return (0, _matchingUtils.testStringOrNumber)(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';
88
- }
89
- }
90
- }
91
- }
92
- }
93
- function bibMelindaIds(record) {
94
- // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records
95
-
96
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');
97
- const debugData = debug.extend('data');
98
- debug(`Creating queries for MelindaIds`);
99
-
100
- // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's
101
- // Both (FI-MELINDA)- and FCC-prefixed forms are found
102
- // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA
103
- const melindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
104
- debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);
105
- if (melindaIds.length < 1) {
106
- debug(`No identifiers found, no queries created.`);
107
- return [];
108
- }
109
- return (0, _candidateSearchUtils.toQueries)(melindaIds, 'melinda.melindaid');
110
- }
111
-
112
- // bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05
113
- // bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?
114
- function bibHostComponents(record) {
115
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents');
116
- const debugData = debug.extend('data');
117
- debug(`Creating queries for hostIds`);
118
- const id = getHostId();
119
- debugData(`Found id: ${JSON.stringify(id)}`);
120
- return (0, _matchingUtils.testStringOrNumber)(id) ? [`melinda.partsofhost=${id}`] : [];
121
- function getHostId() {
122
- const [field] = record.get(/^773$/u);
123
- if (field) {
124
- const {
125
- value
126
- } = field.subfields.find(({
127
- code
128
- }) => code === 'w') || {};
129
- if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FI-MELINDA\)/u.test(String(value))) {
130
- return String(value).replace(/^\(FI-MELINDA\)/u, '');
131
- }
132
- if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FIN01\)/u.test(String(value))) {
133
- return String(value).replace(/^\(FIN01\)/u, '');
134
- }
135
- return false;
136
- }
137
- return false;
138
- }
139
- }
140
-
141
- // SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to
142
- // (probably) to *headings* index TIT
143
- // - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search
144
-
145
- // Headings index TIT drops articles etc. from the start of the title according to the filing indicator
146
- // Currently filing indicator is not implemented - if the title starts with an article and the Melinda
147
- // record is correctly catalogued using a filing indicator -> dc.title search won't match
148
-
149
- function bibTitle(record) {
150
- // We get author/publisher only when formatted title is shorter than 5 chars
151
- return bibTitleAuthorPublisher({
152
- record,
153
- onlyTitleLength: 5
154
- });
155
- }
156
- function bibTitleAuthor(record) {
157
- debug('bibTitleAuthor');
158
- // We use onlyTitleLength that is longer than our formatted length to
159
- // get an author or an publisher always
160
- return bibTitleAuthorPublisher({
161
- record,
162
- onlyTitleLength: 100
163
- });
164
- }
165
- function bibTitleAuthorYear(record) {
166
- debug('bibTitleAuthorYearAlternates');
167
- // We use onlyTitleLength that is longer than our formatted length to
168
- // get an author or an publisher always
169
-
170
- return bibTitleAuthorPublisher({
171
- record,
172
- onlyTitleLength: 100,
173
- addYear: true
174
- });
175
- }
176
- function bibTitleAuthorYearAlternates(record) {
177
- debug('bibTitleAuthorYearAlternates');
178
- // We use onlyTitleLength that is longer than our formatted length to
179
- // get an author or an publisher always
180
- const origQueryList = bibTitleAuthorPublisher({
181
- record,
182
- onlyTitleLength: 100,
183
- addYear: true,
184
- alternates: true,
185
- alternateQueries: []
186
- });
187
- debug(`${JSON.stringify(origQueryList)}`);
188
- return {
189
- queryList: Array.from(origQueryList).reverse(),
190
- queryListType: 'alternates'
191
- };
192
- }
193
- function bibTitleAuthorPublisher({
194
- record,
195
- onlyTitleLength,
196
- addYear = false,
197
- alternates = false,
198
- alternateQueries = []
199
- }) {
200
- debug(`bibTitleAuthorPublisher, onlyTitleLength: ${onlyTitleLength}, addYear: ${addYear}, alternates: ${alternates}`);
201
- const title = getTitle();
202
- if ((0, _matchingUtils.testStringOrNumber)(title)) {
203
- const formatted = String(title).replace(/[^\w\s\p{Alphabetic}]/gu, '')
204
- // Clean up concurrent spaces from fe. subfield changes
205
- .replace(/ +/gu, ' ').trim().slice(0, 30).trim();
206
-
207
- // use word search for titles starting with a boolean
208
- const useWordSearch = checkUseWordSearch(formatted);
209
- // Prevent too many matches / SRU crashing by having a minimum length
210
- // Note that currently this fails matching if there are no matches from previous matchers
211
- if (formatted.length >= onlyTitleLength && !alternates) {
212
- return [`dc.title="${useWordSearch ? '' : '^'}${formatted}*"`];
213
- }
214
- const queryIsOkAlone = formatted.length >= 5;
215
-
216
- // use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]
217
- const query = `dc.title="${useWordSearch || !queryIsOkAlone ? '' : '^'}${formatted}${queryIsOkAlone ? '*' : ''}"`;
218
- debug(`query: ${query}`);
219
- const newAlternateQueries = alternates ? [...alternateQueries, query] : alternateQueries;
220
- return addAuthorsToSearch({
221
- query,
222
- queryIsOkAlone,
223
- addYear,
224
- alternates,
225
- alternateQueries: newAlternateQueries
226
- });
227
- }
228
- return [];
229
- function addAuthorsToSearch({
230
- query,
231
- queryIsOkAlone = false,
232
- addYear = false,
233
- alternates = false,
234
- alternateQueries = []
235
- }) {
236
- debug('addAuthorsToSearch');
237
- const [authorQuery] = bibAuthors(record);
238
- if (authorQuery !== undefined) {
239
- if (addYear) {
240
- const newAlternateQueries = alternates ? [...alternateQueries, `${authorQuery} AND ${query}`] : alternateQueries;
241
- return addYearToSearch({
242
- query: `${authorQuery} AND ${query}`,
243
- queryIsOkAlone: true,
244
- alternates,
245
- alternateQueries: newAlternateQueries
246
- });
247
- }
248
- return alternates ? alternateQueries : [`${authorQuery} AND ${query}`];
249
- }
250
- return addPublisherToSearch({
251
- query,
252
- queryIsOkAlone,
253
- addYear,
254
- alternates,
255
- alternateQueries
256
- });
257
- //return [];
258
- }
259
- function addPublisherToSearch({
260
- query,
261
- queryIsOkAlone = false,
262
- addYear = false,
263
- alternates = false,
264
- alternateQueries = []
265
- }) {
266
- const [publisherQuery] = bibPublishers(record);
267
- if (publisherQuery !== undefined) {
268
- if (addYear) {
269
- const newAlternateQueries = alternates ? [...alternateQueries, `${publisherQuery} AND ${query}`] : alternateQueries;
270
- return addYearToSearch({
271
- query: `${publisherQuery} AND ${query}`,
272
- queryIsOkAlone: true,
273
- alternates,
274
- alternateQueries: newAlternateQueries
275
- });
276
- }
277
- return alternates ? alternateQueries : [`${publisherQuery} AND ${query}`];
278
- }
279
- if (queryIsOkAlone && !addYear) {
280
- return alternates ? alternateQueries : [`${query}`];
281
- }
282
- return addYearToSearch({
283
- query,
284
- queryIsOkAlone,
285
- alternates,
286
- alternateQueries
287
- });
288
- }
289
- function addYearToSearch({
290
- query,
291
- queryIsOkAlone = false,
292
- alternates = false,
293
- alternateQueries = []
294
- }) {
295
- const [yearQuery] = bibYear(record);
296
- if (yearQuery !== undefined) {
297
- const newAlternateQueries = alternates ? [...alternateQueries, `${yearQuery} AND ${query}`] : alternateQueries;
298
- return alternates ? newAlternateQueries : [`${yearQuery} AND ${query}`];
299
- }
300
- if (queryIsOkAlone) {
301
- return alternates ? alternateQueries : [`${query}`];
302
- }
303
- return [];
304
- }
305
- function getTitle() {
306
- const [field] = record.get(/^245$/u);
307
- if (field) {
308
- const titleString = field.subfields
309
- //.filter(({code}) => ['a', 'b', 'n', 'p'].includes(code))
310
- .filter(({
311
- code
312
- }) => ['a', 'b'].includes(code))
313
- //.filter(({code}) => ['a'].includes(code))
314
- .map(({
315
- value
316
- }) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
317
- // In Melinda's index subfield separators are indexed as ' '
318
- .join(' ');
319
- return titleString;
320
- }
321
- return false;
322
- }
323
- }
324
- function bibAuthors(record) {
325
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibAuthors');
326
- const debugData = debug.extend('data');
327
- debug(`Creating query for the first author`);
328
- //debugData(record);
329
-
330
- const author = getAuthor(record);
331
- if ((0, _matchingUtils.testStringOrNumber)(author)) {
332
- const formatted = String(author).replace(/[^\w\s\p{Alphabetic}]/gu, '')
333
- // Clean up concurrent spaces from fe. subfield changes
334
- .replace(/ +/gu, ' ').trim().slice(0, 30).trim();
335
-
336
- // use word search for authors starting with a boolean
337
- const useWordSearch = checkUseWordSearch(formatted);
338
- // Prevent too many matches by having a minimum length
339
- debugData(`Author string: ${formatted}`);
340
- if (formatted.length >= 5) {
341
- return [`dc.author="${useWordSearch ? '' : '^'}${formatted}*"`];
342
- }
343
- return [];
344
- }
345
- return [];
346
- function getAuthor(record) {
347
- //debugData(record);
348
- // eslint-disable-next-line prefer-named-capture-group
349
- const [field] = record.get(/^(100)|(110)|(111)|(700)|(710)|(711)$/u);
350
- //debugData(field);
351
-
352
- if (field) {
353
- const authorString = field.subfields.filter(({
354
- code
355
- }) => ['a'].includes(code)).map(({
356
- value
357
- }) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
358
- // In Melinda's index subfield separators are indexed as ' '
359
- .join(' ');
360
- return authorString;
361
- }
362
- return false;
363
- }
364
- }
365
- function bibPublishers(record) {
366
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibPublishers');
367
- const debugData = debug.extend('data');
368
- debug(`Creating query for the first publisher`);
369
- //debugData(record);
370
-
371
- const publisher = getPublisher(record);
372
- if ((0, _matchingUtils.testStringOrNumber)(publisher)) {
373
- const formatted = String(publisher).replace(/[^\w\s\p{Alphabetic}]/gu, '')
374
- // Clean up concurrent spaces from fe. subfield changes
375
- .replace(/ +/gu, ' ').trim().slice(0, 30).trim();
376
- debugData(`Publisher string: ${formatted}`);
377
- // use non-wildcard word search from dc.publisher
378
- return [`dc.publisher="${formatted}"`];
379
- }
380
- return [];
381
- function getPublisher(record) {
382
- //debugData(record);
383
- const [field] = record.get(/^(?:260)|(?:264)$/u);
384
- //debugData(field);
385
-
386
- if (field) {
387
- const publisherString = field.subfields.filter(({
388
- code
389
- }) => ['b'].includes(code)).map(({
390
- value
391
- }) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
392
- // In Melinda's index subfield separators are indexed as ' '
393
- .join(' ');
394
- return publisherString;
395
- }
396
- return false;
397
- }
398
- }
399
- function bibYear(record) {
400
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibYear');
401
- const debugData = debug.extend('data');
402
- debug(`Creating query for the publishing year`);
403
- debugData(record);
404
- const year = getYear(record);
405
- if (year) {
406
- return [`dc.date="${year}"`];
407
- }
408
- return [];
409
- function getYear(record) {
410
- const value = record.get(/^008$/u)?.[0]?.value || undefined;
411
- return (0, _matchingUtils.testStringOrNumber)(value) ? String(value).slice(7, 11) : undefined;
412
- }
413
- }
414
- function checkUseWordSearch(formatted) {
415
- // Note: add a space to startWords to catch just actual boolean words
416
- const booleanStartWords = ['and ', 'or ', 'nor ', 'not '];
417
- return booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));
418
- }
419
- function bibStandardIdentifiers(record) {
420
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');
421
- const debugData = debug.extend('data');
422
- debug(`Creating queries for standard identifiers`);
423
-
424
- // DEVELOP: should we query also f015 and f028?
425
-
426
- const fields = record.get(/^(?<def>020|022|024)$/u);
427
- const identifiers = [].concat(...fields.map(toIdentifiers));
428
- const uniqueIdentifiers = [...new Set(identifiers)];
429
- debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);
430
- debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);
431
- debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);
432
- if (uniqueIdentifiers.length < 1) {
433
- debug(`No identifiers found, no queries created.`);
434
- return [];
435
- }
436
- return (0, _candidateSearchUtils.toQueries)(uniqueIdentifiers, 'dc.identifier');
437
- function toIdentifiers({
438
- tag,
439
- subfields
440
- }) {
441
- const issnIsbnReqExp = /^[A-Za-z0-9-]+$/u;
442
- const otherIdReqExp = /^[A-Za-z0-9-:]+$/u;
443
- if (tag === '022') {
444
- return subfields.filter(sub => ['a', 'z', 'y'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
445
- value
446
- }) => String(value));
447
- }
448
- if (tag === '020') {
449
- return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
450
- value
451
- }) => String(value));
452
- }
453
- return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && otherIdReqExp.test(String(sub.value))).map(({
454
- value
455
- }) => String(value));
456
- }
457
- }
458
- //# sourceMappingURL=bib.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bib.js","names":["_debug","_interopRequireDefault","require","_candidateSearchUtils","_matchingUtils","e","__esModule","default","debug","createDebugLogger","bibSourceIds","record","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","bibTitleAuthorPublisher","onlyTitleLength","bibTitleAuthor","bibTitleAuthorYear","addYear","bibTitleAuthorYearAlternates","origQueryList","alternates","alternateQueries","queryList","Array","from","reverse","queryListType","title","getTitle","formatted","trim","slice","useWordSearch","checkUseWordSearch","queryIsOkAlone","query","newAlternateQueries","addAuthorsToSearch","authorQuery","bibAuthors","undefined","addYearToSearch","addPublisherToSearch","publisherQuery","bibPublishers","yearQuery","bibYear","titleString","includes","join","author","getAuthor","authorString","publisher","getPublisher","publisherString","year","getYear","booleanStartWords","some","word","toLowerCase","startsWith","bibStandardIdentifiers","fields","identifiers","toIdentifiers","uniqueIdentifiers","Set","tag","issnIsbnReqExp","otherIdReqExp","sub"],"sources":["../../../src/candidate-search/query-list/bib.js"],"sourcesContent":["import createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues, testStringOrNumber} from '../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query');\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 debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents');\n const debugData = debug.extend('data');\n debug(`Creating queries for hostIds`);\n\n const id = getHostId();\n debugData(`Found id: ${JSON.stringify(id)}`);\n\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 // We get author/publisher only when formatted title is shorter than 5 chars\n return bibTitleAuthorPublisher({record, onlyTitleLength: 5});\n}\n\nexport function bibTitleAuthor(record) {\n debug('bibTitleAuthor');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100});\n}\n\nexport function bibTitleAuthorYear(record) {\n debug('bibTitleAuthorYearAlternates');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100, addYear: true});\n}\n\nexport function bibTitleAuthorYearAlternates(record) {\n debug('bibTitleAuthorYearAlternates');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n const origQueryList = bibTitleAuthorPublisher({record, onlyTitleLength: 100, addYear: true, alternates: true, alternateQueries: []});\n debug(`${JSON.stringify(origQueryList)}`);\n return {queryList: Array.from(origQueryList).reverse(), queryListType: 'alternates'};\n}\n\nexport function bibTitleAuthorPublisher({record, onlyTitleLength, addYear = false, alternates = false, alternateQueries = []}) {\n debug(`bibTitleAuthorPublisher, onlyTitleLength: ${onlyTitleLength}, addYear: ${addYear}, alternates: ${alternates}`);\n const title = getTitle();\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 = checkUseWordSearch(formatted);\n // Prevent too many matches / SRU crashing by having a minimum length\n // Note that currently this fails matching if there are no matches from previous matchers\n if (formatted.length >= onlyTitleLength && !alternates) {\n return [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n const queryIsOkAlone = formatted.length >= 5;\n\n // use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]\n const query = `dc.title=\"${useWordSearch || !queryIsOkAlone ? '' : '^'}${formatted}${queryIsOkAlone ? '*' : ''}\"`;\n debug(`query: ${query}`);\n const newAlternateQueries = alternates ? [...alternateQueries, query] : alternateQueries;\n\n return addAuthorsToSearch({query, queryIsOkAlone, addYear, alternates, alternateQueries: newAlternateQueries});\n }\n\n return [];\n\n function addAuthorsToSearch({query, queryIsOkAlone = false, addYear = false, alternates = false, alternateQueries = []}) {\n debug('addAuthorsToSearch');\n const [authorQuery] = bibAuthors(record);\n if (authorQuery !== undefined) {\n if (addYear) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${authorQuery} AND ${query}`] : alternateQueries;\n return addYearToSearch({query: `${authorQuery} AND ${query}`, queryIsOkAlone: true, alternates, alternateQueries: newAlternateQueries});\n }\n return alternates ? alternateQueries : [`${authorQuery} AND ${query}`];\n }\n return addPublisherToSearch({query, queryIsOkAlone, addYear, alternates, alternateQueries});\n //return [];\n }\n\n function addPublisherToSearch({query, queryIsOkAlone = false, addYear = false, alternates = false, alternateQueries = []}) {\n const [publisherQuery] = bibPublishers(record);\n if (publisherQuery !== undefined) {\n if (addYear) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${publisherQuery} AND ${query}`] : alternateQueries;\n return addYearToSearch({query: `${publisherQuery} AND ${query}`, queryIsOkAlone: true, alternates, alternateQueries: newAlternateQueries});\n }\n return alternates ? alternateQueries : [`${publisherQuery} AND ${query}`];\n }\n if (queryIsOkAlone && !addYear) {\n return alternates ? alternateQueries : [`${query}`];\n }\n return addYearToSearch({query, queryIsOkAlone, alternates, alternateQueries});\n }\n\n function addYearToSearch({query, queryIsOkAlone = false, alternates = false, alternateQueries = []}) {\n const [yearQuery] = bibYear(record);\n if (yearQuery !== undefined) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${yearQuery} AND ${query}`] : alternateQueries;\n return alternates ? newAlternateQueries : [`${yearQuery} AND ${query}`];\n }\n if (queryIsOkAlone) {\n return alternates ? alternateQueries : [`${query}`];\n }\n return [];\n }\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n const titleString = field.subfields\n //.filter(({code}) => ['a', 'b', 'n', 'p'].includes(code))\n .filter(({code}) => ['a', 'b'].includes(code))\n //.filter(({code}) => ['a'].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 return titleString;\n }\n return false;\n }\n}\n\nexport function bibAuthors(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibAuthors');\n const debugData = debug.extend('data');\n debug(`Creating query for the first author`);\n //debugData(record);\n\n const author = getAuthor(record);\n\n if (testStringOrNumber(author)) {\n const formatted = String(author)\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 authors starting with a boolean\n const useWordSearch = checkUseWordSearch(formatted);\n // Prevent too many matches by having a minimum length\n debugData(`Author string: ${formatted}`);\n if (formatted.length >= 5) {\n return [`dc.author=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n return [];\n }\n\n return [];\n\n function getAuthor(record) {\n //debugData(record);\n // eslint-disable-next-line prefer-named-capture-group\n const [field] = record.get(/^(100)|(110)|(111)|(700)|(710)|(711)$/u);\n //debugData(field);\n\n if (field) {\n const authorString = field.subfields\n .filter(({code}) => ['a'].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 return authorString;\n }\n return false;\n }\n}\n\nexport function bibPublishers(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibPublishers');\n const debugData = debug.extend('data');\n debug(`Creating query for the first publisher`);\n //debugData(record);\n\n const publisher = getPublisher(record);\n if (testStringOrNumber(publisher)) {\n const formatted = String(publisher)\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 debugData(`Publisher string: ${formatted}`);\n // use non-wildcard word search from dc.publisher\n return [`dc.publisher=\"${formatted}\"`];\n }\n\n return [];\n\n function getPublisher(record) {\n //debugData(record);\n const [field] = record.get(/^(?:260)|(?:264)$/u);\n //debugData(field);\n\n if (field) {\n const publisherString = field.subfields\n .filter(({code}) => ['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 return publisherString;\n }\n return false;\n }\n}\n\nexport function bibYear(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibYear');\n const debugData = debug.extend('data');\n debug(`Creating query for the publishing year`);\n debugData(record);\n\n const year = getYear(record);\n if (year) {\n return [`dc.date=\"${year}\"`];\n }\n return [];\n\n function getYear(record) {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n return testStringOrNumber(value) ? String(value).slice(7, 11) : undefined;\n }\n}\n\nexport function checkUseWordSearch(formatted) {\n // Note: add a space to startWords to catch just actual boolean words\n const booleanStartWords = ['and ', 'or ', 'nor ', 'not '];\n return booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n}\n\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 // DEVELOP: should we query also f015 and f028?\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":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAA8H,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9H,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,0DAA0D,CAAC;AAEpF,SAASC,YAAYA,CAACC,MAAM,EAAE;EAEnC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAQE,MAAMH,KAAK,GAAG,IAAAC,cAAiB,EAAC,qEAAqE,CAAC;EACtG,MAAMG,SAAS,GAAGJ,KAAK,CAACK,MAAM,CAAC,MAAM,CAAC;EACtC;;EAEAL,KAAK,CAAC,iCAAiC,CAAC;EAExC,MAAMM,KAAK,GAAGH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;EAC/BH,SAAS,CAAC,eAAeE,KAAK,CAACE,MAAM,MAAMC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,EAAE,CAAC;EAEnE,OAAOA,KAAK,CAACE,MAAM,GAAG,CAAC,GAAGG,YAAY,CAACL,KAAK,CAAC,GAAG,EAAE;EAElD,SAASK,YAAYA,CAACL,KAAK,EAAE;IAC3BN,KAAK,CAAC,wCAAwC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9D,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAAC2E,GAAG,CAACjE,KAAK,CAAC,IAAI+D,cAAc,CAAC3D,IAAI,CAACb,MAAM,CAAC0E,GAAG,CAACjE,KAAK,CAAC,CAAC,CAAC,CAC5H5B,GAAG,CAAC,CAAC;QAAC4B;MAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;IACpC;IAEA,IAAI8D,GAAG,KAAK,KAAK,EAAE;MACjB,OAAO7D,SAAS,CACb3B,MAAM,CAAC2F,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACxB,QAAQ,CAACwB,GAAG,CAAC9D,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAAC2E,GAAG,CAACjE,KAAK,CAAC,IAAI+D,cAAc,CAAC3D,IAAI,CAACb,MAAM,CAAC0E,GAAG,CAACjE,KAAK,CAAC,CAAC,CAAC,CACvH5B,GAAG,CAAC,CAAC;QAAC4B;MAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;IACpC;IAEA,OAAOC,SAAS,CACb3B,MAAM,CAAC2F,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACxB,QAAQ,CAACwB,GAAG,CAAC9D,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAAC2E,GAAG,CAACjE,KAAK,CAAC,IAAIgE,aAAa,CAAC5D,IAAI,CAACb,MAAM,CAAC0E,GAAG,CAACjE,KAAK,CAAC,CAAC,CAAC,CACtH5B,GAAG,CAAC,CAAC;MAAC4B;IAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;EACpC;AACF","ignoreList":[]}
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
4
- var _fixura = require("@natlibfi/fixura");
5
- var _chai = require("chai");
6
- var _marcRecord = require("@natlibfi/marc-record");
7
- var generators = _interopRequireWildcard(require("./bib"));
8
- var _debug = _interopRequireDefault(require("debug"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test');
13
- const debugData = debug.extend('data');
14
- describe('candidate-search/query-list/bib/', () => {
15
- (0, _fixugen.default)({
16
- path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
17
- useMetadataFile: true,
18
- fixura: {
19
- reader: _fixura.READERS.JSON
20
- },
21
- callback: ({
22
- type,
23
- inputRecord,
24
- expectedQuery,
25
- expectedQueryListType,
26
- enabled = true
27
- }) => {
28
- const generate = generators[type];
29
- const record = new _marcRecord.MarcRecord(inputRecord, {
30
- subfieldValues: false
31
- });
32
- if (!enabled) {
33
- return;
34
- }
35
- const result = generate(record);
36
- debugData(`Result: ${JSON.stringify(result)}`);
37
- if (result.queryListType) {
38
- (0, _chai.expect)(result.queryList).to.eql(expectedQuery);
39
- (0, _chai.expect)(result.queryListType).to.eql(expectedQueryListType);
40
- return;
41
- }
42
- (0, _chai.expect)(result).to.eql(expectedQuery);
43
- }
44
- });
45
- });
46
- //# sourceMappingURL=bib.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bib.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","generators","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","expectedQueryListType","enabled","generate","record","MarcRecord","subfieldValues","result","stringify","queryListType","expect","queryList","to","eql"],"sources":["../../../src/candidate-search/query-list/bib.spec.js"],"sourcesContent":["import generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as generators from './bib';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test');\nconst debugData = debug.extend('data');\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, expectedQueryListType, enabled = true}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n if (!enabled) {\n return;\n }\n\n const result = generate(record);\n debugData(`Result: ${JSON.stringify(result)}`);\n\n if (result.queryListType) {\n expect(result.queryList).to.eql(expectedQuery);\n expect(result.queryListType).to.eql(expectedQueryListType);\n return;\n }\n expect(result).to.eql(expectedQuery);\n }\n });\n});\n"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAsC,SA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});
6
- exports.searchTypes = exports.default = void 0;
7
- var bib = _interopRequireWildcard(require("./bib"));
8
- var _debug = _interopRequireDefault(require("debug"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:index');
13
- const debugData = debug.extend('data');
14
- const searchTypes = exports.searchTypes = {
15
- bib: {
16
- standardIdentifiers: 'bibStandardIdentifiers',
17
- hostComponents: 'bibHostComponents',
18
- title: 'bibTitle',
19
- // title ( + first author + first publisher if needed)
20
- titleAuthor: 'bibTitleAuthor',
21
- // title + first author (or first publisher if no author)
22
- titleAuthorYear: 'bibTitleAuthorYear',
23
- // title + first author (or first publisher if no author), publishing year
24
- titleAuthorYearAlternates: 'bibTitleAuthorYearAlternates',
25
- // title + first author (or first publisher if no author), publishing year
26
- melindaId: 'bibMelindaIds',
27
- sourceIds: 'bibSourceIds'
28
- //DEVELOP: bibContent: 'bibContent'
29
- }
30
- };
31
- var _default = (record, searchSpec) => {
32
- const extractors = {
33
- ...bib
34
- };
35
- debugData(`extractors: ${JSON.stringify(extractors)}`);
36
- debugData(`searchSpec: ${JSON.stringify(searchSpec)}`);
37
- return searchSpec.map(generateQueryExtractor).map(cb => cb(record)).flat();
38
- function generateQueryExtractor(type) {
39
- if (extractors[type]) {
40
- //debugData(`${JSON.stringify(extractors[type])}`);
41
- return extractors[type];
42
- }
43
- throw new Error(`Unknown search type: ${type}`);
44
- }
45
- };
46
- exports.default = _default;
47
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["bib","_interopRequireWildcard","require","_debug","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","debug","createDebugLogger","debugData","extend","searchTypes","exports","standardIdentifiers","hostComponents","title","titleAuthor","titleAuthorYear","titleAuthorYearAlternates","melindaId","sourceIds","_default","record","searchSpec","extractors","JSON","stringify","map","generateQueryExtractor","cb","flat","type","Error"],"sources":["../../../src/candidate-search/query-list/index.js"],"sourcesContent":["\n\nimport * as bib from './bib';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:index');\nconst debugData = debug.extend('data');\n\nexport const searchTypes = {\n bib: {\n standardIdentifiers: 'bibStandardIdentifiers',\n hostComponents: 'bibHostComponents',\n title: 'bibTitle', // title ( + first author + first publisher if needed)\n titleAuthor: 'bibTitleAuthor', // title + first author (or first publisher if no author)\n titleAuthorYear: 'bibTitleAuthorYear', // title + first author (or first publisher if no author), publishing year\n titleAuthorYearAlternates: 'bibTitleAuthorYearAlternates', // title + first author (or first publisher if no author), publishing year\n melindaId: 'bibMelindaIds',\n sourceIds: 'bibSourceIds'\n //DEVELOP: bibContent: 'bibContent'\n }\n};\n\nexport default (record, searchSpec) => {\n const extractors = {...bib};\n debugData(`extractors: ${JSON.stringify(extractors)}`);\n debugData(`searchSpec: ${JSON.stringify(searchSpec)}`);\n\n return searchSpec\n .map(generateQueryExtractor)\n .map(cb => cb(record))\n .flat();\n\n function generateQueryExtractor(type) {\n if (extractors[type]) {\n //debugData(`${JSON.stringify(extractors[type])}`);\n return extractors[type];\n }\n\n thro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