@natlibfi/melinda-record-matching 2.2.1-alpha.1 → 2.2.1-alpha.3

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