@natlibfi/melinda-record-matching 5.0.4 → 5.0.5
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-and-publish.yml +4 -4
- package/dist/candidate-search/query-list/bib.js +84 -67
- package/dist/candidate-search/query-list/bib.js.map +3 -3
- package/dist/candidate-search/query-list/component.js +94 -28
- package/dist/candidate-search/query-list/component.js.map +3 -3
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +2 -2
- package/dist/match-detection/features/bib/f773.js +82 -0
- package/dist/match-detection/features/bib/f773.js.map +7 -0
- package/dist/match-detection/features/bib/index.js +1 -1
- package/dist/match-detection/features/bib/index.js.map +2 -2
- package/dist/match-detection/features/bib/index.test.js +1 -1
- package/dist/match-detection/features/bib/index.test.js.map +2 -2
- package/dist/match-detection/features/bib/isbn.js +3 -13
- package/dist/match-detection/features/bib/isbn.js.map +2 -2
- package/dist/match-detection/features/bib/issn.js +2 -16
- package/dist/match-detection/features/bib/issn.js.map +2 -2
- package/dist/match-detection/features/bib/language.js +12 -22
- package/dist/match-detection/features/bib/language.js.map +2 -2
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +6 -2
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +2 -2
- package/dist/match-detection/features/bib/publication-time.js +62 -16
- package/dist/match-detection/features/bib/publication-time.js.map +2 -2
- package/dist/match-detection/features/bib/title.js +76 -26
- package/dist/match-detection/features/bib/title.js.map +3 -3
- package/dist/match-detection/index.js +8 -3
- package/dist/match-detection/index.js.map +2 -2
- package/dist/matching-utils.js +14 -0
- package/dist/matching-utils.js.map +2 -2
- package/package.json +8 -12
- package/src/candidate-search/query-list/bib.js +100 -77
- package/src/candidate-search/query-list/component.js +100 -23
- package/src/cli.js +8 -4
- package/src/match-detection/features/bib/f773.js +118 -0
- package/src/match-detection/features/bib/index.js +1 -1
- package/src/match-detection/features/bib/index.test.js +1 -1
- package/src/match-detection/features/bib/isbn.js +3 -17
- package/src/match-detection/features/bib/issn.js +3 -32
- package/src/match-detection/features/bib/language.js +15 -26
- package/src/match-detection/features/bib/publication-time-allow-cons-years.js +7 -4
- package/src/match-detection/features/bib/publication-time.js +76 -30
- package/src/match-detection/features/bib/title.js +112 -34
- package/src/match-detection/index.js +9 -3
- package/src/matching-utils.js +17 -0
- package/dist/match-detection/features/bib/title-version-original.js +0 -37
- package/dist/match-detection/features/bib/title-version-original.js.map +0 -7
- package/src/match-detection/features/bib/title-version-original.js +0 -52
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import createDebugLogger from 'debug';
|
|
3
|
-
import naturalPkg from 'natural';
|
|
4
|
-
const {LevenshteinDistance: leven} = naturalPkg;
|
|
5
|
-
|
|
6
|
-
export default ({threshold = 10} = {}) => ({
|
|
7
|
-
name: 'titleVersionOriginal',
|
|
8
|
-
extract: ({record}) => {
|
|
9
|
-
const title = getTitle();
|
|
10
|
-
|
|
11
|
-
if (title) {
|
|
12
|
-
return [title.replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase()];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return [];
|
|
16
|
-
|
|
17
|
-
function getTitle() {
|
|
18
|
-
const [field] = record.get(/^245$/u);
|
|
19
|
-
|
|
20
|
-
if (field) {
|
|
21
|
-
return field.subfields
|
|
22
|
-
.filter(({code}) => ['a', 'b'].includes(code))
|
|
23
|
-
.map(({value}) => value)
|
|
24
|
-
.join('');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
compare: (a, b) => {
|
|
29
|
-
const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/title-version-original');
|
|
30
|
-
const distance = leven(a[0], b[0]);
|
|
31
|
-
|
|
32
|
-
if (distance === 0) {
|
|
33
|
-
return 0.5;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const maxLength = getMaxLength();
|
|
37
|
-
const percentage = distance / maxLength * 100;
|
|
38
|
-
|
|
39
|
-
debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);
|
|
40
|
-
|
|
41
|
-
if (percentage <= threshold) {
|
|
42
|
-
return 0.3;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return -0.5;
|
|
46
|
-
|
|
47
|
-
function getMaxLength() {
|
|
48
|
-
return a[0].length > b[0].length ? a[0].length : b[0].length;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
});
|