@natlibfi/melinda-record-matching 2.2.0-alpha.2 → 2.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.
Files changed (68) hide show
  1. package/.github/CODEOWNERS +10 -0
  2. package/.github/dependabot.yml +40 -0
  3. package/.github/workflows/melinda-node-tests.yml +70 -0
  4. package/package.json +13 -13
  5. package/src/candidate-search/index.js +11 -8
  6. package/src/candidate-search/query-list/bib.js +2 -2
  7. package/src/index.js +70 -29
  8. package/src/match-detection/features/bib/authors.js +1 -1
  9. package/src/match-detection/features/bib/standard-identifier-factory.js +2 -1
  10. package/src/match-detection/index.js +29 -19
  11. package/src/match-detection/index.spec.js +17 -3
  12. package/src/matching-utils.js +1 -1
  13. package/dist/candidate-search/candidate-search-utils.js +0 -58
  14. package/dist/candidate-search/candidate-search-utils.js.map +0 -1
  15. package/dist/candidate-search/index.js +0 -273
  16. package/dist/candidate-search/index.js.map +0 -1
  17. package/dist/candidate-search/index.spec.js +0 -161
  18. package/dist/candidate-search/index.spec.js.map +0 -1
  19. package/dist/candidate-search/query-list/bib.js +0 -252
  20. package/dist/candidate-search/query-list/bib.js.map +0 -1
  21. package/dist/candidate-search/query-list/bib.spec.js +0 -72
  22. package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
  23. package/dist/candidate-search/query-list/index.js +0 -67
  24. package/dist/candidate-search/query-list/index.js.map +0 -1
  25. package/dist/index.js +0 -508
  26. package/dist/index.js.map +0 -1
  27. package/dist/index.spec.js +0 -133
  28. package/dist/index.spec.js.map +0 -1
  29. package/dist/match-detection/features/bib/all-source-ids.js +0 -122
  30. package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
  31. package/dist/match-detection/features/bib/authors.js +0 -117
  32. package/dist/match-detection/features/bib/authors.js.map +0 -1
  33. package/dist/match-detection/features/bib/bibliographic-level.js +0 -42
  34. package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
  35. package/dist/match-detection/features/bib/host-component.js +0 -42
  36. package/dist/match-detection/features/bib/host-component.js.map +0 -1
  37. package/dist/match-detection/features/bib/index.js +0 -104
  38. package/dist/match-detection/features/bib/index.js.map +0 -1
  39. package/dist/match-detection/features/bib/index.spec.js +0 -97
  40. package/dist/match-detection/features/bib/index.spec.js.map +0 -1
  41. package/dist/match-detection/features/bib/isbn.js +0 -55
  42. package/dist/match-detection/features/bib/isbn.js.map +0 -1
  43. package/dist/match-detection/features/bib/issn.js +0 -55
  44. package/dist/match-detection/features/bib/issn.js.map +0 -1
  45. package/dist/match-detection/features/bib/language.js +0 -113
  46. package/dist/match-detection/features/bib/language.js.map +0 -1
  47. package/dist/match-detection/features/bib/melinda-id.js +0 -52
  48. package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
  49. package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -100
  50. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
  51. package/dist/match-detection/features/bib/other-standard-identifier.js +0 -55
  52. package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
  53. package/dist/match-detection/features/bib/publication-time.js +0 -47
  54. package/dist/match-detection/features/bib/publication-time.js.map +0 -1
  55. package/dist/match-detection/features/bib/record-type.js +0 -42
  56. package/dist/match-detection/features/bib/record-type.js.map +0 -1
  57. package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -125
  58. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
  59. package/dist/match-detection/features/bib/title.js +0 -91
  60. package/dist/match-detection/features/bib/title.js.map +0 -1
  61. package/dist/match-detection/features/index.js +0 -15
  62. package/dist/match-detection/features/index.js.map +0 -1
  63. package/dist/match-detection/index.js +0 -178
  64. package/dist/match-detection/index.js.map +0 -1
  65. package/dist/match-detection/index.spec.js +0 -81
  66. package/dist/match-detection/index.spec.js.map +0 -1
  67. package/dist/matching-utils.js +0 -95
  68. package/dist/matching-utils.js.map +0 -1
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- var _chai = require("chai");
4
-
5
- var _fixura = require("@natlibfi/fixura");
6
-
7
- var _fixugenHttpClient = _interopRequireDefault(require("@natlibfi/fixugen-http-client"));
8
-
9
- var _marcRecord = require("@natlibfi/marc-record");
10
-
11
- var _ = _interopRequireWildcard(require("."));
12
-
13
- var _debug = _interopRequireDefault(require("debug"));
14
-
15
- 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); }
16
-
17
- 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; }
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- /**
22
- *
23
- * @licstart The following is the entire license notice for the JavaScript code in this file.
24
- *
25
- * Melinda record matching modules for Javascript
26
- *
27
- * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
28
- *
29
- * This file is part of melinda-record-matching-js
30
- *
31
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
32
- * it under the terms of the GNU Lesser General Public License as
33
- * published by the Free Software Foundation, either version 3 of the
34
- * License, or (at your option) any later version.
35
- *
36
- * melinda-record-matching-js is distributed in the hope that it will be useful,
37
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
- * GNU Lesser General Public License for more details.
40
- *
41
- * You should have received a copy of the GNU Affero General Public License
42
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
43
- *
44
- * @licend The above is the entire license notice
45
- * for the JavaScript code in this file.
46
- *
47
- */
48
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:index:test');
49
- const debugData = debug.extend('data');
50
- describe('INDEX', () => {
51
- (0, _fixugenHttpClient.default)({
52
- callback,
53
- path: [__dirname, '..', 'test-fixtures', 'index'],
54
- recurse: false,
55
- fixura: {
56
- reader: _fixura.READERS.JSON
57
- }
58
- });
59
-
60
- async function callback({
61
- getFixture,
62
- options,
63
- enabled = true,
64
- expectedMatchStatus,
65
- expectedStopReason,
66
- expectedFailures
67
- }) {
68
- if (!enabled) {
69
- debug(`Disabled test!`);
70
- return;
71
- }
72
-
73
- const record = new _marcRecord.MarcRecord(getFixture('inputRecord.json'), {
74
- subfieldValues: false
75
- });
76
- const expectedMatches = getFixture('expectedMatches.json');
77
- const expectedNonMatches = getFixture('expectedNonMatches.json') || [];
78
- const match = (0, _.default)(formatOptions());
79
- const {
80
- matches,
81
- matchStatus,
82
- nonMatches,
83
- conversionFailures
84
- } = await match(record);
85
- debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);
86
- (0, _chai.expect)(matchStatus.status).to.eql(expectedMatchStatus);
87
- (0, _chai.expect)(matchStatus.stopReason).to.eql(expectedStopReason);
88
- const formattedMatchResult = formatRecordResults(matches);
89
- (0, _chai.expect)(formattedMatchResult).to.eql(expectedMatches);
90
- const formattedNonMatchResult = formatRecordResults(nonMatches);
91
- (0, _chai.expect)(formattedNonMatchResult).to.eql(expectedNonMatches); // eslint-disable-next-line functional/no-conditional-statement
92
-
93
- if (expectedFailures) {
94
- (0, _chai.expect)(conversionFailures).to.eql(expectedFailures);
95
- }
96
-
97
- function formatOptions() {
98
- const contextFeatures = _.matchDetection.features[options.detection.strategy.type];
99
- return { ...options,
100
- search: { ...options.search
101
- },
102
- detection: { ...options.detect,
103
- strategy: options.detection.strategy.features.map(v => contextFeatures[v]())
104
- }
105
- };
106
- }
107
-
108
- function formatRecordResults(matches) {
109
- if (matches) {
110
- debugData(JSON.stringify(matches));
111
- return matches.map(match => ({ ...match,
112
- candidate: formatCandidate(match.candidate)
113
- }));
114
- }
115
-
116
- return [];
117
- } // Format candidate to remove validationOptions from record
118
-
119
-
120
- function formatCandidate({
121
- id,
122
- record
123
- }) {
124
- const newId = id;
125
- const newRecord = record;
126
- return {
127
- id: newId,
128
- record: newRecord.toObject()
129
- };
130
- }
131
- }
132
- });
133
- //# sourceMappingURL=index.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.spec.js"],"names":["debug","debugData","extend","describe","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","enabled","expectedMatchStatus","expectedStopReason","expectedFailures","record","MarcRecord","subfieldValues","expectedMatches","expectedNonMatches","match","formatOptions","matches","matchStatus","nonMatches","conversionFailures","length","status","stopReason","to","eql","formattedMatchResult","formatRecordResults","formattedNonMatchResult","contextFeatures","matchDetection","features","detection","strategy","type","search","detect","map","v","stringify","candidate","formatCandidate","id","newId","newRecord","toObject"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAjCA;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;AASA,MAAMA,KAAK,GAAG,oBAAkB,8CAAlB,CAAd;AACA,MAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;AAEAC,QAAQ,CAAC,OAAD,EAAU,MAAM;AACtB,kC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,aAAO,EAAP;AACD,KAtDuH,CAwDxH;;;AACA,aAASC,eAAT,CAAyB;AAACC,MAAAA,EAAD;AAAKhC,MAAAA;AAAL,KAAzB,EAAuC;AACrC,YAAMiC,KAAK,GAAGD,EAAd;AACA,YAAME,SAAS,GAAGlC,MAAlB;AACA,aAAO;AACLgC,QAAAA,EAAE,EAAEC,KADC;AAELjC,QAAAA,MAAM,EAAEkC,SAAS,CAACC,QAAV;AAFH,OAAP;AAID;AAGF;AAEF,CA/EO,CAAR","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 {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createMatchInterface, {matchDetection} from '.';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:index:test');\nconst debugData = debug.extend('data');\n\ndescribe('INDEX', () => {\n generateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'index'],\n recurse: false,\n fixura: {\n reader: READERS.JSON\n }\n });\n\n async function callback({getFixture, options, enabled = true, expectedMatchStatus, expectedStopReason, expectedFailures}) {\n\n if (!enabled) {\n debug(`Disabled test!`);\n return;\n }\n\n const record = new MarcRecord(getFixture('inputRecord.json'), {subfieldValues: false});\n const expectedMatches = getFixture('expectedMatches.json');\n const expectedNonMatches = getFixture('expectedNonMatches.json') || [];\n\n\n const match = createMatchInterface(formatOptions());\n const {matches, matchStatus, nonMatches, conversionFailures} = await match(record);\n debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);\n\n expect(matchStatus.status).to.eql(expectedMatchStatus);\n expect(matchStatus.stopReason).to.eql(expectedStopReason);\n\n const formattedMatchResult = formatRecordResults(matches);\n expect(formattedMatchResult).to.eql(expectedMatches);\n\n const formattedNonMatchResult = formatRecordResults(nonMatches);\n expect(formattedNonMatchResult).to.eql(expectedNonMatches);\n\n // eslint-disable-next-line functional/no-conditional-statement\n if (expectedFailures) {\n expect(conversionFailures).to.eql(expectedFailures);\n }\n\n function formatOptions() {\n const contextFeatures = matchDetection.features[options.detection.strategy.type];\n\n return {\n ...options,\n search: {\n ...options.search\n },\n detection: {\n ...options.detect,\n strategy: options.detection.strategy.features.map(v => contextFeatures[v]())\n }\n };\n }\n\n function formatRecordResults(matches) {\n if (matches) {\n debugData(JSON.stringify(matches));\n return matches.map((match) => ({\n ...match,\n candidate: formatCandidate(match.candidate)\n }));\n }\n return [];\n }\n\n // Format candidate to remove validationOptions from record\n function formatCandidate({id, record}) {\n const newId = id;\n const newRecord = record;\n return {\n id: newId,\n record: newRecord.toObject()\n };\n }\n\n\n }\n\n});\n"],"file":"index.spec.js"}
@@ -1,122 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("debug"));
9
-
10
- var _matchingUtils = require("../../../matching-utils");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /* eslint-disable max-statements */
15
-
16
- /**
17
- *
18
- * @licstart The following is the entire license notice for the JavaScript code in this file.
19
- *
20
- * Melinda record matching modules for Javascript
21
- *
22
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
23
- *
24
- * This file is part of melinda-record-matching-js
25
- *
26
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
27
- * it under the terms of the GNU Lesser General Public License as
28
- * published by the Free Software Foundation, either version 3 of the
29
- * License, or (at your option) any later version.
30
- *
31
- * melinda-record-matching-js is distributed in the hope that it will be useful,
32
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
- * GNU Lesser General Public License for more details.
35
- *
36
- * You should have received a copy of the GNU Affero General Public License
37
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
38
- *
39
- * @licend The above is the entire license notice
40
- * for the JavaScript code in this file.
41
- *
42
- */
43
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');
44
- const debugData = debug.extend('data');
45
- /*
46
-
47
- SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
48
-
49
- SID__ $c 123457 $b helka
50
- SID__ $c (ANDL100020)1077305 $b sata
51
- SID__ $c VER999999 $ FI-KV
52
-
53
- allSourceIds matching feature is formatted as [{sourceDb: "helka", sourceId: "123457"}, {sourceDb: "sata", sourceId: "(ANDL100020)1077305"}, {sourceDb: "FI-KV", sourceId: "VER999999"}]
54
- - no normalization / prefix deletions etc. in the feature
55
-
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
- Records with mismatching local ids for matching local db are a strong mismatch.
62
- Records with matching local ids for matching local db are a very good match.
63
-
64
- */
65
-
66
- var _default = () => ({
67
- name: 'All source IDs',
68
- extract: record => {
69
- debug(`Creating match detection features for all local source id's`);
70
- const fSids = record.get('SID');
71
- debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
72
- const sidFeatures = getSidFeatures(fSids);
73
- debugData(`SID-features (${sidFeatures.length}): ${JSON.stringify(sidFeatures)}`);
74
- return sidFeatures;
75
-
76
- function getSidFeatures(fSids) {
77
- debug(`Getting Sid strings from SID fields`); // Map SID fields to sidFeatures, filter out empty strings
78
-
79
- const sidFeatures = fSids.map(toSidFeature).filter(nonEmptySid => nonEmptySid);
80
- return sidFeatures;
81
-
82
- function toSidFeature(field) {
83
- debug(`Getting feature from a field`);
84
- return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidFeature(field) : '';
85
-
86
- function createSidFeature(field) {
87
- debug(`Creating feature from a field`);
88
- const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
89
- const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
90
- debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
91
- debugData(`sourceDb: ${sfB}, sourceId: ${sfC}`);
92
- return {
93
- 'sourceDb': sfB,
94
- 'sourceId': sfC
95
- };
96
- }
97
- }
98
- }
99
- },
100
- compare: (a, b) => {
101
- debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
102
- const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId === sidB.sourceId));
103
- debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);
104
- const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb && sidA.sourceId !== sidB.sourceId));
105
- debugData(`Mismatches (${mismatches.length}): ${JSON.stringify(mismatches)}`); // If there's at least one mismatching source ID from matching source db
106
-
107
- if (mismatches.length > 0) {
108
- return -1;
109
- } // If there's at least one matching source ID from matching source db
110
-
111
-
112
- if (matches.length > 0) {
113
- return 1;
114
- } // If there are no source IDs with matching sources
115
-
116
-
117
- return 0;
118
- }
119
- });
120
-
121
- exports.default = _default;
122
- //# sourceMappingURL=all-source-ids.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/all-source-ids.js"],"names":["debug","debugData","extend","name","extract","record","fSids","get","length","JSON","stringify","sidFeatures","getSidFeatures","map","toSidFeature","filter","nonEmptySid","field","createSidFeature","sfC","sfB","compare","a","b","matches","sidA","some","sidB","sourceDb","sourceId","mismatches"],"mappings":";;;;;;;AA6BA;;AACA;;;;AA9BA;;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;AACA;AAKA,MAAMA,KAAK,GAAG,oBAAkB,2EAAlB,CAAd;AACA,MAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,CAAa,MAAb,CAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;eAEe,OAAO;AACpBC,EAAAA,IAAI,EAAE,gBADc;AAEpBC,EAAAA,OAAO,EAAEC,MAAM,IAAI;AACjBL,IAAAA,KAAK,CAAE,6DAAF,CAAL;AAEA,UAAMM,KAAK,GAAGD,MAAM,CAACE,GAAP,CAAW,KAAX,CAAd;AACAN,IAAAA,SAAS,CAAE,eAAcK,KAAK,CAACE,MAAO,MAAKC,IAAI,CAACC,SAAL,CAAeJ,KAAf,CAAsB,EAAxD,CAAT;AAEA,UAAMK,WAAW,GAAGC,cAAc,CAACN,KAAD,CAAlC;AACAL,IAAAA,SAAS,CAAE,iBAAgBU,WAAW,CAACH,MAAO,MAAKC,IAAI,CAACC,SAAL,CAAeC,WAAf,CAA4B,EAAtE,CAAT;AAEA,WAAOA,WAAP;;AAEA,aAASC,cAAT,CAAwBN,KAAxB,EAA+B;AAC7BN,MAAAA,KAAK,CAAE,qCAAF,CAAL,CAD6B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IAAAA,SAAS,CAAE,YAAWuB,OAAO,CAAChB,MAAO,MAAKC,IAAI,CAACC,SAAL,CAAec,OAAf,CAAwB,EAAzD,CAAT;AAEA,UAAMM,UAAU,GAAGR,CAAC,CAACP,MAAF,CAASU,IAAI,IAAIF,CAAC,CAACG,IAAF,CAAOC,IAAI,IAAIF,IAAI,CAACG,QAAL,KAAkBD,IAAI,CAACC,QAAvB,IACjDH,IAAI,CAACI,QAAL,KAAkBF,IAAI,CAACE,QADW,CAAjB,CAAnB;AAEA5B,IAAAA,SAAS,CAAE,eAAc6B,UAAU,CAACtB,MAAO,MAAKC,IAAI,CAACC,SAAL,CAAeoB,UAAf,CAA2B,EAAlE,CAAT,CAViB,CAYjB;;AACA,QAAIA,UAAU,CAACtB,MAAX,GAAoB,CAAxB,EAA2B;AACzB,aAAO,CAAC,CAAR;AACD,KAfgB,CAiBjB;;;AACA,QAAIgB,OAAO,CAAChB,MAAR,GAAiB,CAArB,EAAwB;AACtB,aAAO,CAAP;AACD,KApBgB,CAsBjB;;;AACA,WAAO,CAAP;AAED;AAhEmB,CAAP,C","sourcesContent":["/* eslint-disable max-statements */\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 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 {validateSidFieldSubfieldCounts, getSubfieldValues} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');\nconst debugData = debug.extend('data');\n\n/*\n\nSID-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\nallSourceIds matching feature is formatted as [{sourceDb: \"helka\", sourceId: \"123457\"}, {sourceDb: \"sata\", sourceId: \"(ANDL100020)1077305\"}, {sourceDb: \"FI-KV\", sourceId: \"VER999999\"}]\n- no normalization / prefix deletions etc. in the feature\n\nNote: 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\nRecords with mismatching local ids for matching local db are a strong mismatch.\nRecords with matching local ids for matching local db are a very good match.\n\n*/\n\nexport default () => ({\n name: 'All source IDs',\n extract: record => {\n debug(`Creating match detection features for all local source id's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n const sidFeatures = getSidFeatures(fSids);\n debugData(`SID-features (${sidFeatures.length}): ${JSON.stringify(sidFeatures)}`);\n\n return sidFeatures;\n\n function getSidFeatures(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to sidFeatures, filter out empty strings\n const sidFeatures = fSids.map(toSidFeature).filter(nonEmptySid => nonEmptySid);\n return sidFeatures;\n\n function toSidFeature(field) {\n debug(`Getting feature from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidFeature(field) : '';\n\n function createSidFeature(field) {\n debug(`Creating feature from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n debugData(`sourceDb: ${sfB}, sourceId: ${sfC}`);\n return {'sourceDb': sfB, 'sourceId': sfC};\n }\n }\n\n }\n\n },\n compare: (a, b) => {\n\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n const matches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&\n sidA.sourceId === sidB.sourceId));\n debugData(`Matches (${matches.length}): ${JSON.stringify(matches)}`);\n\n const mismatches = a.filter(sidA => b.some(sidB => sidA.sourceDb === sidB.sourceDb &&\n sidA.sourceId !== sidB.sourceId));\n debugData(`Mismatches (${mismatches.length}): ${JSON.stringify(mismatches)}`);\n\n // If there's at least one mismatching source ID from matching source db\n if (mismatches.length > 0) {\n return -1;\n }\n\n // If there's at least one matching source ID from matching source db\n if (matches.length > 0) {\n return 1;\n }\n\n // If there are no source IDs with matching sources\n return 0;\n\n }\n});\n"],"file":"all-source-ids.js"}
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _natural = require("natural");
9
-
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 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
- var _default = ({
38
- nameTreshold = 10
39
- } = {}) => ({
40
- name: 'Authors',
41
- extract: record => record.get(/^(?<def>100|700)$/u).map(({
42
- subfields
43
- }) => {
44
- return subfields.filter(({
45
- code,
46
- value
47
- }) => code && value).filter(({
48
- code
49
- }) => ['a', '0'].includes(code)).map(toObj).reduce((acc, v) => ({ ...acc,
50
- ...v
51
- }), {});
52
-
53
- function toObj({
54
- code,
55
- value
56
- }) {
57
- if (code === 'a') {
58
- return {
59
- name: value.replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase()
60
- };
61
- }
62
-
63
- return {
64
- id: value
65
- };
66
- }
67
- }),
68
- compare: (a, b) => {
69
- const maxAuthors = a.length > b.length ? a.length : b.length;
70
- const matchingIds = findMatchingIds();
71
-
72
- if (maxAuthors >= 3 && matchingIds >= 3) {
73
- return 0.3;
74
- }
75
-
76
- const matchingNames = findMatchingNames();
77
- const idPoints = matchingIds / maxAuthors * 0.3;
78
- const namePoints = matchingNames / maxAuthors * 0.2;
79
- const totalPoints = idPoints + namePoints;
80
- return totalPoints <= 0.2 ? totalPoints : 0.2;
81
-
82
- function findMatchingIds() {
83
- return findMatches('id', (a, b) => a === b);
84
- }
85
-
86
- function findMatchingNames() {
87
- return findMatches('name', (a, b) => {
88
- const distance = (0, _natural.LevenshteinDistance)(a, b);
89
-
90
- if (distance === 0) {
91
- return true;
92
- }
93
-
94
- const maxLength = getMaxLength();
95
- const percentage = distance / maxLength * 100;
96
- return percentage <= nameTreshold;
97
-
98
- function getMaxLength() {
99
- return a.length > b.length ? a.length : b.length;
100
- }
101
- });
102
- }
103
-
104
- function findMatches(key, cb) {
105
- const valuesA = a.filter(o => o[key]).map(o => o[key]);
106
- const valuesB = b.filter(o => o[key]).map(o => o[key]);
107
- const allValues = valuesA.concat(valuesB);
108
- return allValues.reduce((acc, value) => {
109
- const occurrance = allValues.filter(otherValue => cb(value, otherValue)).length;
110
- return occurrance >= 2 ? acc + 1 : acc;
111
- }, 0);
112
- }
113
- }
114
- });
115
-
116
- exports.default = _default;
117
- //# sourceMappingURL=authors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/authors.js"],"names":["nameTreshold","name","extract","record","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue"],"mappings":";;;;;;;AA4BA;;AA5BA;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;eAIe,CAAC;AAACA,EAAAA,YAAY,GAAG;AAAhB,IAAsB,EAAvB,MAA+B;AAC5CC,EAAAA,IAAI,EAAE,SADsC;AAE5CC,EAAAA,OAAO,EAAEC,MAAM,IAAIA,MAAM,CAACC,GAAP,CAAW,oBAAX,EAChBC,GADgB,CACZ,CAAC;AAACC,IAAAA;AAAD,GAAD,KAAiB;AACpB,WAAOA,SAAS,CACbC,MADI,CACG,CAAC;AAACC,MAAAA,IAAD;AAAOC,MAAAA;AAAP,KAAD,KAAmBD,IAAI,IAAIC,KAD9B,EAEJF,MAFI,CAEG,CAAC;AAACC,MAAAA;AAAD,KAAD,KAAY,CAAC,GAAD,EAAM,GAAN,EAAWE,QAAX,CAAoBF,IAApB,CAFf,EAGJH,GAHI,CAGAM,KAHA,EAIJC,MAJI,CAIG,CAACC,GAAD,EAAMC,CAAN,MAAa,EAAC,GAAGD,GAAJ;AAAS,SAAGC;AAAZ,KAAb,CAJH,EAIiC,EAJjC,CAAP;;AAMA,aAASH,KAAT,CAAe;AAACH,MAAAA,IAAD;AAAOC,MAAAA;AAAP,KAAf,EAA8B;AAC5B,UAAID,IAAI,KAAK,GAAb,EAAkB;AAChB,eAAO;AAACP,UAA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AAIlC,YAArB;;AAEA,iBAASiC,YAAT,GAAwB;AACtB,iBAAOd,CAAC,CAACG,MAAF,GAAWF,CAAC,CAACE,MAAb,GAAsBH,CAAC,CAACG,MAAxB,GAAiCF,CAAC,CAACE,MAA1C;AACD;AACF,OAfiB,CAAlB;AAgBD;;AAED,aAASQ,WAAT,CAAqBK,GAArB,EAA0BC,EAA1B,EAA8B;AAC5B,YAAMC,OAAO,GAAGlB,CAAC,CAACZ,MAAF,CAAS+B,CAAC,IAAIA,CAAC,CAACH,GAAD,CAAf,EAAsB9B,GAAtB,CAA0BiC,CAAC,IAAIA,CAAC,CAACH,GAAD,CAAhC,CAAhB;AACA,YAAMI,OAAO,GAAGnB,CAAC,CAACb,MAAF,CAAS+B,CAAC,IAAIA,CAAC,CAACH,GAAD,CAAf,EAAsB9B,GAAtB,CAA0BiC,CAAC,IAAIA,CAAC,CAACH,GAAD,CAAhC,CAAhB;AACA,YAAMK,SAAS,GAAGH,OAAO,CAACI,MAAR,CAAeF,OAAf,CAAlB;AAEA,aAAOC,SAAS,CAAC5B,MAAV,CAAiB,CAACC,GAAD,EAAMJ,KAAN,KAAgB;AACtC,cAAMiC,UAAU,GAAGF,SAAS,CAACjC,MAAV,CAAiBoC,UAAU,IAAIP,EAAE,CAAC3B,KAAD,EAAQkC,UAAR,CAAjC,EAAsDrB,MAAzE;AACA,eAAOoB,UAAU,IAAI,CAAd,GAAkB7B,GAAG,GAAG,CAAxB,GAA4BA,GAAnC;AACD,OAHM,EAGJ,CAHI,CAAP;AAID;AACF;AAlE2C,CAA/B,C","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 {LevenshteinDistance as leven} from 'natural';\n\nexport default ({nameTreshold = 10} = {}) => ({\n name: 'Authors',\n extract: record => record.get(/^(?<def>100|700)$/u)\n .map(({subfields}) => {\n return subfields\n .filter(({code, value}) => code && value)\n .filter(({code}) => ['a', '0'].includes(code))\n .map(toObj)\n .reduce((acc, v) => ({...acc, ...v}), {});\n\n function toObj({code, value}) {\n if (code === 'a') {\n return {name: value.replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase()};\n }\n\n return {id: value};\n }\n }),\n compare: (a, b) => {\n const maxAuthors = a.length > b.length ? a.length : b.length;\n const matchingIds = findMatchingIds();\n\n if (maxAuthors >= 3 && matchingIds >= 3) {\n return 0.3;\n }\n\n const matchingNames = findMatchingNames();\n const idPoints = matchingIds / maxAuthors * 0.3;\n const namePoints = matchingNames / maxAuthors * 0.2;\n const totalPoints = idPoints + namePoints;\n\n return totalPoints <= 0.2 ? totalPoints : 0.2;\n\n function findMatchingIds() {\n return findMatches('id', (a, b) => a === b);\n }\n\n function findMatchingNames() {\n return findMatches('name', (a, b) => {\n const distance = leven(a, b);\n\n if (distance === 0) {\n return true;\n }\n\n const maxLength = getMaxLength();\n const percentage = distance / maxLength * 100;\n\n return percentage <= nameTreshold;\n\n function getMaxLength() {\n return a.length > b.length ? a.length : b.length;\n }\n });\n }\n\n function findMatches(key, cb) {\n const valuesA = a.filter(o => o[key]).map(o => o[key]);\n const valuesB = b.filter(o => o[key]).map(o => o[key]);\n const allValues = valuesA.concat(valuesB);\n\n return allValues.reduce((acc, value) => {\n const occurrance = allValues.filter(otherValue => cb(value, otherValue)).length;\n return occurrance >= 2 ? acc + 1 : acc;\n }, 0);\n }\n }\n});\n"],"file":"authors.js"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /**
9
- *
10
- * @licstart The following is the entire license notice for the JavaScript code in this file.
11
- *
12
- * Melinda record matching modules for Javascript
13
- *
14
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
15
- *
16
- * This file is part of melinda-record-matching-js
17
- *
18
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Lesser General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * melinda-record-matching-js is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Lesser General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Affero General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- * @licend The above is the entire license notice
32
- * for the JavaScript code in this file.
33
- *
34
- */
35
- var _default = () => ({
36
- name: 'Bibliographic level',
37
- extract: r => r.leader[7] ? [r.leader[7]] : [],
38
- compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2
39
- });
40
-
41
- exports.default = _default;
42
- //# sourceMappingURL=bibliographic-level.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/bibliographic-level.js"],"names":["name","extract","r","leader","compare","a","b"],"mappings":";;;;;;;AAAA;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;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,qBADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,MAAF,CAAS,CAAT,IAAc,CAACD,CAAC,CAACC,MAAF,CAAS,CAAT,CAAD,CAAd,GAA8B,EAFxB;AAGpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AAHtB,CAAP,C","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\nexport default () => ({\n name: 'Bibliographic level',\n extract: r => r.leader[7] ? [r.leader[7]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2\n});\n"],"file":"bibliographic-level.js"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /**
9
- *
10
- * @licstart The following is the entire license notice for the JavaScript code in this file.
11
- *
12
- * Melinda record matching modules for Javascript
13
- *
14
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
15
- *
16
- * This file is part of melinda-record-matching-js
17
- *
18
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Lesser General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * melinda-record-matching-js is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Lesser General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Affero General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- * @licend The above is the entire license notice
32
- * for the JavaScript code in this file.
33
- *
34
- */
35
- var _default = () => ({
36
- name: 'Host/Component record',
37
- extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],
38
- compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0
39
- });
40
-
41
- exports.default = _default;
42
- //# sourceMappingURL=host-component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/host-component.js"],"names":["name","extract","r","get","length","compare","a","b"],"mappings":";;;;;;;AAAA;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;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,uBADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,GAAF,CAAM,QAAN,EAAgBC,MAAhB,GAAyB,CAAzB,GAA6B,CAAC,WAAD,CAA7B,GAA6C,CAAC,MAAD,CAFvC;AAGpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AAHtB,CAAP,C","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\nexport default () => ({\n name: 'Host/Component record',\n extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],\n compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0\n});\n"],"file":"host-component.js"}
@@ -1,104 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "allSourceIds", {
7
- enumerable: true,
8
- get: function () {
9
- return _allSourceIds.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "authors", {
13
- enumerable: true,
14
- get: function () {
15
- return _authors.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "bibliographicLevel", {
19
- enumerable: true,
20
- get: function () {
21
- return _bibliographicLevel.default;
22
- }
23
- });
24
- Object.defineProperty(exports, "hostComponent", {
25
- enumerable: true,
26
- get: function () {
27
- return _hostComponent.default;
28
- }
29
- });
30
- Object.defineProperty(exports, "isbn", {
31
- enumerable: true,
32
- get: function () {
33
- return _isbn.default;
34
- }
35
- });
36
- Object.defineProperty(exports, "issn", {
37
- enumerable: true,
38
- get: function () {
39
- return _issn.default;
40
- }
41
- });
42
- Object.defineProperty(exports, "language", {
43
- enumerable: true,
44
- get: function () {
45
- return _language.default;
46
- }
47
- });
48
- Object.defineProperty(exports, "melindaId", {
49
- enumerable: true,
50
- get: function () {
51
- return _melindaId.default;
52
- }
53
- });
54
- Object.defineProperty(exports, "otherStandardIdentifier", {
55
- enumerable: true,
56
- get: function () {
57
- return _otherStandardIdentifier.default;
58
- }
59
- });
60
- Object.defineProperty(exports, "publicationTime", {
61
- enumerable: true,
62
- get: function () {
63
- return _publicationTime.default;
64
- }
65
- });
66
- Object.defineProperty(exports, "recordType", {
67
- enumerable: true,
68
- get: function () {
69
- return _recordType.default;
70
- }
71
- });
72
- Object.defineProperty(exports, "title", {
73
- enumerable: true,
74
- get: function () {
75
- return _title.default;
76
- }
77
- });
78
-
79
- var _hostComponent = _interopRequireDefault(require("./host-component"));
80
-
81
- var _isbn = _interopRequireDefault(require("./isbn"));
82
-
83
- var _issn = _interopRequireDefault(require("./issn"));
84
-
85
- var _otherStandardIdentifier = _interopRequireDefault(require("./other-standard-identifier"));
86
-
87
- var _title = _interopRequireDefault(require("./title"));
88
-
89
- var _authors = _interopRequireDefault(require("./authors"));
90
-
91
- var _recordType = _interopRequireDefault(require("./record-type"));
92
-
93
- var _publicationTime = _interopRequireDefault(require("./publication-time"));
94
-
95
- var _language = _interopRequireDefault(require("./language"));
96
-
97
- var _bibliographicLevel = _interopRequireDefault(require("./bibliographic-level"));
98
-
99
- var _melindaId = _interopRequireDefault(require("./melinda-id"));
100
-
101
- var _allSourceIds = _interopRequireDefault(require("./all-source-ids"));
102
-
103
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
104
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","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\nexport {default as hostComponent} from './host-component';\nexport {default as isbn} from './isbn';\nexport {default as issn} from './issn';\nexport {default as otherStandardIdentifier} from './other-standard-identifier';\nexport {default as title} from './title';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as language} from './language';\nexport {default as bibliographicLevel} from './bibliographic-level';\nexport {default as melindaId} from './melinda-id';\nexport {default as allSourceIds} from './all-source-ids';\n"],"file":"index.js"}