@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 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.
- package/.github/workflows/melinda-node-tests.yml +13 -9
- package/LICENSE.txt +21 -165
- package/README.md +2 -2
- package/eslint.config.js +52 -0
- package/example.env +4 -0
- package/package.json +29 -79
- package/src/candidate-search/candidate-search-utils.js +1 -28
- package/src/candidate-search/choose-queries.js +93 -0
- package/src/candidate-search/index.js +85 -119
- package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
- package/src/candidate-search/query-list/bib.js +54 -55
- package/src/candidate-search/query-list/bib.test.js +38 -0
- package/src/candidate-search/query-list/component.js +127 -0
- package/src/candidate-search/query-list/index.js +31 -35
- package/src/cli.js +177 -0
- package/src/index.js +27 -68
- package/src/{index.spec.js → index.test.js} +11 -42
- package/src/match-detection/features/bib/all-source-ids.js +2 -29
- package/src/match-detection/features/bib/authors.js +5 -30
- package/src/match-detection/features/bib/bibliographic-level.js +0 -27
- package/src/match-detection/features/bib/host-component.js +0 -27
- package/src/match-detection/features/bib/index.js +16 -43
- package/src/match-detection/features/bib/index.test.js +52 -0
- package/src/match-detection/features/bib/isbn.js +2 -29
- package/src/match-detection/features/bib/issn.js +1 -28
- package/src/match-detection/features/bib/language.js +5 -32
- package/src/match-detection/features/bib/media-type.js +2 -28
- package/src/match-detection/features/bib/melinda-id.js +1 -28
- package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
- package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
- package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
- package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
- package/src/match-detection/features/bib/publication-time.js +2 -28
- package/src/match-detection/features/bib/record-type.js +0 -27
- package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
- package/src/match-detection/features/bib/title-version-original.js +2 -28
- package/src/match-detection/features/bib/title.js +6 -34
- package/src/match-detection/features/index.js +1 -28
- package/src/match-detection/index.js +1 -28
- package/src/match-detection/{index.spec.js → index.test.js} +9 -35
- package/src/matching-utils.js +8 -37
- package/dist/candidate-search/candidate-search-utils.js +0 -55
- package/dist/candidate-search/candidate-search-utils.js.map +0 -1
- package/dist/candidate-search/index.js +0 -254
- package/dist/candidate-search/index.js.map +0 -1
- package/dist/candidate-search/index.spec.js +0 -144
- package/dist/candidate-search/index.spec.js.map +0 -1
- package/dist/candidate-search/query-list/bib.js +0 -439
- package/dist/candidate-search/query-list/bib.js.map +0 -1
- package/dist/candidate-search/query-list/bib.spec.js +0 -64
- package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
- package/dist/candidate-search/query-list/index.js +0 -66
- package/dist/candidate-search/query-list/index.js.map +0 -1
- package/dist/index.js +0 -579
- package/dist/index.js.map +0 -1
- package/dist/index.spec.js +0 -127
- package/dist/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/all-source-ids.js +0 -119
- package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
- package/dist/match-detection/features/bib/authors.js +0 -113
- package/dist/match-detection/features/bib/authors.js.map +0 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +0 -42
- package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
- package/dist/match-detection/features/bib/host-component.js +0 -42
- package/dist/match-detection/features/bib/host-component.js.map +0 -1
- package/dist/match-detection/features/bib/index.js +0 -119
- package/dist/match-detection/features/bib/index.js.map +0 -1
- package/dist/match-detection/features/bib/index.spec.js +0 -93
- package/dist/match-detection/features/bib/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/isbn.js +0 -77
- package/dist/match-detection/features/bib/isbn.js.map +0 -1
- package/dist/match-detection/features/bib/issn.js +0 -51
- package/dist/match-detection/features/bib/issn.js.map +0 -1
- package/dist/match-detection/features/bib/language.js +0 -141
- package/dist/match-detection/features/bib/language.js.map +0 -1
- package/dist/match-detection/features/bib/media-type.js +0 -83
- package/dist/match-detection/features/bib/media-type.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-id.js +0 -48
- package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -89
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +0 -52
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -256
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +0 -71
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +0 -1
- package/dist/match-detection/features/bib/publication-time.js +0 -48
- package/dist/match-detection/features/bib/publication-time.js.map +0 -1
- package/dist/match-detection/features/bib/record-type.js +0 -45
- package/dist/match-detection/features/bib/record-type.js.map +0 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -215
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
- package/dist/match-detection/features/bib/title-version-original.js +0 -79
- package/dist/match-detection/features/bib/title-version-original.js.map +0 -1
- package/dist/match-detection/features/bib/title.js +0 -98
- package/dist/match-detection/features/bib/title.js.map +0 -1
- package/dist/match-detection/features/index.js +0 -11
- package/dist/match-detection/features/index.js.map +0 -1
- package/dist/match-detection/index.js +0 -201
- package/dist/match-detection/index.js.map +0 -1
- package/dist/match-detection/index.spec.js +0 -91
- package/dist/match-detection/index.spec.js.map +0 -1
- package/dist/matching-utils.js +0 -143
- package/dist/matching-utils.js.map +0 -1
- package/src/candidate-search/query-list/bib.spec.js +0 -54
- package/src/match-detection/features/bib/index.spec.js +0 -78
|
@@ -1,439 +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.bibYear = bibYear;
|
|
17
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
18
|
-
var _candidateSearchUtils = require("../candidate-search-utils");
|
|
19
|
-
var _matchingUtils = require("../../matching-utils");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
24
|
-
*
|
|
25
|
-
* Melinda record matching modules for Javascript
|
|
26
|
-
*
|
|
27
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
28
|
-
*
|
|
29
|
-
* This file is part of melinda-record-matching-js
|
|
30
|
-
*
|
|
31
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
32
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
33
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
34
|
-
* License, or (at your option) any later version.
|
|
35
|
-
*
|
|
36
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
37
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
38
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
39
|
-
* GNU Lesser General Public License for more details.
|
|
40
|
-
*
|
|
41
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
42
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
43
|
-
*
|
|
44
|
-
* @licend The above is the entire license notice
|
|
45
|
-
* for the JavaScript code in this file.
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query');
|
|
50
|
-
function bibSourceIds(record) {
|
|
51
|
-
/* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records
|
|
52
|
-
SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
|
|
53
|
-
SID__ $c 123457 $b helka
|
|
54
|
-
SID__ $c (ANDL100020)1077305 $b sata
|
|
55
|
-
SID__ $c VER999999 $ FI-KV
|
|
56
|
-
SID__ $c /10024/508126 $ REPO_THESEUS
|
|
57
|
-
In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:
|
|
58
|
-
Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted
|
|
59
|
-
1234567helka
|
|
60
|
-
1077305sata
|
|
61
|
-
VER999999FIKV
|
|
62
|
-
/10024/508126REPO_THESEUS
|
|
63
|
-
Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,
|
|
64
|
-
existence of a SID field depends on how the record has been added to Melinda and how it has been handled
|
|
65
|
-
afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
|
|
66
|
-
after the matching record is removed from the local db.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');
|
|
70
|
-
const debugData = debug.extend('data');
|
|
71
|
-
//const debugInfo = debug.extend('info');
|
|
72
|
-
|
|
73
|
-
debug(`Creating queries for sourceid's`);
|
|
74
|
-
const fSids = record.get('SID');
|
|
75
|
-
debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
|
|
76
|
-
return fSids.length > 0 ? toSidQueries(fSids) : [];
|
|
77
|
-
function toSidQueries(fSids) {
|
|
78
|
-
debug(`Creating actual queries for sourceid's`);
|
|
79
|
-
const sidStrings = getSidStrings(fSids);
|
|
80
|
-
if (sidStrings.length < 1) {
|
|
81
|
-
debug(`No identifiers found, no queries created.`);
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
const sidQueries = (0, _candidateSearchUtils.toQueries)(sidStrings, 'melinda.sourceid');
|
|
85
|
-
return sidQueries;
|
|
86
|
-
function getSidStrings(fSids) {
|
|
87
|
-
debug(`Getting Sid strings from SID fields`);
|
|
88
|
-
|
|
89
|
-
// Map SID fields to valid sidStrings, filter out empty strings
|
|
90
|
-
const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);
|
|
91
|
-
return sidStrings;
|
|
92
|
-
function toSidString(field) {
|
|
93
|
-
debug(`Getting string from a field`);
|
|
94
|
-
return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidString(field) : '';
|
|
95
|
-
function createSidString(field) {
|
|
96
|
-
debug(`Creating string from a field`);
|
|
97
|
-
const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
|
|
98
|
-
const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
|
|
99
|
-
const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));
|
|
100
|
-
const cleanedSfB = normalizeSidSubfieldValue(sfB);
|
|
101
|
-
debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
|
|
102
|
-
return cleanedSfC.concat(cleanedSfB);
|
|
103
|
-
}
|
|
104
|
-
function removeSourcePrefix(subfieldValue) {
|
|
105
|
-
const sourcePrefixRegex = /^(?<sourcePrefix>\([A-Za-z0-9-]+\))(?<id>.+)$/u;
|
|
106
|
-
const normalizedValue = (0, _matchingUtils.testStringOrNumber)(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';
|
|
107
|
-
debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);
|
|
108
|
-
return normalizedValue;
|
|
109
|
-
}
|
|
110
|
-
function normalizeSidSubfieldValue(subfieldValue) {
|
|
111
|
-
debugData(`Normalizing ${subfieldValue}`);
|
|
112
|
-
const normalizeAwayRegex = /[- ]/u;
|
|
113
|
-
return (0, _matchingUtils.testStringOrNumber)(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function bibMelindaIds(record) {
|
|
120
|
-
// Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records
|
|
121
|
-
|
|
122
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');
|
|
123
|
-
const debugData = debug.extend('data');
|
|
124
|
-
debug(`Creating queries for MelindaIds`);
|
|
125
|
-
|
|
126
|
-
// Note: Melinda-ID's for search queries are created just from records f035a's and f035z's
|
|
127
|
-
// Both (FI-MELINDA)- and FCC-prefixed forms are found
|
|
128
|
-
// f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA
|
|
129
|
-
const melindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
|
|
130
|
-
debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);
|
|
131
|
-
if (melindaIds.length < 1) {
|
|
132
|
-
debug(`No identifiers found, no queries created.`);
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
return (0, _candidateSearchUtils.toQueries)(melindaIds, 'melinda.melindaid');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05
|
|
139
|
-
// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?
|
|
140
|
-
function bibHostComponents(record) {
|
|
141
|
-
const id = getHostId();
|
|
142
|
-
return (0, _matchingUtils.testStringOrNumber)(id) ? [`melinda.partsofhost=${id}`] : [];
|
|
143
|
-
function getHostId() {
|
|
144
|
-
const [field] = record.get(/^773$/u);
|
|
145
|
-
if (field) {
|
|
146
|
-
const {
|
|
147
|
-
value
|
|
148
|
-
} = field.subfields.find(({
|
|
149
|
-
code
|
|
150
|
-
}) => code === 'w') || {};
|
|
151
|
-
if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FI-MELINDA\)/u.test(String(value))) {
|
|
152
|
-
return String(value).replace(/^\(FI-MELINDA\)/u, '');
|
|
153
|
-
}
|
|
154
|
-
if ((0, _matchingUtils.testStringOrNumber)(value) && /^\(FIN01\)/u.test(String(value))) {
|
|
155
|
-
return String(value).replace(/^\(FIN01\)/u, '');
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to
|
|
164
|
-
// (probably) to *headings* index TIT
|
|
165
|
-
// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search
|
|
166
|
-
|
|
167
|
-
// Headings index TIT drops articles etc. from the start of the title according to the filing indicator
|
|
168
|
-
// Currently filing indicator is not implemented - if the title starts with an article and the Melinda
|
|
169
|
-
// record is correctly catalogued using a filing indicator -> dc.title search won't match
|
|
170
|
-
|
|
171
|
-
function bibTitle(record) {
|
|
172
|
-
// We get author/publisher only when formatted title is shorter than 5 chars
|
|
173
|
-
return bibTitleAuthorPublisher({
|
|
174
|
-
record,
|
|
175
|
-
onlyTitleLength: 5
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function bibTitleAuthor(record) {
|
|
179
|
-
debug('bibTitleAuthor');
|
|
180
|
-
// We use onlyTitleLength that is longer than our formatted length to
|
|
181
|
-
// get an author or an publisher always
|
|
182
|
-
return bibTitleAuthorPublisher({
|
|
183
|
-
record,
|
|
184
|
-
onlyTitleLength: 100
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
function bibTitleAuthorYear(record) {
|
|
188
|
-
debug('bibTitleAuthorYear');
|
|
189
|
-
// We use onlyTitleLength that is longer than our formatted length to
|
|
190
|
-
// get an author or an publisher always
|
|
191
|
-
|
|
192
|
-
return bibTitleAuthorPublisher({
|
|
193
|
-
record,
|
|
194
|
-
onlyTitleLength: 100,
|
|
195
|
-
addYear: true
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
function bibTitleAuthorPublisher({
|
|
199
|
-
record,
|
|
200
|
-
onlyTitleLength,
|
|
201
|
-
addYear = false
|
|
202
|
-
}) {
|
|
203
|
-
debug('bibTitleAuthorPublisher');
|
|
204
|
-
const title = getTitle();
|
|
205
|
-
const booleanStartWords = ['and', 'or', 'nor', 'not'];
|
|
206
|
-
if ((0, _matchingUtils.testStringOrNumber)(title)) {
|
|
207
|
-
const formatted = String(title).replace(/[^\w\s\p{Alphabetic}]/gu, '')
|
|
208
|
-
// Clean up concurrent spaces from fe. subfield changes
|
|
209
|
-
.replace(/ +/gu, ' ').trim().slice(0, 30).trim();
|
|
210
|
-
|
|
211
|
-
// use word search for titles starting with a boolean
|
|
212
|
-
const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));
|
|
213
|
-
// Prevent too many matches / SRU crashing by having a minimum length
|
|
214
|
-
// Note that currently this fails matching if there are no matches from previous matchers
|
|
215
|
-
if (formatted.length >= onlyTitleLength) {
|
|
216
|
-
return [`dc.title="${useWordSearch ? '' : '^'}${formatted}*"`];
|
|
217
|
-
}
|
|
218
|
-
const queryIsOkAlone = formatted.length >= 5;
|
|
219
|
-
|
|
220
|
-
// use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]
|
|
221
|
-
const query = `dc.title="${useWordSearch || !queryIsOkAlone ? '' : '^'}${formatted}${queryIsOkAlone ? '*' : ''}"`;
|
|
222
|
-
debug(`query: ${query}`);
|
|
223
|
-
return addAuthorsToSearch({
|
|
224
|
-
query,
|
|
225
|
-
queryIsOkAlone,
|
|
226
|
-
addYear
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return [];
|
|
230
|
-
function addAuthorsToSearch({
|
|
231
|
-
query,
|
|
232
|
-
queryIsOkAlone = false,
|
|
233
|
-
addYear = false
|
|
234
|
-
}) {
|
|
235
|
-
debug('addAuthorsToSearch');
|
|
236
|
-
const [authorQuery] = bibAuthors(record);
|
|
237
|
-
if (authorQuery !== undefined) {
|
|
238
|
-
if (addYear) {
|
|
239
|
-
return addYearToSearch({
|
|
240
|
-
query: `${authorQuery} AND ${query}`,
|
|
241
|
-
queryIsOkAlone: true
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
return [`${authorQuery} AND ${query}`];
|
|
245
|
-
}
|
|
246
|
-
return addPublisherToSearch({
|
|
247
|
-
query,
|
|
248
|
-
queryIsOkAlone,
|
|
249
|
-
addYear
|
|
250
|
-
});
|
|
251
|
-
//return [];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function addPublisherToSearch({
|
|
255
|
-
query,
|
|
256
|
-
queryIsOkAlone = false,
|
|
257
|
-
addYear = false
|
|
258
|
-
}) {
|
|
259
|
-
const [publisherQuery] = bibPublishers(record);
|
|
260
|
-
if (publisherQuery !== undefined) {
|
|
261
|
-
if (addYear) {
|
|
262
|
-
return addYearToSearch({
|
|
263
|
-
query: `${publisherQuery} AND ${query}`,
|
|
264
|
-
queryIsOkAlone: true
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return [`${publisherQuery} AND ${query}`];
|
|
268
|
-
}
|
|
269
|
-
if (queryIsOkAlone && !addYear) {
|
|
270
|
-
return [`${query}`];
|
|
271
|
-
}
|
|
272
|
-
return addYearToSearch({
|
|
273
|
-
query,
|
|
274
|
-
queryIsOkAlone
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function addYearToSearch({
|
|
278
|
-
query,
|
|
279
|
-
queryIsOkAlone = false
|
|
280
|
-
}) {
|
|
281
|
-
const [yearQuery] = bibYear(record);
|
|
282
|
-
if (yearQuery !== undefined) {
|
|
283
|
-
return [`${yearQuery} AND ${query}`];
|
|
284
|
-
}
|
|
285
|
-
if (queryIsOkAlone) {
|
|
286
|
-
return [`${query}`];
|
|
287
|
-
}
|
|
288
|
-
return [];
|
|
289
|
-
}
|
|
290
|
-
function getTitle() {
|
|
291
|
-
const [field] = record.get(/^245$/u);
|
|
292
|
-
if (field) {
|
|
293
|
-
const titleString = field.subfields
|
|
294
|
-
//.filter(({code}) => ['a', 'b', 'n', 'p'].includes(code))
|
|
295
|
-
.filter(({
|
|
296
|
-
code
|
|
297
|
-
}) => ['a', 'b'].includes(code))
|
|
298
|
-
//.filter(({code}) => ['a'].includes(code))
|
|
299
|
-
.map(({
|
|
300
|
-
value
|
|
301
|
-
}) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
|
|
302
|
-
// In Melinda's index subfield separators are indexed as ' '
|
|
303
|
-
.join(' ');
|
|
304
|
-
return titleString;
|
|
305
|
-
}
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
function bibAuthors(record) {
|
|
310
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibAuthors');
|
|
311
|
-
const debugData = debug.extend('data');
|
|
312
|
-
debug(`Creating query for the first author`);
|
|
313
|
-
//debugData(record);
|
|
314
|
-
|
|
315
|
-
const author = getAuthor(record);
|
|
316
|
-
const booleanStartWords = ['and', 'or', 'nor', 'not'];
|
|
317
|
-
if ((0, _matchingUtils.testStringOrNumber)(author)) {
|
|
318
|
-
const formatted = String(author).replace(/[^\w\s\p{Alphabetic}]/gu, '')
|
|
319
|
-
// Clean up concurrent spaces from fe. subfield changes
|
|
320
|
-
.replace(/ +/gu, ' ').trim().slice(0, 30).trim();
|
|
321
|
-
|
|
322
|
-
// use word search for authors starting with a boolean
|
|
323
|
-
const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));
|
|
324
|
-
// Prevent too many matches by having a minimum length
|
|
325
|
-
debugData(`Author string: ${formatted}`);
|
|
326
|
-
if (formatted.length >= 5) {
|
|
327
|
-
return [`dc.author="${useWordSearch ? '' : '^'}${formatted}*"`];
|
|
328
|
-
}
|
|
329
|
-
return [];
|
|
330
|
-
}
|
|
331
|
-
return [];
|
|
332
|
-
function getAuthor(record) {
|
|
333
|
-
//debugData(record);
|
|
334
|
-
// eslint-disable-next-line prefer-named-capture-group
|
|
335
|
-
const [field] = record.get(/^(100)|(110)|(111)|(700)|(710)|(711)$/u);
|
|
336
|
-
//debugData(field);
|
|
337
|
-
|
|
338
|
-
if (field) {
|
|
339
|
-
const authorString = field.subfields.filter(({
|
|
340
|
-
code
|
|
341
|
-
}) => ['a'].includes(code)).map(({
|
|
342
|
-
value
|
|
343
|
-
}) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
|
|
344
|
-
// In Melinda's index subfield separators are indexed as ' '
|
|
345
|
-
.join(' ');
|
|
346
|
-
return authorString;
|
|
347
|
-
}
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
function bibPublishers(record) {
|
|
352
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibPublishers');
|
|
353
|
-
const debugData = debug.extend('data');
|
|
354
|
-
debug(`Creating query for the first publisher`);
|
|
355
|
-
//debugData(record);
|
|
356
|
-
|
|
357
|
-
const publisher = getPublisher(record);
|
|
358
|
-
if ((0, _matchingUtils.testStringOrNumber)(publisher)) {
|
|
359
|
-
const formatted = String(publisher).replace(/[^\w\s\p{Alphabetic}]/gu, '')
|
|
360
|
-
// Clean up concurrent spaces from fe. subfield changes
|
|
361
|
-
.replace(/ +/gu, ' ').trim().slice(0, 30).trim();
|
|
362
|
-
debugData(`Publisher string: ${formatted}`);
|
|
363
|
-
// use non-wildcard word search from dc.publisher
|
|
364
|
-
return [`dc.publisher="${formatted}"`];
|
|
365
|
-
}
|
|
366
|
-
return [];
|
|
367
|
-
function getPublisher(record) {
|
|
368
|
-
//debugData(record);
|
|
369
|
-
const [field] = record.get(/^(?:260)|(?:264)$/u);
|
|
370
|
-
//debugData(field);
|
|
371
|
-
|
|
372
|
-
if (field) {
|
|
373
|
-
const publisherString = field.subfields.filter(({
|
|
374
|
-
code
|
|
375
|
-
}) => ['b'].includes(code)).map(({
|
|
376
|
-
value
|
|
377
|
-
}) => (0, _matchingUtils.testStringOrNumber)(value) ? String(value) : '').filter(value => value)
|
|
378
|
-
// In Melinda's index subfield separators are indexed as ' '
|
|
379
|
-
.join(' ');
|
|
380
|
-
return publisherString;
|
|
381
|
-
}
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
function bibYear(record) {
|
|
386
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibYear');
|
|
387
|
-
const debugData = debug.extend('data');
|
|
388
|
-
debug(`Creating query for the publishing year`);
|
|
389
|
-
debugData(record);
|
|
390
|
-
const year = getYear(record);
|
|
391
|
-
if (year) {
|
|
392
|
-
return [`dc.date="${year}"`];
|
|
393
|
-
}
|
|
394
|
-
return [];
|
|
395
|
-
function getYear(record) {
|
|
396
|
-
const value = record.get(/^008$/u)?.[0]?.value || undefined;
|
|
397
|
-
return (0, _matchingUtils.testStringOrNumber)(value) ? String(value).slice(7, 11) : undefined;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
function bibStandardIdentifiers(record) {
|
|
401
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');
|
|
402
|
-
const debugData = debug.extend('data');
|
|
403
|
-
debug(`Creating queries for standard identifiers`);
|
|
404
|
-
|
|
405
|
-
// DEVELOP: should we query also f015 and f028?
|
|
406
|
-
|
|
407
|
-
const fields = record.get(/^(?<def>020|022|024)$/u);
|
|
408
|
-
const identifiers = [].concat(...fields.map(toIdentifiers));
|
|
409
|
-
const uniqueIdentifiers = [...new Set(identifiers)];
|
|
410
|
-
debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);
|
|
411
|
-
debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);
|
|
412
|
-
debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);
|
|
413
|
-
if (uniqueIdentifiers.length < 1) {
|
|
414
|
-
debug(`No identifiers found, no queries created.`);
|
|
415
|
-
return [];
|
|
416
|
-
}
|
|
417
|
-
return (0, _candidateSearchUtils.toQueries)(uniqueIdentifiers, 'dc.identifier');
|
|
418
|
-
function toIdentifiers({
|
|
419
|
-
tag,
|
|
420
|
-
subfields
|
|
421
|
-
}) {
|
|
422
|
-
const issnIsbnReqExp = /^[A-Za-z0-9-]+$/u;
|
|
423
|
-
const otherIdReqExp = /^[A-Za-z0-9-:]+$/u;
|
|
424
|
-
if (tag === '022') {
|
|
425
|
-
return subfields.filter(sub => ['a', 'z', 'y'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
|
|
426
|
-
value
|
|
427
|
-
}) => String(value));
|
|
428
|
-
}
|
|
429
|
-
if (tag === '020') {
|
|
430
|
-
return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && issnIsbnReqExp.test(String(sub.value))).map(({
|
|
431
|
-
value
|
|
432
|
-
}) => String(value));
|
|
433
|
-
}
|
|
434
|
-
return subfields.filter(sub => ['a', 'z'].includes(sub.code) && (0, _matchingUtils.testStringOrNumber)(sub.value) && otherIdReqExp.test(String(sub.value))).map(({
|
|
435
|
-
value
|
|
436
|
-
}) => String(value));
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
//# sourceMappingURL=bib.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bib.js","names":["_debug","_interopRequireDefault","require","_candidateSearchUtils","_matchingUtils","obj","__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","title","getTitle","booleanStartWords","formatted","trim","slice","useWordSearch","some","word","toLowerCase","startsWith","queryIsOkAlone","query","addAuthorsToSearch","authorQuery","bibAuthors","undefined","addYearToSearch","addPublisherToSearch","publisherQuery","bibPublishers","yearQuery","bibYear","titleString","includes","join","author","getAuthor","authorString","publisher","getPublisher","publisherString","year","getYear","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\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 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 // 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('bibTitleAuthorYear');\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 bibTitleAuthorPublisher({record, onlyTitleLength, addYear = false}) {\n debug('bibTitleAuthorPublisher');\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 / 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) {\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 return addAuthorsToSearch({query, queryIsOkAlone, addYear});\n }\n\n return [];\n\n function addAuthorsToSearch({query, queryIsOkAlone = false, addYear = false}) {\n debug('addAuthorsToSearch');\n const [authorQuery] = bibAuthors(record);\n if (authorQuery !== undefined) {\n if (addYear) {\n return addYearToSearch({query: `${authorQuery} AND ${query}`, queryIsOkAlone: true});\n }\n return [`${authorQuery} AND ${query}`];\n }\n return addPublisherToSearch({query, queryIsOkAlone, addYear});\n //return [];\n }\n\n function addPublisherToSearch({query, queryIsOkAlone = false, addYear = false}) {\n const [publisherQuery] = bibPublishers(record);\n if (publisherQuery !== undefined) {\n if (addYear) {\n return addYearToSearch({query: `${publisherQuery} AND ${query}`, queryIsOkAlone: true});\n }\n return [`${publisherQuery} AND ${query}`];\n }\n if (queryIsOkAlone && !addYear) {\n return [`${query}`];\n }\n return addYearToSearch({query, queryIsOkAlone});\n }\n\n function addYearToSearch({query, queryIsOkAlone = false}) {\n const [yearQuery] = bibYear(record);\n if (yearQuery !== undefined) {\n return [`${yearQuery} AND ${query}`];\n }\n if (queryIsOkAlone) {\n return [`${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 const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\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 = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\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\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":";;;;;;;;;;;;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAA8H,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7B9H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,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,CAAE,iCAAgC,CAAC;EAExC,MAAMM,KAAK,GAAGH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;EAC/BH,SAAS,CAAE,eAAcE,KAAK,CAACE,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAE,EAAC,CAAC;EAEnE,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E,GAAG,CAAC,CAACnB,QAAQ,CAACmB,GAAG,CAACnD,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAACgE,GAAG,CAACtD,KAAK,CAAC,IAAIoD,cAAc,CAAChD,IAAI,CAACb,MAAM,CAAC+D,GAAG,CAACtD,KAAK,CAAC,CAAC,CAAC,CACvH5B,GAAG,CAAC,CAAC;QAAC4B;MAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;IACpC;IAEA,OAAOC,SAAS,CACb3B,MAAM,CAACgF,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACnB,QAAQ,CAACmB,GAAG,CAACnD,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAACgE,GAAG,CAACtD,KAAK,CAAC,IAAIqD,aAAa,CAACjD,IAAI,CAACb,MAAM,CAAC+D,GAAG,CAACtD,KAAK,CAAC,CAAC,CAAC,CACtH5B,GAAG,CAAC,CAAC;MAAC4B;IAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;EACpC;AACF"}
|
|
@@ -1,64 +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
|
-
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); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
14
|
-
*
|
|
15
|
-
* Melinda record matching modules for Javascript
|
|
16
|
-
*
|
|
17
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
18
|
-
*
|
|
19
|
-
* This file is part of melinda-record-matching-js
|
|
20
|
-
*
|
|
21
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
22
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
23
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
24
|
-
* License, or (at your option) any later version.
|
|
25
|
-
*
|
|
26
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
27
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29
|
-
* GNU Lesser General Public License for more details.
|
|
30
|
-
*
|
|
31
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
32
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
-
*
|
|
34
|
-
* @licend The above is the entire license notice
|
|
35
|
-
* for the JavaScript code in this file.
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
describe('candidate-search/query-list/bib/', () => {
|
|
40
|
-
(0, _fixugen.default)({
|
|
41
|
-
path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
|
|
42
|
-
useMetadataFile: true,
|
|
43
|
-
fixura: {
|
|
44
|
-
reader: _fixura.READERS.JSON
|
|
45
|
-
},
|
|
46
|
-
callback: ({
|
|
47
|
-
type,
|
|
48
|
-
inputRecord,
|
|
49
|
-
expectedQuery,
|
|
50
|
-
enabled = true
|
|
51
|
-
}) => {
|
|
52
|
-
const generate = generators[type];
|
|
53
|
-
const record = new _marcRecord.MarcRecord(inputRecord, {
|
|
54
|
-
subfieldValues: false
|
|
55
|
-
});
|
|
56
|
-
if (!enabled) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const queryList = generate(record);
|
|
60
|
-
(0, _chai.expect)(queryList).to.eql(expectedQuery);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=bib.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bib.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","generators","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","record","MarcRecord","subfieldValues","queryList","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 const queryList = generate(record);\n expect(queryList).to.eql(expectedQuery);\n }\n });\n});\n"],"mappings":";;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAC,uBAAA,CAAAL,OAAA;AAAoC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,C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;MACjC,MAAMK,MAAM,GAAG,IAAIC,sBAAU,CAACL,WAAW,EAAE;QAACM,cAAc,EAAE;MAAK,CAAC,CAAC;MAEnE,IAAI,CAACJ,OAAO,EAAE;QACZ;MACF;MAEA,MAAMK,SAAS,GAAGJ,QAAQ,CAACC,MAAM,CAAC;MAClC,IAAAI,YAAM,EAACD,SAAS,CAAC,CAACE,EAAE,CAACC,GAAG,CAACT,aAAa,CAAC;IACzC;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.searchTypes = exports.default = void 0;
|
|
7
|
-
var bib = _interopRequireWildcard(require("./bib"));
|
|
8
|
-
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); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
13
|
-
*
|
|
14
|
-
* Melinda record matching modules for Javascript
|
|
15
|
-
*
|
|
16
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
17
|
-
*
|
|
18
|
-
* This file is part of melinda-record-matching-js
|
|
19
|
-
*
|
|
20
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
22
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
23
|
-
* License, or (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU Lesser General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*
|
|
33
|
-
* @licend The above is the entire license notice
|
|
34
|
-
* for the JavaScript code in this file.
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
const searchTypes = exports.searchTypes = {
|
|
39
|
-
bib: {
|
|
40
|
-
standardIdentifiers: 'bibStandardIdentifiers',
|
|
41
|
-
hostComponents: 'bibHostComponents',
|
|
42
|
-
title: 'bibTitle',
|
|
43
|
-
// title ( + first author + first publisher if needed)
|
|
44
|
-
titleAuthor: 'bibTitleAuthor',
|
|
45
|
-
// title + first author (or first publisher if no author)
|
|
46
|
-
titleAuthorYear: 'bibTitleAuthorYear',
|
|
47
|
-
// title + first author (or first publisher if no author), publishing year
|
|
48
|
-
melindaId: 'bibMelindaIds',
|
|
49
|
-
sourceIds: 'bibSourceIds'
|
|
50
|
-
//DEVELOP: bibContent: 'bibContent'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var _default = (record, searchSpec) => {
|
|
54
|
-
const extractors = {
|
|
55
|
-
...bib
|
|
56
|
-
};
|
|
57
|
-
return searchSpec.map(generateQueryExtractor).map(cb => cb(record)).flat();
|
|
58
|
-
function generateQueryExtractor(type) {
|
|
59
|
-
if (extractors[type]) {
|
|
60
|
-
return extractors[type];
|
|
61
|
-
}
|
|
62
|
-
throw new Error(`Unknown search type: ${type}`);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
exports.default = _default;
|
|
66
|
-
//# sourceMappingURL=index.js.map
|