@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 5.0.0-alpha.2
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/dist/candidate-search/candidate-search-utils.js +6 -43
- package/dist/candidate-search/candidate-search-utils.js.map +7 -1
- package/dist/candidate-search/choose-queries.js +75 -0
- package/dist/candidate-search/choose-queries.js.map +7 -0
- package/dist/candidate-search/index.js +89 -225
- package/dist/candidate-search/index.js.map +7 -1
- package/dist/candidate-search/index.test.js +92 -0
- package/dist/candidate-search/index.test.js.map +7 -0
- package/dist/candidate-search/query-list/bib.js +141 -320
- package/dist/candidate-search/query-list/bib.js.map +7 -1
- package/dist/candidate-search/query-list/bib.test.js +34 -0
- package/dist/candidate-search/query-list/bib.test.js.map +7 -0
- package/dist/candidate-search/query-list/component.js +87 -0
- package/dist/candidate-search/query-list/component.js.map +7 -0
- package/dist/candidate-search/query-list/index.js +39 -52
- package/dist/candidate-search/query-list/index.js.map +7 -1
- package/dist/cli.js +138 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.js +87 -462
- package/dist/index.js.map +7 -1
- package/dist/index.test.js +69 -0
- package/dist/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/all-source-ids.js +20 -91
- package/dist/match-detection/features/bib/all-source-ids.js.map +7 -1
- package/dist/match-detection/features/bib/authors.js +20 -76
- package/dist/match-detection/features/bib/authors.js.map +7 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +4 -40
- package/dist/match-detection/features/bib/bibliographic-level.js.map +7 -1
- package/dist/match-detection/features/bib/host-component.js +5 -41
- package/dist/match-detection/features/bib/host-component.js.map +7 -1
- package/dist/match-detection/features/bib/index.js +17 -119
- package/dist/match-detection/features/bib/index.js.map +7 -1
- package/dist/match-detection/features/bib/index.test.js +40 -0
- package/dist/match-detection/features/bib/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/isbn.js +13 -69
- package/dist/match-detection/features/bib/isbn.js.map +7 -1
- package/dist/match-detection/features/bib/issn.js +5 -50
- package/dist/match-detection/features/bib/issn.js.map +7 -1
- package/dist/match-detection/features/bib/language.js +25 -86
- package/dist/match-detection/features/bib/language.js.map +7 -1
- package/dist/match-detection/features/bib/media-type.js +12 -64
- package/dist/match-detection/features/bib/media-type.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-id.js +5 -47
- package/dist/match-detection/features/bib/melinda-id.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +16 -67
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +5 -51
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +49 -189
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +10 -53
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time.js +8 -46
- package/dist/match-detection/features/bib/publication-time.js.map +7 -1
- package/dist/match-detection/features/bib/record-type.js +4 -43
- package/dist/match-detection/features/bib/record-type.js.map +7 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +47 -163
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/title-version-original.js +11 -53
- package/dist/match-detection/features/bib/title-version-original.js.map +7 -1
- package/dist/match-detection/features/bib/title.js +20 -72
- package/dist/match-detection/features/bib/title.js.map +7 -1
- package/dist/match-detection/features/index.js +3 -11
- package/dist/match-detection/features/index.js.map +7 -1
- package/dist/match-detection/index.js +35 -150
- package/dist/match-detection/index.js.map +7 -1
- package/dist/match-detection/index.test.js +44 -0
- package/dist/match-detection/index.test.js.map +7 -0
- package/dist/matching-utils.js +38 -102
- package/dist/matching-utils.js.map +7 -1
- package/eslint.config.js +52 -0
- package/example.env +4 -0
- package/package.json +29 -78
- 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/index.spec.js +0 -144
- package/dist/candidate-search/index.spec.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/index.spec.js +0 -127
- package/dist/index.spec.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/index.spec.js +0 -91
- package/dist/match-detection/index.spec.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 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/match-detection/features/index.js"],
|
|
4
|
+
"sourcesContent": ["\nimport * as bib from './bib/index.js';\nexport {bib};\n"],
|
|
5
|
+
"mappings": "AACA,YAAY,SAAS;AACrB,SAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,187 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.features = exports.default = void 0;
|
|
7
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
-
var features = _interopRequireWildcard(require("./features"));
|
|
9
|
-
exports.features = features;
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && 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; }
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
16
|
-
*
|
|
17
|
-
* Melinda record matching modules for Javascript
|
|
18
|
-
*
|
|
19
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
20
|
-
*
|
|
21
|
-
* This file is part of melinda-record-matching-js
|
|
22
|
-
*
|
|
23
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
24
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
25
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
26
|
-
* License, or (at your option) any later version.
|
|
27
|
-
*
|
|
28
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
29
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
30
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
31
|
-
* GNU Lesser General Public License for more details.
|
|
32
|
-
*
|
|
33
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
34
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
35
|
-
*
|
|
36
|
-
* @licend The above is the entire license notice
|
|
37
|
-
* for the JavaScript code in this file.
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
var _default = ({
|
|
41
|
-
strategy,
|
|
42
|
-
treshold = 0.9
|
|
43
|
-
}, returnStrategy = false, localSettings = {}) => ({
|
|
44
|
-
recordA,
|
|
45
|
-
recordB,
|
|
46
|
-
recordAExternal = {},
|
|
47
|
-
recordBExternal = {}
|
|
48
|
-
}) => {
|
|
1
|
+
import createDebugLogger from "debug";
|
|
2
|
+
import * as features from "./features/index.js";
|
|
3
|
+
export { features };
|
|
4
|
+
export default ({ strategy, treshold = 0.9 }, returnStrategy = false, localSettings = {}) => ({ recordA, recordB, recordAExternal = {}, recordBExternal = {} }) => {
|
|
49
5
|
const minProbabilityQuantifier = 0.5;
|
|
50
|
-
const debug = (
|
|
51
|
-
const debugData = debug.extend(
|
|
6
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection");
|
|
7
|
+
const debugData = debug.extend("data");
|
|
52
8
|
debugData(`Strategy: ${JSON.stringify(strategy)}, Treshold: ${JSON.stringify(treshold)}, ReturnStrategy: ${JSON.stringify(returnStrategy)}`);
|
|
53
|
-
debugData(`Records: A: ${recordA}
|
|
9
|
+
debugData(`Records: A: ${recordA}
|
|
10
|
+
B: ${recordB}`);
|
|
54
11
|
debug(`Externals: A: ${JSON.stringify(recordAExternal)}, B: ${JSON.stringify(recordBExternal)}`);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const featuresA = extractFeatures({
|
|
58
|
-
record: recordA,
|
|
59
|
-
recordExternal: recordAExternal,
|
|
60
|
-
localSettings
|
|
61
|
-
});
|
|
12
|
+
const featuresA = extractFeatures({ record: recordA, recordExternal: recordAExternal, localSettings });
|
|
62
13
|
debug(`We got an array of records: ${Array.isArray(recordB)}`);
|
|
63
14
|
const recordsB = Array.isArray(recordB) ? recordB : [recordB];
|
|
64
15
|
const recordsBExternal = Array.isArray(recordB) ? recordBExternal : [recordBExternal];
|
|
65
|
-
const detectionResults = recordsB.map((record, index) => actualDetection({
|
|
66
|
-
featuresA,
|
|
67
|
-
recordAExternal,
|
|
68
|
-
record,
|
|
69
|
-
recordExternal: recordsBExternal[index],
|
|
70
|
-
index
|
|
71
|
-
}));
|
|
72
|
-
|
|
73
|
-
// if we got array of records, we return an array of result
|
|
74
|
-
// if we got a singular record, we return a singular result
|
|
16
|
+
const detectionResults = recordsB.map((record, index) => actualDetection({ featuresA, recordAExternal, record, recordExternal: recordsBExternal[index], index }));
|
|
75
17
|
return Array.isArray(recordB) ? detectionResults : detectionResults[0];
|
|
76
|
-
function actualDetection({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
recordExternal,
|
|
80
|
-
index,
|
|
81
|
-
localSettings
|
|
82
|
-
}) {
|
|
83
|
-
const labelA = recordAExternal && recordAExternal.label ? recordAExternal.label : 'a';
|
|
84
|
-
const labelB = recordExternal && recordExternal.label ? recordExternal.label : 'b';
|
|
18
|
+
function actualDetection({ featuresA: featuresA2, record, recordExternal, index, localSettings: localSettings2 }) {
|
|
19
|
+
const labelA = recordAExternal && recordAExternal.label ? recordAExternal.label : "a";
|
|
20
|
+
const labelB = recordExternal && recordExternal.label ? recordExternal.label : "b";
|
|
85
21
|
debug(`Actual detection for record ${index + 1} ${labelB}`);
|
|
86
|
-
const featuresB = extractFeatures({
|
|
87
|
-
|
|
88
|
-
recordExternal,
|
|
89
|
-
localSettings
|
|
90
|
-
});
|
|
91
|
-
debugData(`Features (a: ${labelA}): ${JSON.stringify(featuresA)}`);
|
|
22
|
+
const featuresB = extractFeatures({ record, recordExternal, localSettings: localSettings2 });
|
|
23
|
+
debugData(`Features (a: ${labelA}): ${JSON.stringify(featuresA2)}`);
|
|
92
24
|
debugData(`Features (b: ${labelB}): ${JSON.stringify(featuresB)}`);
|
|
93
|
-
const featurePairs = generateFeaturePairs(
|
|
25
|
+
const featurePairs = generateFeaturePairs(featuresA2, featuresB);
|
|
94
26
|
const similarityVector = generateSimilarityVector(featurePairs);
|
|
95
|
-
if (similarityVector.some(v => v >= minProbabilityQuantifier)) {
|
|
27
|
+
if (similarityVector.some((v) => v >= minProbabilityQuantifier)) {
|
|
96
28
|
const probability = calculateProbability(similarityVector);
|
|
97
29
|
debug(`probability: ${probability} (Treshold: ${treshold})`);
|
|
98
|
-
return returnResult({
|
|
99
|
-
match: probability >= treshold,
|
|
100
|
-
probability
|
|
101
|
-
});
|
|
30
|
+
return returnResult({ match: probability >= treshold, probability });
|
|
102
31
|
}
|
|
103
32
|
debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);
|
|
104
|
-
return returnResult({
|
|
105
|
-
match: false,
|
|
106
|
-
probability: 0.0
|
|
107
|
-
});
|
|
33
|
+
return returnResult({ match: false, probability: 0 });
|
|
108
34
|
}
|
|
109
|
-
function extractFeatures({
|
|
110
|
-
record,
|
|
111
|
-
recordExternal
|
|
112
|
-
}) {
|
|
113
|
-
return strategy.reduce((acc, {
|
|
114
|
-
name,
|
|
115
|
-
extract
|
|
116
|
-
}) => acc.concat({
|
|
117
|
-
name,
|
|
118
|
-
value: extract({
|
|
119
|
-
record,
|
|
120
|
-
recordExternal
|
|
121
|
-
})
|
|
122
|
-
}), []);
|
|
35
|
+
function extractFeatures({ record, recordExternal }) {
|
|
36
|
+
return strategy.reduce((acc, { name, extract }) => acc.concat({ name, value: extract({ record, recordExternal }) }), []);
|
|
123
37
|
}
|
|
124
38
|
function returnResult(result) {
|
|
125
39
|
if (returnStrategy) {
|
|
126
40
|
debug(`Returning detection strategy with the result`);
|
|
127
|
-
const resultWithStrategy = {
|
|
128
|
-
match: result.match,
|
|
129
|
-
probability: result.probability,
|
|
130
|
-
strategy: formatStrategy(strategy),
|
|
131
|
-
treshold
|
|
132
|
-
};
|
|
41
|
+
const resultWithStrategy = { match: result.match, probability: result.probability, strategy: formatStrategy(strategy), treshold };
|
|
133
42
|
debugData(`${JSON.stringify(resultWithStrategy)}`);
|
|
134
43
|
return resultWithStrategy;
|
|
135
44
|
}
|
|
136
45
|
return result;
|
|
137
46
|
}
|
|
138
|
-
function formatStrategy(
|
|
139
|
-
const strategyNames =
|
|
47
|
+
function formatStrategy(strategy2) {
|
|
48
|
+
const strategyNames = strategy2.map((element) => element.name);
|
|
140
49
|
return strategyNames || [];
|
|
141
50
|
}
|
|
142
51
|
function calculateProbability(similarityVector) {
|
|
143
|
-
const probability = similarityVector.reduce((acc, v) => acc + v, 0
|
|
144
|
-
return probability > 1
|
|
52
|
+
const probability = similarityVector.reduce((acc, v) => acc + v, 0);
|
|
53
|
+
return probability > 1 ? 1 : probability;
|
|
145
54
|
}
|
|
146
55
|
function generateSimilarityVector(featurePairs) {
|
|
147
|
-
const compared = featurePairs.map(({
|
|
148
|
-
name
|
|
149
|
-
a,
|
|
150
|
-
b
|
|
151
|
-
}) => {
|
|
152
|
-
const {
|
|
153
|
-
compare
|
|
154
|
-
} = strategy.find(({
|
|
155
|
-
name: featureName
|
|
156
|
-
}) => name === featureName);
|
|
56
|
+
const compared = featurePairs.map(({ name, a, b }) => {
|
|
57
|
+
const { compare } = strategy.find(({ name: featureName }) => name === featureName);
|
|
157
58
|
const points = compare(a, b);
|
|
158
|
-
return {
|
|
159
|
-
name,
|
|
160
|
-
points
|
|
161
|
-
};
|
|
59
|
+
return { name, points };
|
|
162
60
|
});
|
|
163
61
|
debugData(`Points: ${JSON.stringify(compared)}`);
|
|
164
|
-
return compared.map(({
|
|
165
|
-
points
|
|
166
|
-
}) => points);
|
|
62
|
+
return compared.map(({ points }) => points);
|
|
167
63
|
}
|
|
168
|
-
function generateFeaturePairs(
|
|
64
|
+
function generateFeaturePairs(featuresA2, featuresB) {
|
|
169
65
|
const pairs = generatePairs();
|
|
170
66
|
const missingFeatures = findMissing();
|
|
171
67
|
debug(`Not comparing the following features because one, or both records are missing features: ${JSON.stringify(missingFeatures)}`);
|
|
172
68
|
return pairs;
|
|
173
69
|
function generatePairs() {
|
|
174
|
-
return
|
|
175
|
-
name,
|
|
176
|
-
value
|
|
177
|
-
}, index) => acc.concat({
|
|
70
|
+
return featuresA2.reduce((acc, { name, value }, index) => acc.concat({
|
|
178
71
|
name,
|
|
179
72
|
a: value,
|
|
180
73
|
b: featuresB[index].value
|
|
181
|
-
}), []).filter(({
|
|
182
|
-
a,
|
|
183
|
-
b
|
|
184
|
-
}) => {
|
|
74
|
+
}), []).filter(({ a, b }) => {
|
|
185
75
|
if (a.length === 0 || b.length === 0) {
|
|
186
76
|
return false;
|
|
187
77
|
}
|
|
@@ -189,13 +79,8 @@ var _default = ({
|
|
|
189
79
|
});
|
|
190
80
|
}
|
|
191
81
|
function findMissing() {
|
|
192
|
-
return
|
|
193
|
-
name
|
|
194
|
-
}) => name).filter(v => pairs.some(({
|
|
195
|
-
name
|
|
196
|
-
}) => name === v) === false);
|
|
82
|
+
return featuresA2.map(({ name }) => name).filter((v) => pairs.some(({ name }) => name === v) === false);
|
|
197
83
|
}
|
|
198
84
|
}
|
|
199
85
|
};
|
|
200
|
-
|
|
201
|
-
//# sourceMappingURL=index.js.map
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","features","_interopRequireWildcard","exports","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_default","strategy","treshold","returnStrategy","localSettings","recordA","recordB","recordAExternal","recordBExternal","minProbabilityQuantifier","debug","createDebugLogger","debugData","extend","JSON","stringify","featuresA","extractFeatures","record","recordExternal","Array","isArray","recordsB","recordsBExternal","detectionResults","map","index","actualDetection","labelA","label","labelB","featuresB","featurePairs","generateFeaturePairs","similarityVector","generateSimilarityVector","some","v","probability","calculateProbability","returnResult","match","reduce","acc","name","extract","concat","value","result","resultWithStrategy","formatStrategy","strategyNames","element","compared","b","compare","find","featureName","points","pairs","generatePairs","missingFeatures","findMissing","filter","length"],"sources":["../../src/match-detection/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 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 createDebugLogger from 'debug';\nimport * as features from './features';\n\nexport {features};\n\nexport default ({strategy, treshold = 0.9}, returnStrategy = false, localSettings = {}) => ({recordA, recordB, recordAExternal = {}, recordBExternal = {}}) => {\n const minProbabilityQuantifier = 0.5;\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection');\n const debugData = debug.extend('data');\n\n debugData(`Strategy: ${JSON.stringify(strategy)}, Treshold: ${JSON.stringify(treshold)}, ReturnStrategy: ${JSON.stringify(returnStrategy)}`);\n debugData(`Records: A: ${recordA}\\nB: ${recordB}`);\n debug(`Externals: A: ${JSON.stringify(recordAExternal)}, B: ${JSON.stringify(recordBExternal)}`);\n // We could add here labels for records if we didn't get external labels\n\n const featuresA = extractFeatures({record: recordA, recordExternal: recordAExternal, localSettings});\n\n debug(`We got an array of records: ${Array.isArray(recordB)}`);\n const recordsB = Array.isArray(recordB) ? recordB : [recordB];\n const recordsBExternal = Array.isArray(recordB) ? recordBExternal : [recordBExternal];\n\n const detectionResults = recordsB.map((record, index) => actualDetection({featuresA, recordAExternal, record, recordExternal: recordsBExternal[index], index}));\n\n // if we got array of records, we return an array of result\n // if we got a singular record, we return a singular result\n return Array.isArray(recordB) ? detectionResults : detectionResults[0];\n\n function actualDetection({featuresA, record, recordExternal, index, localSettings}) {\n const labelA = recordAExternal && recordAExternal.label ? recordAExternal.label : 'a';\n const labelB = recordExternal && recordExternal.label ? recordExternal.label : 'b';\n\n\n debug(`Actual detection for record ${index + 1} ${labelB}`);\n const featuresB = extractFeatures({record, recordExternal, localSettings});\n\n debugData(`Features (a: ${labelA}): ${JSON.stringify(featuresA)}`);\n debugData(`Features (b: ${labelB}): ${JSON.stringify(featuresB)}`);\n\n const featurePairs = generateFeaturePairs(featuresA, featuresB);\n const similarityVector = generateSimilarityVector(featurePairs);\n\n if (similarityVector.some(v => v >= minProbabilityQuantifier)) {\n const probability = calculateProbability(similarityVector);\n debug(`probability: ${probability} (Treshold: ${treshold})`);\n return returnResult({match: probability >= treshold, probability});\n }\n\n debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);\n return returnResult({match: false, probability: 0.0});\n }\n\n function extractFeatures({record, recordExternal}) {\n return strategy.reduce((acc, {name, extract}) => acc.concat({name, value: extract({record, recordExternal})}), []);\n }\n\n function returnResult(result) {\n if (returnStrategy) {\n debug(`Returning detection strategy with the result`);\n const resultWithStrategy = {match: result.match, probability: result.probability, strategy: formatStrategy(strategy), treshold};\n debugData(`${JSON.stringify(resultWithStrategy)}`);\n return resultWithStrategy;\n }\n return result;\n }\n\n function formatStrategy(strategy) {\n const strategyNames = strategy.map(element => element.name);\n return strategyNames || [];\n }\n\n function calculateProbability(similarityVector) {\n const probability = similarityVector.reduce((acc, v) => acc + v, 0.0);\n return probability > 1.0 ? 1.0 : probability;\n }\n\n function generateSimilarityVector(featurePairs) {\n const compared = featurePairs.map(({name, a, b}) => {\n const {compare} = strategy.find(({name: featureName}) => name === featureName);\n const points = compare(a, b);\n return {name, points};\n });\n\n debugData(`Points: ${JSON.stringify(compared)}`);\n return compared.map(({points}) => points);\n }\n\n function generateFeaturePairs(featuresA, featuresB) {\n const pairs = generatePairs();\n const missingFeatures = findMissing();\n\n debug(`Not comparing the following features because one, or both records are missing features: ${JSON.stringify(missingFeatures)}`);\n return pairs;\n\n function generatePairs() {\n return featuresA\n .reduce((acc, {name, value}, index) => acc.concat({\n name,\n a: value,\n b: featuresB[index].value\n }), [])\n .filter(({a, b}) => {\n if (a.length === 0 || b.length === 0) {\n return false;\n }\n\n return true;\n });\n }\n\n function findMissing() {\n return featuresA\n .map(({name}) => name)\n .filter(v => pairs.some(({name}) => name === v) === false);\n }\n }\n\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAuCG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,IAAI;QAAEG;MAAK,CAAC,EAAErB,KAAK,KAAKiB,GAAG,CAACG,MAAM,CAAC;QAChDF,IAAI;QACJvD,CAAC,EAAE0D,KAAK;QACRO,CAAC,EAAEvB,SAAS,CAACL,KAAK,CAAC,CAACqB;MACtB,CAAC,CAAC,EAAE,EAAE,CAAC,CACNgB,MAAM,CAAC,CAAC;QAAC1E,CAAC;QAAEiE;MAAC,CAAC,KAAK;QAClB,IAAIjE,CAAC,CAAC2E,MAAM,KAAK,CAAC,IAAIV,CAAC,CAACU,MAAM,KAAK,CAAC,EAAE;UACpC,OAAO,KAAK;QACd;QAEA,OAAO,IAAI;MACb,CAAC,CAAC;IACN;IAEA,SAASF,WAAWA,CAAA,EAAG;MACrB,OAAO9C,SAAS,CACbS,GAAG,CAAC,CAAC;QAACmB;MAAI,CAAC,KAAKA,IAAI,CAAC,CACrBmB,MAAM,CAAC1B,CAAC,IAAIsB,KAAK,CAACvB,IAAI,CAAC,CAAC;QAACQ;MAAI,CAAC,KAAKA,IAAI,KAAKP,CAAC,CAAC,KAAK,KAAK,CAAC;IAC9D;EACF;AAEF,CAAC;AAAA5D,OAAA,CAAAO,OAAA,GAAAgB,QAAA"}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/match-detection/index.js"],
|
|
4
|
+
"sourcesContent": ["\nimport createDebugLogger from 'debug';\nimport * as features from './features/index.js';\n\nexport {features};\n\nexport default ({strategy, treshold = 0.9}, returnStrategy = false, localSettings = {}) => ({recordA, recordB, recordAExternal = {}, recordBExternal = {}}) => {\n const minProbabilityQuantifier = 0.5;\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection');\n const debugData = debug.extend('data');\n\n debugData(`Strategy: ${JSON.stringify(strategy)}, Treshold: ${JSON.stringify(treshold)}, ReturnStrategy: ${JSON.stringify(returnStrategy)}`);\n debugData(`Records: A: ${recordA}\\nB: ${recordB}`);\n debug(`Externals: A: ${JSON.stringify(recordAExternal)}, B: ${JSON.stringify(recordBExternal)}`);\n // We could add here labels for records if we didn't get external labels\n\n const featuresA = extractFeatures({record: recordA, recordExternal: recordAExternal, localSettings});\n\n debug(`We got an array of records: ${Array.isArray(recordB)}`);\n const recordsB = Array.isArray(recordB) ? recordB : [recordB];\n const recordsBExternal = Array.isArray(recordB) ? recordBExternal : [recordBExternal];\n\n const detectionResults = recordsB.map((record, index) => actualDetection({featuresA, recordAExternal, record, recordExternal: recordsBExternal[index], index}));\n\n // if we got array of records, we return an array of result\n // if we got a singular record, we return a singular result\n return Array.isArray(recordB) ? detectionResults : detectionResults[0];\n\n function actualDetection({featuresA, record, recordExternal, index, localSettings}) {\n const labelA = recordAExternal && recordAExternal.label ? recordAExternal.label : 'a';\n const labelB = recordExternal && recordExternal.label ? recordExternal.label : 'b';\n\n\n debug(`Actual detection for record ${index + 1} ${labelB}`);\n const featuresB = extractFeatures({record, recordExternal, localSettings});\n\n debugData(`Features (a: ${labelA}): ${JSON.stringify(featuresA)}`);\n debugData(`Features (b: ${labelB}): ${JSON.stringify(featuresB)}`);\n\n const featurePairs = generateFeaturePairs(featuresA, featuresB);\n const similarityVector = generateSimilarityVector(featurePairs);\n\n if (similarityVector.some(v => v >= minProbabilityQuantifier)) {\n const probability = calculateProbability(similarityVector);\n debug(`probability: ${probability} (Treshold: ${treshold})`);\n return returnResult({match: probability >= treshold, probability});\n }\n\n debugData(`No feature yielded minimum probability amount of points (${minProbabilityQuantifier})`);\n return returnResult({match: false, probability: 0.0});\n }\n\n function extractFeatures({record, recordExternal}) {\n return strategy.reduce((acc, {name, extract}) => acc.concat({name, value: extract({record, recordExternal})}), []);\n }\n\n function returnResult(result) {\n if (returnStrategy) {\n debug(`Returning detection strategy with the result`);\n const resultWithStrategy = {match: result.match, probability: result.probability, strategy: formatStrategy(strategy), treshold};\n debugData(`${JSON.stringify(resultWithStrategy)}`);\n return resultWithStrategy;\n }\n return result;\n }\n\n function formatStrategy(strategy) {\n const strategyNames = strategy.map(element => element.name);\n return strategyNames || [];\n }\n\n function calculateProbability(similarityVector) {\n const probability = similarityVector.reduce((acc, v) => acc + v, 0.0);\n return probability > 1.0 ? 1.0 : probability;\n }\n\n function generateSimilarityVector(featurePairs) {\n const compared = featurePairs.map(({name, a, b}) => {\n const {compare} = strategy.find(({name: featureName}) => name === featureName);\n const points = compare(a, b);\n return {name, points};\n });\n\n debugData(`Points: ${JSON.stringify(compared)}`);\n return compared.map(({points}) => points);\n }\n\n function generateFeaturePairs(featuresA, featuresB) {\n const pairs = generatePairs();\n const missingFeatures = findMissing();\n\n debug(`Not comparing the following features because one, or both records are missing features: ${JSON.stringify(missingFeatures)}`);\n return pairs;\n\n function generatePairs() {\n return featuresA\n .reduce((acc, {name, value}, index) => acc.concat({\n name,\n a: value,\n b: featuresB[index].value\n }), [])\n .filter(({a, b}) => {\n if (a.length === 0 || b.length === 0) {\n return false;\n }\n\n return true;\n });\n }\n\n function findMissing() {\n return featuresA\n .map(({name}) => name)\n .filter(v => pairs.some(({name}) => name === v) === false);\n }\n }\n\n};\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,uBAAuB;AAC9B,YAAY,cAAc;AAE1B,SAAQ;AAER,eAAe,CAAC,EAAC,UAAU,WAAW,IAAG,GAAG,iBAAiB,OAAO,gBAAgB,CAAC,MAAM,CAAC,EAAC,SAAS,SAAS,kBAAkB,CAAC,GAAG,kBAAkB,CAAC,EAAC,MAAM;AAC7J,QAAM,2BAA2B;AAEjC,QAAM,QAAQ,kBAAkB,mDAAmD;AACnF,QAAM,YAAY,MAAM,OAAO,MAAM;AAErC,YAAU,aAAa,KAAK,UAAU,QAAQ,CAAC,eAAe,KAAK,UAAU,QAAQ,CAAC,qBAAqB,KAAK,UAAU,cAAc,CAAC,EAAE;AAC3I,YAAU,eAAe,OAAO;AAAA,KAAQ,OAAO,EAAE;AACjD,QAAM,iBAAiB,KAAK,UAAU,eAAe,CAAC,QAAQ,KAAK,UAAU,eAAe,CAAC,EAAE;AAG/F,QAAM,Y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AEpC,UAAM,2FAA2F,KAAK,UAAU,eAAe,CAAC,EAAE;AAClI,WAAO;AAEP,aAAS,gBAAgB;AACvB,aAAOA,WACJ,OAAO,CAAC,KAAK,EAAC,MAAM,MAAK,GAAG,UAAU,IAAI,OAAO;AAAA,QAChD;AAAA,QACA,GAAG;AAAA,QACH,GAAG,UAAU,KAAK,EAAE;AAAA,MACtB,CAAC,GAAG,CAAC,CAAC,EACL,OAAO,CAAC,EAAC,GAAG,EAAC,MAAM;AAClB,YAAI,EAAE,WAAW,KAAK,EAAE,WAAW,GAAG;AACpC,iBAAO;AAAA,QACT;AAEA,eAAO;AAAA,MACT,CAAC;AAAA,IACL;AAEA,aAAS,cAAc;AACrB,aAAOA,WACJ,IAAI,CAAC,EAAC,KAAI,MAAM,IAAI,EACpB,OAAO,OAAK,MAAM,KAAK,CAAC,EAAC,KAAI,MAAM,SAAS,CAAC,MAAM,KAAK;AAAA,IAC7D;AAAA,EACF;AAEF;",
|
|
6
|
+
"names": ["featuresA", "localSettings", "strategy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
import { describe } from "node:test";
|
|
3
|
+
import createDebugLogger from "debug";
|
|
4
|
+
import { inspect } from "util";
|
|
5
|
+
import generateTests from "@natlibfi/fixugen";
|
|
6
|
+
import { READERS } from "@natlibfi/fixura";
|
|
7
|
+
import { MarcRecord } from "@natlibfi/marc-record";
|
|
8
|
+
import createDetectionInterface from "./index.js";
|
|
9
|
+
import * as features from "./features/index.js";
|
|
10
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:test");
|
|
11
|
+
const debugData = debug.extend("data");
|
|
12
|
+
describe("match-detection", () => {
|
|
13
|
+
generateTests({
|
|
14
|
+
path: [import.meta.dirname, "..", "..", "test-fixtures", "match-detection", "index"],
|
|
15
|
+
useMetadataFile: true,
|
|
16
|
+
recurse: false,
|
|
17
|
+
fixura: {
|
|
18
|
+
reader: READERS.JSON
|
|
19
|
+
},
|
|
20
|
+
callback: ({ getFixture, options, expectedResults, array, enabled = true }) => {
|
|
21
|
+
if (!enabled) {
|
|
22
|
+
debug(`*** DISABLED TEST! ***`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const detect = createDetectionInterface(formatOptions());
|
|
26
|
+
const recordA = new MarcRecord(getFixture("recordA.json"), { subfieldValues: false });
|
|
27
|
+
debugData(inspect(recordA));
|
|
28
|
+
debug(`Our recordB is an array of records: ${array}`);
|
|
29
|
+
const recordB = array ? getFixture("recordB.json").map((recordJson) => new MarcRecord(recordJson, { subfieldValues: false })) : new MarcRecord(getFixture("recordB.json"), { subfieldValues: false });
|
|
30
|
+
debugData(inspect(recordB));
|
|
31
|
+
const results = detect({ recordA, recordB });
|
|
32
|
+
debugData(`${JSON.stringify(results)}`);
|
|
33
|
+
assert.deepStrictEqual(results, expectedResults);
|
|
34
|
+
function formatOptions() {
|
|
35
|
+
const contextFeatures = features[options.strategy.type];
|
|
36
|
+
return {
|
|
37
|
+
...options,
|
|
38
|
+
strategy: options.strategy.features.map((v) => contextFeatures[v]())
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/match-detection/index.test.js"],
|
|
4
|
+
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport {inspect} from 'util';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\n\nimport createDetectionInterface from './index.js';\nimport * as features from './features/index.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:test');\nconst debugData = debug.extend('data');\n\ndescribe('match-detection', () => {\n generateTests({\n path: [import.meta.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 assert.deepStrictEqual(results, 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"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,SAAQ,eAAc;AACtB,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AAEzB,OAAO,8BAA8B;AACrC,YAAY,cAAc;AAE1B,MAAM,QAAQ,kBAAkB,wDAAwD;AACxF,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAS,mBAAmB,MAAM;AAChC,gBAAc;AAAA,IACZ,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,iBAAiB,mBAAmB,OAAO;AAAA,IACnF,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,UAAU,CAAC,EAAC,YAAY,SAAS,iBAAiB,OAAO,UAAU,KAAI,MAAM;AAE3E,UAAI,CAAC,SAAS;AACZ,cAAM,wBAAwB;AAC9B;AAAA,MACF;AAEA,YAAM,SAAS,yBAAyB,cAAc,CAAC;AACvD,YAAM,UAAU,IAAI,WAAW,WAAW,cAAc,GAAG,EAAC,gBAAgB,MAAK,CAAC;AAClF,gBAAU,QAAQ,OAAO,CAAC;AAE1B,YAAM,uCAAuC,KAAK,EAAE;AACpD,YAAM,UAAU,QACZ,WAAW,cAAc,EAAE,IAAI,gBAAc,IAAI,WAAW,YAAY,EAAC,gBAAgB,MAAK,CAAC,CAAC,IAChG,IAAI,WAAW,WAAW,cAAc,GAAG,EAAC,gBAAgB,MAAK,CAAC;AACtE,gBAAU,QAAQ,OAAO,CAAC;AAE1B,YAAM,UAAU,OAAO,EAAC,SAAS,QAAO,CAAC;AACzC,gBAAU,GAAG,KAAK,UAAU,OAAO,CAAC,EAAE;AAEtC,aAAO,gBAAgB,SAAS,eAAe;AAE/C,eAAS,gBAAgB;AACvB,cAAM,kBAAkB,SAAS,QAAQ,SAAS,IAAI;AAEtD,eAAO;AAAA,UACL,GAAG;AAAA,UACH,UAAU,QAAQ,SAAS,SAAS,IAAI,OAAK,gBAAgB,CAAC,EAAE,CAAC;AAAA,QACnE;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/matching-utils.js
CHANGED
|
@@ -1,123 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.getMelindaIdsF035 = getMelindaIdsF035;
|
|
9
|
-
exports.getSubfieldValues = getSubfieldValues;
|
|
10
|
-
exports.testStringOrNumber = testStringOrNumber;
|
|
11
|
-
exports.uniqueSubfields = uniqueSubfields;
|
|
12
|
-
exports.validateSidFieldSubfieldCounts = validateSidFieldSubfieldCounts;
|
|
13
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
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
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:utils');
|
|
44
|
-
const debugData = debug.extend('data');
|
|
45
|
-
function getMelindaIdsF035(record) {
|
|
46
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:melinda-id');
|
|
47
|
-
const debugData = debug.extend('data');
|
|
48
|
-
const f035s = record.getFields('035');
|
|
1
|
+
import createDebugLogger from "debug";
|
|
2
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:utils");
|
|
3
|
+
const debugData = debug.extend("data");
|
|
4
|
+
export function getMelindaIdsF035(record) {
|
|
5
|
+
const debug2 = createDebugLogger("@natlibfi/melinda-record-matching:melinda-id");
|
|
6
|
+
const debugData2 = debug2.extend("data");
|
|
7
|
+
const f035s = record.getFields("035");
|
|
49
8
|
if (f035s.length < 1) {
|
|
50
|
-
|
|
9
|
+
debug2(`No f035s found.`);
|
|
51
10
|
return [];
|
|
52
11
|
}
|
|
53
|
-
const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));
|
|
12
|
+
const allF035MelindaIds = [].concat(...f035s.map((field) => toMelindaIds(field)));
|
|
54
13
|
const f035MelindaIds = [...new Set(allF035MelindaIds)];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
14
|
+
debugData2(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);
|
|
15
|
+
debugData2(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);
|
|
16
|
+
debugData2(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);
|
|
58
17
|
return f035MelindaIds;
|
|
59
|
-
function toMelindaIds({
|
|
60
|
-
subfields
|
|
61
|
-
}) {
|
|
62
|
-
const melindaIdRegExp = /^(?<prefix>\(FI-MELINDA\)|FCC)(?<id>\d{9})$/u;
|
|
63
|
-
return subfields.filter(sub => ['a', 'z'].includes(sub.code)).filter(sub => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value))).map(({
|
|
64
|
-
value
|
|
65
|
-
}) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, '$<id>') : '');
|
|
66
|
-
}
|
|
67
18
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
19
|
+
export function toMelindaIds({ subfields }, subfieldsToParse = ["a", "z"]) {
|
|
20
|
+
const melindaIdRegExp = /^(?<prefix>\(FI-MELINDA\)|FCC)(?<id>\d{9})$/u;
|
|
21
|
+
return subfields.filter((sub) => subfieldsToParse.includes(sub.code)).filter((sub) => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value))).map(({ value }) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, "$<id>") : "");
|
|
22
|
+
}
|
|
23
|
+
export function validateSidFieldSubfieldCounts(field) {
|
|
70
24
|
debugData(`Validating SID field ${JSON.stringify(field)}`);
|
|
71
|
-
const countC = countSubfields(field,
|
|
72
|
-
const countB = countSubfields(field,
|
|
25
|
+
const countC = countSubfields(field, "c");
|
|
26
|
+
const countB = countSubfields(field, "b");
|
|
73
27
|
debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);
|
|
74
28
|
return countC === 1 && countB === 1;
|
|
75
29
|
}
|
|
76
30
|
function countSubfields(field, subfieldCode) {
|
|
77
|
-
|
|
78
|
-
return field.subfields.filter(({
|
|
79
|
-
code
|
|
80
|
-
}) => code === subfieldCode).length;
|
|
31
|
+
return field.subfields.filter(({ code }) => code === subfieldCode).length;
|
|
81
32
|
}
|
|
82
|
-
function getSubfieldValues(field, subfieldCode) {
|
|
33
|
+
export function getSubfieldValues(field, subfieldCode) {
|
|
83
34
|
debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);
|
|
84
|
-
return field.subfields.filter(({
|
|
85
|
-
code
|
|
86
|
-
}) => code === subfieldCode).map(({
|
|
87
|
-
value
|
|
88
|
-
}) => testStringOrNumber(value) ? String(value) : '').filter(value => value);
|
|
35
|
+
return field.subfields.filter(({ code }) => code === subfieldCode).map(({ value }) => testStringOrNumber(value) ? String(value) : "").filter((value) => value);
|
|
89
36
|
}
|
|
90
|
-
function testStringOrNumber(value) {
|
|
91
|
-
if (typeof value ===
|
|
37
|
+
export function testStringOrNumber(value) {
|
|
38
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
92
39
|
return true;
|
|
93
40
|
}
|
|
94
41
|
return false;
|
|
95
42
|
}
|
|
96
|
-
function extractSubfieldsFromField(field, subfieldCodes) {
|
|
97
|
-
if (field ===
|
|
43
|
+
export function extractSubfieldsFromField(field, subfieldCodes) {
|
|
44
|
+
if (field === void 0 || field.subfields === void 0) {
|
|
98
45
|
return [];
|
|
99
46
|
}
|
|
100
|
-
const resultSubfields = field.subfields.filter(({
|
|
101
|
-
code
|
|
102
|
-
}) => subfieldCodes.includes(code)).map(({
|
|
103
|
-
code,
|
|
104
|
-
value
|
|
105
|
-
}) => ({
|
|
106
|
-
code,
|
|
107
|
-
value: testStringOrNumber(value) ? String(value) : ''
|
|
108
|
-
})).filter(value => value);
|
|
47
|
+
const resultSubfields = field.subfields.filter(({ code }) => subfieldCodes.includes(code)).map(({ code, value }) => ({ code, value: testStringOrNumber(value) ? String(value) : "" })).filter((value) => value);
|
|
109
48
|
return resultSubfields;
|
|
110
49
|
}
|
|
111
|
-
function uniqueSubfields(subfields) {
|
|
50
|
+
export function uniqueSubfields(subfields) {
|
|
112
51
|
return subfields.reduce((arr, e) => {
|
|
113
|
-
if (!arr.find(item => item.code === e.code && item.value === e.value)) {
|
|
52
|
+
if (!arr.find((item) => item.code === e.code && item.value === e.value)) {
|
|
114
53
|
const newArr = arr.concat(e);
|
|
115
54
|
return newArr;
|
|
116
55
|
}
|
|
117
56
|
return arr;
|
|
118
57
|
}, []);
|
|
119
58
|
}
|
|
120
|
-
function getMatchCounts(aValues, bValues) {
|
|
59
|
+
export function getMatchCounts(aValues, bValues) {
|
|
121
60
|
const matchingValues = getMatchingValuesAmount(aValues, bValues);
|
|
122
61
|
return {
|
|
123
62
|
maxValues: aValues.length > bValues.length ? aValues.length : bValues.length,
|
|
@@ -125,19 +64,16 @@ function getMatchCounts(aValues, bValues) {
|
|
|
125
64
|
possibleMatchValues: aValues.length > bValues.length ? bValues.length : aValues.length,
|
|
126
65
|
matchingValues
|
|
127
66
|
};
|
|
128
|
-
function getMatchingValuesAmount(
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
67
|
+
function getMatchingValuesAmount(aValues2, bValues2) {
|
|
68
|
+
if (bValues2.length > aValues2.length) {
|
|
69
|
+
return aValues2.filter((aValue) => bValues2.some((bValue) => aValue === bValue)).length;
|
|
131
70
|
}
|
|
132
|
-
if (
|
|
133
|
-
return
|
|
71
|
+
if (aValues2.length > bValues2.length) {
|
|
72
|
+
return bValues2.filter((bValue) => aValues2.some((aValue) => bValue === aValue)).length;
|
|
134
73
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// there would be duplicate values
|
|
138
|
-
const aToB = aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length;
|
|
139
|
-
const bToA = bValues.filter(bValue => aValues.some(aValue => bValue === aValue)).length;
|
|
74
|
+
const aToB = aValues2.filter((aValue) => bValues2.some((bValue) => aValue === bValue)).length;
|
|
75
|
+
const bToA = bValues2.filter((bValue) => aValues2.some((aValue) => bValue === aValue)).length;
|
|
140
76
|
return aToB < bToA ? aToB : bToA;
|
|
141
77
|
}
|
|
142
78
|
}
|
|
143
|
-
//# sourceMappingURL=matching-utils.js.map
|
|
79
|
+
//# sourceMappingURL=matching-utils.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"matching-utils.js","names":["_debug","_interopRequireDefault","require","obj","__esModule","default","debug","createDebugLogger","debugData","extend","getMelindaIdsF035","record","f035s","getFields","length","allF035MelindaIds","concat","map","toMelindaIds","f035MelindaIds","Set","JSON","stringify","subfields","melindaIdRegExp","filter","sub","includes","code","testStringOrNumber","value","test","String","replace","validateSidFieldSubfieldCounts","field","countC","countSubfields","countB","subfieldCode","getSubfieldValues","extractSubfieldsFromField","subfieldCodes","undefined","resultSubfields","uniqueSubfields","reduce","arr","e","find","item","newArr","getMatchCounts","aValues","bValues","matchingValues","getMatchingValuesAmount","maxValues","possibleMatchValues","aValue","some","bValue","aToB","bToA"],"sources":["../src/matching-utils.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 createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:utils');\nconst debugData = debug.extend('data');\n\nexport function getMelindaIdsF035(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:melinda-id');\n const debugData = debug.extend('data');\n\n const f035s = record.getFields('035');\n\n if (f035s.length < 1) {\n debug(`No f035s found.`);\n return [];\n }\n\n const allF035MelindaIds = [].concat(...f035s.map(toMelindaIds));\n const f035MelindaIds = [...new Set(allF035MelindaIds)];\n\n debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);\n debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);\n debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);\n\n return f035MelindaIds;\n\n function toMelindaIds({subfields}) {\n const melindaIdRegExp = /^(?<prefix>\\(FI-MELINDA\\)|FCC)(?<id>\\d{9})$/u;\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code))\n .filter(sub => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value)))\n .map(({value}) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, '$<id>') : '');\n\n }\n}\n\nexport function validateSidFieldSubfieldCounts(field) {\n // Valid SID-fields have just one $c and one $b\n debugData(`Validating SID field ${JSON.stringify(field)}`);\n const countC = countSubfields(field, 'c');\n const countB = countSubfields(field, 'b');\n debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);\n\n return countC === 1 && countB === 1;\n}\n\nfunction countSubfields(field, subfieldCode) {\n // debug(`Counting subfields ${subfieldCode}`);\n return field.subfields.filter(({code}) => code === subfieldCode).length;\n}\n\nexport function getSubfieldValues(field, subfieldCode) {\n debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);\n return field.subfields\n .filter(({code}) => code === subfieldCode)\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value);\n}\n\nexport function testStringOrNumber(value) {\n if (typeof value === 'string' || typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport function extractSubfieldsFromField(field, subfieldCodes) {\n if (field === undefined || field.subfields === undefined) {\n return [];\n }\n const resultSubfields = field.subfields\n .filter(({code}) => subfieldCodes.includes(code))\n .map(({code, value}) => ({code, value: testStringOrNumber(value) ? String(value) : ''}))\n .filter(value => value);\n return resultSubfields;\n}\n\nexport function uniqueSubfields(subfields) {\n return subfields.reduce((arr, e) => {\n if (!arr.find(item => item.code === e.code && item.value === e.value)) {\n const newArr = arr.concat(e);\n return newArr;\n }\n return arr;\n }, []);\n}\n\nexport function getMatchCounts(aValues, bValues) {\n\n const matchingValues = getMatchingValuesAmount(aValues, bValues);\n\n return {\n maxValues: aValues.length > bValues.length ? aValues.length : bValues.length,\n // possibleMatchingValues: amount of identifiers in set of less identifiers (we cannot more values than these)\n possibleMatchValues: aValues.length > bValues.length ? bValues.length : aValues.length,\n matchingValues\n };\n\n function getMatchingValuesAmount(aValues, bValues) {\n if (bValues.length > aValues.length) {\n return aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length;\n }\n if (aValues.length > bValues.length) {\n return bValues.filter(bValue => aValues.some(aValue => bValue === aValue)).length;\n }\n\n // If we have same amount of values, we'll check matches both ways, to avoid mixups in cases\n // there would be duplicate values\n const aToB = aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length;\n const bToA = bValues.filter(bValue => aValues.some(aValue => bValue === aValue)).length;\n\n return aToB < bToA ? aToB : bToA;\n }\n}\n"],"mappings":";;;;;;;;;;;;AA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AAM,IAAIL,OAAO,CAACM,IAAI,CAACC,MAAM,IAAIF,MAAM,KAAKE,MAAM,CAAC,CAAC,CAAC/C,MAAM;IACvF,MAAMiD,IAAI,GAAGT,OAAO,CAAC7B,MAAM,CAACoC,MAAM,IAAIR,OAAO,CAACO,IAAI,CAACD,MAAM,IAAIE,MAAM,KAAKF,MAAM,CAAC,CAAC,CAAC7C,MAAM;IAEvF,OAAOgD,IAAI,GAAGC,IAAI,GAAGD,IAAI,GAAGC,IAAI;EAClC;AACF"}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/matching-utils.js"],
|
|
4
|
+
"sourcesContent": ["import createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:utils');\nconst debugData = debug.extend('data');\n\nexport function getMelindaIdsF035(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:melinda-id');\n const debugData = debug.extend('data');\n\n const f035s = record.getFields('035');\n\n if (f035s.length < 1) {\n debug(`No f035s found.`);\n return [];\n }\n\n const allF035MelindaIds = [].concat(...f035s.map(field => toMelindaIds(field)));\n const f035MelindaIds = [...new Set(allF035MelindaIds)];\n\n debugData(`Fields (${f035s.length}): ${JSON.stringify(f035s)}`);\n debugData(`Ids (${allF035MelindaIds.length}): ${JSON.stringify(allF035MelindaIds)}`);\n debugData(`Unique ids (${f035MelindaIds.length}): ${JSON.stringify(f035MelindaIds)}`);\n\n return f035MelindaIds;\n}\n\nexport function toMelindaIds({subfields}, subfieldsToParse = ['a', 'z']) {\n const melindaIdRegExp = /^(?<prefix>\\(FI-MELINDA\\)|FCC)(?<id>\\d{9})$/u;\n\n return subfields\n .filter(sub => subfieldsToParse.includes(sub.code))\n .filter(sub => testStringOrNumber(sub.value) && melindaIdRegExp.test(String(sub.value)))\n .map(({value}) => testStringOrNumber(value) ? String(value).replace(melindaIdRegExp, '$<id>') : '');\n}\n\nexport function validateSidFieldSubfieldCounts(field) {\n // Valid SID-fields have just one $c and one $b\n debugData(`Validating SID field ${JSON.stringify(field)}`);\n const countC = countSubfields(field, 'c');\n const countB = countSubfields(field, 'b');\n debug(`Found ${countC} sf $cs and ${countB} sf $bs. IsValid: ${countC === 1 && countB === 1}`);\n\n return countC === 1 && countB === 1;\n}\n\nfunction countSubfields(field, subfieldCode) {\n // debug(`Counting subfields ${subfieldCode}`);\n return field.subfields.filter(({code}) => code === subfieldCode).length;\n}\n\nexport function getSubfieldValues(field, subfieldCode) {\n debugData(`Get subfield(s) $${subfieldCode} from ${JSON.stringify(field)}`);\n return field.subfields\n .filter(({code}) => code === subfieldCode)\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value);\n}\n\nexport function testStringOrNumber(value) {\n if (typeof value === 'string' || typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport function extractSubfieldsFromField(field, subfieldCodes) {\n if (field === undefined || field.subfields === undefined) {\n return [];\n }\n const resultSubfields = field.subfields\n .filter(({code}) => subfieldCodes.includes(code))\n .map(({code, value}) => ({code, value: testStringOrNumber(value) ? String(value) : ''}))\n .filter(value => value);\n return resultSubfields;\n}\n\nexport function uniqueSubfields(subfields) {\n return subfields.reduce((arr, e) => {\n if (!arr.find(item => item.code === e.code && item.value === e.value)) {\n const newArr = arr.concat(e);\n return newArr;\n }\n return arr;\n }, []);\n}\n\nexport function getMatchCounts(aValues, bValues) {\n\n const matchingValues = getMatchingValuesAmount(aValues, bValues);\n\n return {\n maxValues: aValues.length > bValues.length ? aValues.length : bValues.length,\n // possibleMatchingValues: amount of identifiers in set of less identifiers (we cannot more values than these)\n possibleMatchValues: aValues.length > bValues.length ? bValues.length : aValues.length,\n matchingValues\n };\n\n function getMatchingValuesAmount(aValues, bValues) {\n if (bValues.length > aValues.length) {\n return aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length;\n }\n if (aValues.length > bValues.length) {\n return bValues.filter(bValue => aValues.some(aValue => bValue === aValue)).length;\n }\n\n // If we have same amount of values, we'll check matches both ways, to avoid mixups in cases\n // there would be duplicate values\n const aToB = aValues.filter(aValue => bValues.some(bValue => aValue === bValue)).length;\n const bToA = bValues.filter(bValue => aValues.some(aValue => bValue === aValue)).length;\n\n return aToB < bToA ? aToB : bToA;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,uBAAuB;AAE9B,MAAM,QAAQ,kBAAkB,yCAAyC;AACzE,MAAM,YAAY,MAAM,OAAO,MAAM;AAE9B,gBAAS,kBAAkB,QAAQ;AAExC,QAAMA,SAAQ,kBAAkB,8CAA8C;AAC9E,QAAMC,aAAYD,OAAM,OAAO,MAAM;AAErC,QAAM,QAAQ,OAAO,UAAU,KAAK;AAEpC,MAAI,MAAM,SAAS,GAAG;AACpB,IAAAA,OAAM,iBAAiB;AACvB,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,oBAAoB,CAAC,EAAE,OAAO,GAAG,MAAM,IAAI,WAAS,aAAa,KAAK,CAAC,CAAC;AAC9E,QAAM,iBAAiB,CAAC,GAAG,IAAI,IAAI,iBAAiB,CAAC;AAErD,EAAAC,WAAU,WAAW,MAAM,MAAM,MAAM,KAAK,UAAU,KAAK,CAAC,EAAE;AAC9D,EAAAA,WAAU,QAAQ,kBAAkB,MAAM,MAAM,KAAK,UAAU,iBAAiB,CAAC,EAAE;AACnF,EAAAA,WAAU,eAAe,eAAe,MAAM,MAAM,KAAK,UAAU,cAAc,CAAC,EAAE;AAEpF,SAAO;AACT;AAEO,gBAAS,aAAa,EAAC,UAAS,GAAG,mBAAmB,CAAC,KAAK,GAAG,GAAG;AACvE,QAAM,kBAAkB;AAExB,SAAO,UACJ,OAAO,SAAO,iBAAiB,SAAS,IAAI,IAAI,CAAC,EACjD,OAAO,SAAO,mBAAmB,IAAI,KAAK,KAAK,gBAAgB,KAAK,OAAO,IAAI,KAAK,CAAC,CAAC,EACtF,IAAI,CAAC,EAAC,MAAK,MAAM,mBAAmB,KAAK,IAAI,OAAO,KAAK,EAAE,QAAQ,iBAAiB,OA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