@natlibfi/melinda-record-matching 4.2.0-alpha.1 → 4.2.1-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/dependabot.yml +9 -4
- package/.github/workflows/melinda-node-tests.yml +4 -4
- package/dist/candidate-search/index.js +2 -2
- package/dist/candidate-search/index.js.map +1 -1
- package/dist/candidate-search/index.spec.js +2 -2
- package/dist/candidate-search/index.spec.js.map +1 -1
- package/dist/candidate-search/query-list/bib.js +10 -45
- package/dist/candidate-search/query-list/bib.js.map +1 -1
- package/dist/candidate-search/query-list/bib.spec.js +2 -2
- package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
- package/dist/candidate-search/query-list/index.js +3 -7
- package/dist/candidate-search/query-list/index.js.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/index.spec.js +2 -2
- package/dist/index.spec.js.map +1 -1
- package/dist/match-detection/features/bib/index.spec.js +2 -2
- package/dist/match-detection/features/bib/index.spec.js.map +1 -1
- package/dist/match-detection/features/index.js +2 -2
- package/dist/match-detection/features/index.js.map +1 -1
- package/dist/match-detection/index.js +2 -2
- package/dist/match-detection/index.js.map +1 -1
- package/dist/match-detection/index.spec.js +2 -2
- package/dist/match-detection/index.spec.js.map +1 -1
- package/package.json +15 -15
- package/src/candidate-search/query-list/bib.js +10 -25
- package/src/candidate-search/query-list/index.js +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_","_util","_debug","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_","_util","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","callback","getFixture","options","expectedResults","array","enabled","detect","createDetectionInterface","formatOptions","recordA","MarcRecord","subfieldValues","inspect","recordB","map","recordJson","results","stringify","expect","to","eql","contextFeatures","strategy","type","v"],"sources":["../../src/match-detection/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 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 features from './features';\nimport createDetectionInterface from '.';\nimport {inspect} from 'util';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:test');\nconst debugData = debug.extend('data');\n\ndescribe('match-detection', () => {\n generateTests({\n path: [__dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({getFixture, options, expectedResults, array, enabled = true}) => {\n\n if (!enabled) {\n debug(`*** DISABLED TEST! ***`);\n return;\n }\n\n const detect = createDetectionInterface(formatOptions());\n const recordA = new MarcRecord(getFixture('recordA.json'), {subfieldValues: false});\n debugData(inspect(recordA));\n\n debug(`Our recordB is an array of records: ${array}`);\n const recordB = array\n ? getFixture('recordB.json').map(recordJson => new MarcRecord(recordJson, {subfieldValues: false}))\n : new MarcRecord(getFixture('recordB.json'), {subfieldValues: false});\n debugData(inspect(recordB));\n\n const results = detect({recordA, recordB});\n debugData(`${JSON.stringify(results)}`);\n\n expect(results).to.eql(expectedResults);\n\n function formatOptions() {\n const contextFeatures = features[options.strategy.type];\n\n return {\n ...options,\n strategy: options.strategy.features.map(v => contextFeatures[v]())\n };\n }\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,QAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,CAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAT,sBAAA,CAAAC,OAAA;AAAsC,SAAAS,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,SAAAL,wBAAAK,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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AAQ,CAACuD,GAAG,CAACU,CAAC,IAAIH,eAAe,CAACG,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;MACH;IACF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "git@github.com:natlibfi/melinda-record-matching-js.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "LGPL-3.0+",
|
|
17
|
-
"version": "4.2.
|
|
17
|
+
"version": "4.2.1-alpha.1",
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18"
|
|
@@ -39,31 +39,31 @@
|
|
|
39
39
|
"@natlibfi/marc-record": "^7.3.1",
|
|
40
40
|
"@natlibfi/marc-record-serializers": "^10.1.1",
|
|
41
41
|
"@natlibfi/melinda-commons": "^13.0.6",
|
|
42
|
-
"@natlibfi/sru-client": "^6.0.
|
|
42
|
+
"@natlibfi/sru-client": "^6.0.5",
|
|
43
43
|
"debug": "^4.3.4",
|
|
44
|
-
"isbn3": "^1.1.
|
|
44
|
+
"isbn3": "^1.1.42",
|
|
45
45
|
"moment": "^2.29.4",
|
|
46
|
-
"natural": "^6.
|
|
47
|
-
"uuid": "^9.0.
|
|
48
|
-
"winston": "^3.
|
|
46
|
+
"natural": "^6.8.0",
|
|
47
|
+
"uuid": "^9.0.1",
|
|
48
|
+
"winston": "^3.11.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/cli": "^7.
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
-
"@babel/eslint-parser": "^7.22.
|
|
54
|
-
"@babel/node": "^7.22.
|
|
55
|
-
"@babel/preset-env": "^7.
|
|
56
|
-
"@babel/register": "^7.22.
|
|
57
|
-
"@natlibfi/eslint-config-melinda-backend": "^3.0.
|
|
51
|
+
"@babel/cli": "^7.23.0",
|
|
52
|
+
"@babel/core": "^7.23.2",
|
|
53
|
+
"@babel/eslint-parser": "^7.22.15",
|
|
54
|
+
"@babel/node": "^7.22.19",
|
|
55
|
+
"@babel/preset-env": "^7.23.2",
|
|
56
|
+
"@babel/register": "^7.22.15",
|
|
57
|
+
"@natlibfi/eslint-config-melinda-backend": "^3.0.2",
|
|
58
58
|
"@natlibfi/fixugen": "^2.0.1",
|
|
59
59
|
"@natlibfi/fixugen-http-client": "^3.0.0",
|
|
60
60
|
"@natlibfi/fixura": "^3.0.1",
|
|
61
61
|
"babel-plugin-istanbul": "^6.1.1",
|
|
62
62
|
"babel-plugin-rewire": "^1.2.0",
|
|
63
|
-
"chai": "^4.3.
|
|
63
|
+
"chai": "^4.3.10",
|
|
64
64
|
"chai-as-promised": "^7.1.1",
|
|
65
65
|
"cross-env": "^7.0.3",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.51.0",
|
|
67
67
|
"mocha": "^10.2.0",
|
|
68
68
|
"nodemon": "^3.0.1",
|
|
69
69
|
"nyc": "^15.1.0"
|
|
@@ -182,17 +182,6 @@ export function bibHostComponents(record) {
|
|
|
182
182
|
// record is correctly catalogued using a filing indicator -> dc.title search won't match
|
|
183
183
|
|
|
184
184
|
export function bibTitle(record) {
|
|
185
|
-
// We get author/publisher only when formatted title is shorter than 5 chars
|
|
186
|
-
return bibTitleAuthorPublisher({record, onlyTitleLength: 5});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function bibTitleAuthor(record) {
|
|
190
|
-
// We use onlyTitleLength that is longer than our formatted length to
|
|
191
|
-
// get an author or an publisher always
|
|
192
|
-
return bibTitleAuthorPublisher({record, onlyTitleLength: 100});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function bibTitleAuthorPublisher({record, onlyTitleLength}) {
|
|
196
185
|
const title = getTitle();
|
|
197
186
|
const booleanStartWords = ['and', 'or', 'nor', 'not'];
|
|
198
187
|
|
|
@@ -207,38 +196,31 @@ export function bibTitleAuthorPublisher({record, onlyTitleLength}) {
|
|
|
207
196
|
|
|
208
197
|
// use word search for titles starting with a boolean
|
|
209
198
|
const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));
|
|
210
|
-
// Prevent too many matches
|
|
199
|
+
// Prevent too many matches by having a minimum length
|
|
211
200
|
// Note that currently this fails matching if there are no matches from previous matchers
|
|
212
|
-
if (formatted.length >=
|
|
201
|
+
if (formatted.length >= 5) {
|
|
213
202
|
return [`dc.title="${useWordSearch ? '' : '^'}${formatted}*"`];
|
|
214
203
|
}
|
|
215
|
-
const queryIsOkAlone = formatted.length >= 5;
|
|
216
|
-
|
|
217
204
|
// use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return addAuthorsToSearch({query, queryIsOkAlone});
|
|
205
|
+
return addAuthorsToSearch(`dc.title="${formatted}"`);
|
|
221
206
|
}
|
|
222
207
|
|
|
223
208
|
return [];
|
|
224
209
|
|
|
225
|
-
function addAuthorsToSearch(
|
|
210
|
+
function addAuthorsToSearch(titleQuery) {
|
|
226
211
|
const [authorQuery] = bibAuthors(record);
|
|
227
212
|
if (authorQuery !== undefined) {
|
|
228
|
-
return [`${authorQuery} AND ${
|
|
213
|
+
return [`${authorQuery} AND ${titleQuery}`];
|
|
229
214
|
}
|
|
230
|
-
return addPublisherToSearch(
|
|
215
|
+
return addPublisherToSearch(titleQuery);
|
|
231
216
|
//return [];
|
|
232
217
|
}
|
|
233
218
|
|
|
234
|
-
function addPublisherToSearch(
|
|
219
|
+
function addPublisherToSearch(query) {
|
|
235
220
|
const [publisherQuery] = bibPublishers(record);
|
|
236
221
|
if (publisherQuery !== undefined) {
|
|
237
222
|
return [`${publisherQuery} AND ${query}`];
|
|
238
223
|
}
|
|
239
|
-
if (queryIsOkAlone) {
|
|
240
|
-
return [`${query}`];
|
|
241
|
-
}
|
|
242
224
|
return [];
|
|
243
225
|
}
|
|
244
226
|
|
|
@@ -286,6 +268,9 @@ export function bibAuthors(record) {
|
|
|
286
268
|
if (formatted.length >= 5) {
|
|
287
269
|
return [`dc.author="${useWordSearch ? '' : '^'}${formatted}*"`];
|
|
288
270
|
}
|
|
271
|
+
//if (formatted) {
|
|
272
|
+
// return [`dc.author="${formatted}"`];
|
|
273
|
+
//}
|
|
289
274
|
return [];
|
|
290
275
|
}
|
|
291
276
|
|
|
@@ -32,8 +32,7 @@ export const searchTypes = {
|
|
|
32
32
|
bib: {
|
|
33
33
|
standardIdentifiers: 'bibStandardIdentifiers',
|
|
34
34
|
hostComponents: 'bibHostComponents',
|
|
35
|
-
title: 'bibTitle',
|
|
36
|
-
titleAuthor: 'bibTitleAuthor', // title + first author (or first publisher if no author)
|
|
35
|
+
title: 'bibTitle',
|
|
37
36
|
melindaId: 'bibMelindaIds',
|
|
38
37
|
sourceIds: 'bibSourceIds'
|
|
39
38
|
}
|