@natlibfi/melinda-record-matching 4.3.2 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.github/workflows/melinda-node-tests.yml +2 -2
  2. package/LICENSE.txt +21 -165
  3. package/README.md +1 -1
  4. package/dist/candidate-search/candidate-search-utils.js +0 -28
  5. package/dist/candidate-search/candidate-search-utils.js.map +1 -1
  6. package/dist/candidate-search/choose-queries.js +1 -29
  7. package/dist/candidate-search/choose-queries.js.map +1 -1
  8. package/dist/candidate-search/index.js +1 -29
  9. package/dist/candidate-search/index.js.map +1 -1
  10. package/dist/candidate-search/index.spec.js +1 -29
  11. package/dist/candidate-search/index.spec.js.map +1 -1
  12. package/dist/candidate-search/query-list/bib.js +0 -28
  13. package/dist/candidate-search/query-list/bib.js.map +1 -1
  14. package/dist/candidate-search/query-list/bib.spec.js +1 -29
  15. package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
  16. package/dist/candidate-search/query-list/index.js +1 -29
  17. package/dist/candidate-search/query-list/index.js.map +1 -1
  18. package/dist/index.js +1 -28
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.spec.js +1 -29
  21. package/dist/index.spec.js.map +1 -1
  22. package/dist/match-detection/features/bib/all-source-ids.js +0 -28
  23. package/dist/match-detection/features/bib/all-source-ids.js.map +1 -1
  24. package/dist/match-detection/features/bib/authors.js +0 -27
  25. package/dist/match-detection/features/bib/authors.js.map +1 -1
  26. package/dist/match-detection/features/bib/bibliographic-level.js +0 -27
  27. package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -1
  28. package/dist/match-detection/features/bib/host-component.js +0 -27
  29. package/dist/match-detection/features/bib/host-component.js.map +1 -1
  30. package/dist/match-detection/features/bib/index.js.map +1 -1
  31. package/dist/match-detection/features/bib/index.spec.js +1 -29
  32. package/dist/match-detection/features/bib/index.spec.js.map +1 -1
  33. package/dist/match-detection/features/bib/isbn.js +0 -28
  34. package/dist/match-detection/features/bib/isbn.js.map +1 -1
  35. package/dist/match-detection/features/bib/issn.js +0 -27
  36. package/dist/match-detection/features/bib/issn.js.map +1 -1
  37. package/dist/match-detection/features/bib/language.js +0 -28
  38. package/dist/match-detection/features/bib/language.js.map +1 -1
  39. package/dist/match-detection/features/bib/media-type.js +0 -27
  40. package/dist/match-detection/features/bib/media-type.js.map +1 -1
  41. package/dist/match-detection/features/bib/melinda-id.js +0 -27
  42. package/dist/match-detection/features/bib/melinda-id.js.map +1 -1
  43. package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -27
  44. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +1 -1
  45. package/dist/match-detection/features/bib/other-standard-identifier.js +0 -27
  46. package/dist/match-detection/features/bib/other-standard-identifier.js.map +1 -1
  47. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -27
  48. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +1 -1
  49. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +0 -27
  50. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +1 -1
  51. package/dist/match-detection/features/bib/publication-time.js +0 -27
  52. package/dist/match-detection/features/bib/publication-time.js.map +1 -1
  53. package/dist/match-detection/features/bib/record-type.js +0 -27
  54. package/dist/match-detection/features/bib/record-type.js.map +1 -1
  55. package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -27
  56. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +1 -1
  57. package/dist/match-detection/features/bib/title-version-original.js +0 -27
  58. package/dist/match-detection/features/bib/title-version-original.js.map +1 -1
  59. package/dist/match-detection/features/bib/title.js +0 -28
  60. package/dist/match-detection/features/bib/title.js.map +1 -1
  61. package/dist/match-detection/features/index.js +1 -1
  62. package/dist/match-detection/features/index.js.map +1 -1
  63. package/dist/match-detection/index.js +1 -28
  64. package/dist/match-detection/index.js.map +1 -1
  65. package/dist/match-detection/index.spec.js +1 -29
  66. package/dist/match-detection/index.spec.js.map +1 -1
  67. package/dist/matching-utils.js +0 -28
  68. package/dist/matching-utils.js.map +1 -1
  69. package/package.json +18 -18
  70. package/src/candidate-search/candidate-search-utils.js +0 -28
  71. package/src/candidate-search/choose-queries.js +0 -28
  72. package/src/candidate-search/index.js +0 -28
  73. package/src/candidate-search/index.spec.js +0 -28
  74. package/src/candidate-search/query-list/bib.js +0 -28
  75. package/src/candidate-search/query-list/bib.spec.js +0 -28
  76. package/src/candidate-search/query-list/index.js +1 -27
  77. package/src/index.js +0 -28
  78. package/src/index.spec.js +0 -28
  79. package/src/match-detection/features/bib/all-source-ids.js +0 -27
  80. package/src/match-detection/features/bib/authors.js +1 -27
  81. package/src/match-detection/features/bib/bibliographic-level.js +0 -27
  82. package/src/match-detection/features/bib/host-component.js +0 -27
  83. package/src/match-detection/features/bib/index.js +0 -27
  84. package/src/match-detection/features/bib/index.spec.js +0 -27
  85. package/src/match-detection/features/bib/isbn.js +0 -27
  86. package/src/match-detection/features/bib/issn.js +0 -27
  87. package/src/match-detection/features/bib/language.js +0 -27
  88. package/src/match-detection/features/bib/media-type.js +1 -27
  89. package/src/match-detection/features/bib/melinda-id.js +0 -27
  90. package/src/match-detection/features/bib/melinda-identifier-factory.js +0 -27
  91. package/src/match-detection/features/bib/other-standard-identifier.js +0 -27
  92. package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +0 -27
  93. package/src/match-detection/features/bib/publication-time-allow-cons-years.js +0 -27
  94. package/src/match-detection/features/bib/publication-time.js +1 -27
  95. package/src/match-detection/features/bib/record-type.js +0 -27
  96. package/src/match-detection/features/bib/standard-identifier-factory.js +1 -27
  97. package/src/match-detection/features/bib/title-version-original.js +0 -27
  98. package/src/match-detection/features/bib/title.js +0 -29
  99. package/src/match-detection/features/index.js +0 -27
  100. package/src/match-detection/index.js +0 -27
  101. package/src/match-detection/index.spec.js +0 -27
  102. package/src/matching-utils.js +0 -28
@@ -7,36 +7,8 @@ var _marcRecord = require("@natlibfi/marc-record");
7
7
  var _ = _interopRequireWildcard(require("."));
8
8
  var _debug = _interopRequireDefault(require("debug"));
9
9
  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); }
10
- 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; }
10
+ 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 && {}.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; }
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- /**
13
- *
14
- * @licstart The following is the entire license notice for the JavaScript code in this file.
15
- *
16
- * Melinda record matching modules for Javascript
17
- *
18
- * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
19
- *
20
- * This file is part of melinda-record-matching-js
21
- *
22
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
23
- * it under the terms of the GNU Lesser General Public License as
24
- * published by the Free Software Foundation, either version 3 of the
25
- * License, or (at your option) any later version.
26
- *
27
- * melinda-record-matching-js is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU Lesser General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU Affero General Public License
33
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- *
35
- * @licend The above is the entire license notice
36
- * for the JavaScript code in this file.
37
- *
38
- */
39
-
40
12
  const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:index:test');
41
13
  const debugData = debug.extend('data');
42
14
  describe('INDEX', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.spec.js","names":["_chai","require","_fixura","_fixugenHttpClient","_interopRequireDefault","_marcRecord","_","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","expectedMatchStatus","expectedStopReason","expectedFailures","expectedCandidateCount","record","MarcRecord","subfieldValues","expectedMatches","expectedNonMatches","match","createMatchInterface","formatOptions","matches","matchStatus","nonMatches","conversionFailures","candidateCount","length","status","stopReason","expect","to","eql","formattedMatchResult","formatRecordResults","formattedNonMatchResult","contextFeatures","matchDetection","features","detection","strategy","type","search","detect","map","v","stringify","candidate","formatCandidate","id","newId","newRecord","toObject"],"sources":["../src/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2023 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 // eslint-disable-next-line max-statements\n async function callback({getFixture, options, expectedMatchStatus, expectedStopReason, expectedFailures, expectedCandidateCount}) {\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, candidateCount} = 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 expect(candidateCount).to.eql(expectedCandidateCount);\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-statements\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"],"mappings":";;AA4BA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,CAAA,GAAAC,uBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAAsC,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAA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;IACA,IAAIN,gBAAgB,EAAE;MACpB,IAAAkB,YAAM,EAACL,kBAAkB,CAAC,CAACM,EAAE,CAACC,GAAG,CAACpB,gBAAgB,CAAC;IACrD;IAEA,SAASS,aAAaA,CAAA,EAAG;MACvB,MAAMe,eAAe,GAAGC,gBAAc,CAACC,QAAQ,CAAC7B,OAAO,CAAC8B,SAAS,CAACC,QAAQ,CAACC,IAAI,CAAC;MAEhF,OAAO;QACL,GAAGhC,OAAO;QACViC,MAAM,EAAE;UACN,GAAGjC,OAAO,CAACiC;QACb,CAAC;QACDH,SAAS,EAAE;UACT,GAAG9B,OAAO,CAACkC,MAAM;UACjBH,QAAQ,EAAE/B,OAAO,CAAC8B,SAAS,CAACC,QAAQ,CAACF,QAAQ,CAACM,GAAG,CAACC,CAAC,IAAIT,eAAe,CAACS,CAAC,CAAC,CAAC,CAAC;QAC7E;MACF,CAAC;IACH;IAEA,SAASX,mBAAmBA,CAACZ,OAAO,EAAE;MACpC,IAAIA,OAAO,EAAE;QACX1B,SAAS,CAACW,IAAI,CAACuC,SAAS,CAACxB,OAAO,CAAC,CAAC;QAClC,OAAOA,OAAO,CAACsB,GAAG,CAAEzB,KAAK,KAAM;UAC7B,GAAGA,KAAK;UACR4B,SAAS,EAAEC,eAAe,CAAC7B,KAAK,CAAC4B,SAAS;QAC5C,CAAC,CAAC,CAAC;MACL;MACA,OAAO,EAAE;IACX;;IAEA;IACA,SAASC,eAAeA,CAAC;MAACC,EAAE;MAAEnC;IAAM,CAAC,EAAE;MACrC,MAAMoC,KAAK,GAAGD,EAAE;MAChB,MAAME,SAAS,GAAGrC,MAAM;MACxB,OAAO;QACLmC,EAAE,EAAEC,KAAK;QACTpC,MAAM,EAAEqC,SAAS,CAACC,QAAQ,CAAC;MAC7B,CAAC;IACH;EAGF;AAEF,CAAC,CAAC"}
1
+ {"version":3,"file":"index.spec.js","names":["_chai","require","_fixura","_fixugenHttpClient","_interopRequireDefault","_marcRecord","_","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","options","expectedMatchStatus","expectedStopReason","expectedFailures","expectedCandidateCount","record","MarcRecord","subfieldValues","expectedMatches","expectedNonMatches","match","createMatchInterface","formatOptions","matches","matchStatus","nonMatches","conversionFailures","candidateCount","length","status","stopReason","expect","to","eql","formattedMatchResult","formatRecordResults","formattedNonMatchResult","contextFeatures","matchDetection","features","detection","strategy","type","search","detect","map","v","stringify","candidate","formatCandidate","id","newId","newRecord","toObject"],"sources":["../src/index.spec.js"],"sourcesContent":["import {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 // eslint-disable-next-line max-statements\n async function callback({getFixture, options, expectedMatchStatus, expectedStopReason, expectedFailures, expectedCandidateCount}) {\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, candidateCount} = 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 expect(candidateCount).to.eql(expectedCandidateCount);\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-statements\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"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,CAAA,GAAAC,uBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAAsC,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yB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,CAAC;IACH;EAGF;AAEF,CAAC,CAAC","ignoreList":[]}
@@ -7,34 +7,6 @@ exports.default = void 0;
7
7
  var _debug = _interopRequireDefault(require("debug"));
8
8
  var _matchingUtils = require("../../../matching-utils");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
-
38
10
  const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:all-source-ids');
39
11
  const debugData = debug.extend('data');
40
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"all-source-ids.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","fSids","get","length","JSON","stringify","sidFeatures","getSidFeatures","map","toSidFeature","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidFeature","sfC","getSubfieldValues","sfB","compare","a","b","matches","sidA","some","sidB","sourceDb","sourceId","mismatches","exports"],"sources":["../../../../src/match-detection/features/bib/all-source-ids.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 {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, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n debug(`Creating match detection features for all local source id's for ${label}`);\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"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAA0F,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GA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CAAC,CAACG,IAAI,CAACC,IAAI,IAAIF,IAAI,CAACG,QAAQ,KAAKD,IAAI,CAACC,QAAQ,IAChFH,IAAI,CAACI,QAAQ,KAAKF,IAAI,CAACE,QAAQ,CAAC,CAAC;IACnCjC,SAAS,CAAE,eAAckC,UAAU,CAACxB,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACsB,UAAU,CAAE,EAAC,CAAC;;IAE7E;IACA,IAAIA,UAAU,CAACxB,MAAM,GAAG,CAAC,EAAE;MACzB,OAAO,CAAC,CAAC;IACX;;IAEA;IACA,IAAIkB,OAAO,CAAClB,MAAM,GAAG,CAAC,EAAE;MACtB,OAAO,CAAC;IACV;;IAEA;IACA,OAAO,CAAC;EAEV;AACF,CAAC,CAAC;AAAAyB,OAAA,CAAAtC,OAAA,GAAAK,QAAA"}
1
+ {"version":3,"file":"all-source-ids.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","fSids","get","length","JSON","stringify","sidFeatures","getSidFeatures","map","toSidFeature","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidFeature","sfC","getSubfieldValues","sfB","compare","a","b","matches","sidA","some","sidB","sourceDb","sourceId","mismatches","exports"],"sources":["../../../../src/match-detection/features/bib/all-source-ids.js"],"sourcesContent":["\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, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n debug(`Creating match detection features for all local source id's for ${label}`);\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"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAA0F,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1F,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,2EAA2E,CAAC;AAC5G,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAnBA,IAAAC,QAAA,GAqBeA,CAAA,MAAO;EACpBC,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEA,CAAC;IAACC,MAAM;IAAEC;EAAc,CAAC,KAAK;IACrC,MAAMC,KAAK,GAAGD,cAAc,IAAIA,cAAc,CAACC,KAAK,GAAGD,cAAc,CAACC,KAAK,GAAG,QAAQ;IACtFT,KAAK,CAAE,mEAAkES,KAAM,EAAC,CAAC;IAEjF,MAAMC,KAAK,GAAGH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;IAC/BT,SAAS,CAAE,eAAcQ,KAAK,CAACE,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAE,EAAC,CAAC;IAEnE,MAAMK,WAAW,GAAGC,cAAc,CAACN,KAAK,CAAC;IACzCR,SAAS,CAAE,iBAAgBa,WAAW,CAACH,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACC,WAAW,CAAE,EAAC,CAAC;IA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Q,IACvEH,IAAI,CAACI,QAAQ,KAAKF,IAAI,CAACE,QAAQ,CAAC,CAAC;IACzCjC,SAAS,CAAE,YAAW4B,OAAO,CAAClB,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACgB,OAAO,CAAE,EAAC,CAAC;IAEpE,MAAMM,UAAU,GAAGR,CAAC,CAACT,MAAM,CAACY,IAAI,IAAIF,CAAC,CAACG,IAAI,CAACC,IAAI,IAAIF,IAAI,CAACG,QAAQ,KAAKD,IAAI,CAACC,QAAQ,IAChFH,IAAI,CAACI,QAAQ,KAAKF,IAAI,CAACE,QAAQ,CAAC,CAAC;IACnCjC,SAAS,CAAE,eAAckC,UAAU,CAACxB,MAAO,MAAKC,IAAI,CAACC,SAAS,CAACsB,UAAU,CAAE,EAAC,CAAC;;IAE7E;IACA,IAAIA,UAAU,CAACxB,MAAM,GAAG,CAAC,EAAE;MACzB,OAAO,CAAC,CAAC;IACX;;IAEA;IACA,IAAIkB,OAAO,CAAClB,MAAM,GAAG,CAAC,EAAE;MACtB,OAAO,CAAC;IACV;;IAEA;IACA,OAAO,CAAC;EAEV;AACF,CAAC,CAAC;AAAAyB,OAAA,CAAAtC,OAAA,GAAAK,QAAA","ignoreList":[]}
@@ -6,33 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _natural = require("natural");
8
8
  var _matchingUtils = require("../../../matching-utils");
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Melinda record matching modules for Javascript
14
- *
15
- * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-record-matching-js
18
- *
19
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Lesser General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-record-matching-js is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Lesser General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Affero General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
9
  // We should extract also organisational authors (110/710)
37
10
  var _default = ({
38
11
  nameTreshold = 10
@@ -1 +1 @@
1
- {"version":3,"file":"authors.js","names":["_natural","require","_matchingUtils","_default","nameTreshold","name","extract","record","authors","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","testStringOrNumber","String","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","leven","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue","exports","default"],"sources":["../../../../src/match-detection/features/bib/authors.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 {LevenshteinDistance as leven} from 'natural';\nimport {testStringOrNumber} from '../../../matching-utils';\n\n// We should extract also organisational authors (110/710)\n\nexport default ({nameTreshold = 10} = {}) => ({\n name: 'Authors',\n extract: ({record}) => {\n //const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n const authors = 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: testStringOrNumber(value) ? String(value).replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase() : ''};\n }\n\n return {id: value};\n }\n });\n return authors;\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"],"mappings":";;;;;;AA4BA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AC,IAAIA,CAAC,CAACH,GAAG,CAAC,CAAC,CAACjC,GAAG,CAACoC,CAAC,IAAIA,CAAC,CAACH,GAAG,CAAC,CAAC;MACtD,MAAMI,OAAO,GAAGpB,CAAC,CAACf,MAAM,CAACkC,CAAC,IAAIA,CAAC,CAACH,GAAG,CAAC,CAAC,CAACjC,GAAG,CAACoC,CAAC,IAAIA,CAAC,CAACH,GAAG,CAAC,CAAC;MACtD,MAAMK,SAAS,GAAGH,OAAO,CAACI,MAAM,CAACF,OAAO,CAAC;MAEzC,OAAOC,SAAS,CAAC/B,MAAM,CAAC,CAACC,GAAG,EAAEJ,KAAK,KAAK;QACtC,MAAMoC,UAAU,GAAGF,SAAS,CAACpC,MAAM,CAACuC,UAAU,IAAIP,EAAE,CAAC9B,KAAK,EAAEqC,UAAU,CAAC,CAAC,CAACtB,MAAM;QAC/E,OAAOqB,UAAU,IAAI,CAAC,GAAGhC,GAAG,GAAG,CAAC,GAAGA,GAAG;MACxC,CAAC,EAAE,CAAC,CAAC;IACP;EACF;AACF,CAAC,CAAC;AAAAkC,OAAA,CAAAC,OAAA,GAAAlD,QAAA"}
1
+ {"version":3,"file":"authors.js","names":["_natural","require","_matchingUtils","_default","nameTreshold","name","extract","record","authors","get","map","subfields","filter","code","value","includes","toObj","reduce","acc","v","testStringOrNumber","String","replace","toLowerCase","id","compare","a","b","maxAuthors","length","matchingIds","findMatchingIds","matchingNames","findMatchingNames","idPoints","namePoints","totalPoints","findMatches","distance","leven","maxLength","getMaxLength","percentage","key","cb","valuesA","o","valuesB","allValues","concat","occurrance","otherValue","exports","default"],"sources":["../../../../src/match-detection/features/bib/authors.js"],"sourcesContent":["\n\nimport {LevenshteinDistance as leven} from 'natural';\nimport {testStringOrNumber} from '../../../matching-utils';\n\n// We should extract also organisational authors (110/710)\n\nexport default ({nameTreshold = 10} = {}) => ({\n name: 'Authors',\n extract: ({record}) => {\n //const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n const authors = 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: testStringOrNumber(value) ? String(value).replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase() : ''};\n }\n\n return {id: value};\n }\n });\n return authors;\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"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA;AAAA,IAAAE,QAAA,GAEeA,CAAC;EAACC,YAAY,GAAG;AAAE,CAAC,GAAG,CAAC,CAAC,MAAM;EAC5CC,IAAI,EAAE,SAAS;EACfC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,K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GAAG,CAACoC,CAAC,IAAIA,CAAC,CAACH,GAAG,CAAC,CAAC;MACtD,MAAMK,SAAS,GAAGH,OAAO,CAACI,MAAM,CAACF,OAAO,CAAC;MAEzC,OAAOC,SAAS,CAAC/B,MAAM,CAAC,CAACC,GAAG,EAAEJ,KAAK,KAAK;QACtC,MAAMoC,UAAU,GAAGF,SAAS,CAACpC,MAAM,CAACuC,UAAU,IAAIP,EAAE,CAAC9B,KAAK,EAAEqC,UAAU,CAAC,CAAC,CAACtB,MAAM;QAC/E,OAAOqB,UAAU,IAAI,CAAC,GAAGhC,GAAG,GAAG,CAAC,GAAGA,GAAG;MACxC,CAAC,EAAE,CAAC,CAAC;IACP;EACF;AACF,CAAC,CAAC;AAAAkC,OAAA,CAAAC,OAAA,GAAAlD,QAAA","ignoreList":[]}
@@ -4,33 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- *
9
- * @licstart The following is the entire license notice for the JavaScript code in this file.
10
- *
11
- * Melinda record matching modules for Javascript
12
- *
13
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
14
- *
15
- * This file is part of melinda-record-matching-js
16
- *
17
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
18
- * it under the terms of the GNU Lesser General Public License as
19
- * published by the Free Software Foundation, either version 3 of the
20
- * License, or (at your option) any later version.
21
- *
22
- * melinda-record-matching-js is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- * GNU Lesser General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU Affero General Public License
28
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- *
30
- * @licend The above is the entire license notice
31
- * for the JavaScript code in this file.
32
- *
33
- */
34
7
  var _default = () => ({
35
8
  name: 'Bibliographic level',
36
9
  extract: ({
@@ -1 +1 @@
1
- {"version":3,"file":"bibliographic-level.js","names":["_default","name","extract","record","leader","compare","a","b","exports","default"],"sources":["../../../../src/match-detection/features/bib/bibliographic-level.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\nexport default () => ({\n name: 'Bibliographic level',\n extract: ({record}) => record.leader[7] ? [record.leader[7]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2\n});\n"],"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;AA1BA,IAAAA,QAAA,GA4BeA,CAAA,MAAO;EACpBC,IAAI,EAAE,qBAAqB;EAC3BC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,KAAKA,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,GAAG,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;EACjEC,OAAO,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAT,QAAA"}
1
+ {"version":3,"file":"bibliographic-level.js","names":["_default","name","extract","record","leader","compare","a","b","exports","default"],"sources":["../../../../src/match-detection/features/bib/bibliographic-level.js"],"sourcesContent":["\nexport default () => ({\n name: 'Bibliographic level',\n extract: ({record}) => record.leader[7] ? [record.leader[7]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2\n});\n"],"mappings":";;;;;;eACeA,CAAA,MAAO;EACpBC,IAAI,EAAE,qBAAqB;EAC3BC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,KAAKA,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,GAAG,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;EACjEC,OAAO,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAT,QAAA","ignoreList":[]}
@@ -4,33 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- *
9
- * @licstart The following is the entire license notice for the JavaScript code in this file.
10
- *
11
- * Melinda record matching modules for Javascript
12
- *
13
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
14
- *
15
- * This file is part of melinda-record-matching-js
16
- *
17
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
18
- * it under the terms of the GNU Lesser General Public License as
19
- * published by the Free Software Foundation, either version 3 of the
20
- * License, or (at your option) any later version.
21
- *
22
- * melinda-record-matching-js is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- * GNU Lesser General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU Affero General Public License
28
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- *
30
- * @licend The above is the entire license notice
31
- * for the JavaScript code in this file.
32
- *
33
- */
34
7
  var _default = () => ({
35
8
  name: 'Host/Component record',
36
9
  extract: ({
@@ -1 +1 @@
1
- {"version":3,"file":"host-component.js","names":["_default","name","extract","record","get","length","compare","a","b","exports","default"],"sources":["../../../../src/match-detection/features/bib/host-component.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\nexport default () => ({\n name: 'Host/Component record',\n extract: ({record}) => record.get(/^773$/u).length > 0 ? ['component'] : ['host'],\n compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0\n});\n"],"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;AA1BA,IAAAA,QAAA,GA4BeA,CAAA,MAAO;EACpBC,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,KAAKA,MAAM,CAACC,GAAG,CAAC,QAAQ,CAAC,CAACC,MAAM,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;EACjFC,OAAO,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAV,QAAA"}
1
+ {"version":3,"file":"host-component.js","names":["_default","name","extract","record","get","length","compare","a","b","exports","default"],"sources":["../../../../src/match-detection/features/bib/host-component.js"],"sourcesContent":["\nexport default () => ({\n name: 'Host/Component record',\n extract: ({record}) => record.get(/^773$/u).length > 0 ? ['component'] : ['host'],\n compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0\n});\n"],"mappings":";;;;;;eACeA,CAAA,MAAO;EACpBC,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEA,CAAC;IAACC;EAAM,CAAC,KAAKA,MAAM,CAACC,GAAG,CAAC,QAAQ,CAAC,CAACC,MAAM,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;EACjFC,OAAO,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,KAAKC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAC5C,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAV,QAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_hostComponent","_interopRequireDefault","require","_isbn","_issn","_otherStandardIdentifier","_title","_titleVersionOriginal","_authors","_recordType","_publicationTime","_publicationTimeAllowConsYears","_publicationTimeAllowConsYearsMulti","_language","_bibliographicLevel","_melindaId","_allSourceIds","_mediaType","obj","__esModule","default"],"sources":["../../../../src/match-detection/features/bib/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\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 titleVersionOriginal} from './title-version-original';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as publicationTimeAllowConsYears} from './publication-time-allow-cons-years';\nexport {default as publicationTimeAllowConsYearsMulti} from './publication-time-allow-cons-years-multi';\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';\nexport {default as mediaType} from './media-type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,wBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,qBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,QAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,gBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,8BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,mCAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,SAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,mBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,UAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,aAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,UAAA,GAAAhB,sBAAA,CAAAC,OAAA;AAAkD,SAAAD,uBAAAiB,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
1
+ {"version":3,"file":"index.js","names":["_hostComponent","_interopRequireDefault","require","_isbn","_issn","_otherStandardIdentifier","_title","_titleVersionOriginal","_authors","_recordType","_publicationTime","_publicationTimeAllowConsYears","_publicationTimeAllowConsYearsMulti","_language","_bibliographicLevel","_melindaId","_allSourceIds","_mediaType","obj","__esModule","default"],"sources":["../../../../src/match-detection/features/bib/index.js"],"sourcesContent":["\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 titleVersionOriginal} from './title-version-original';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as publicationTimeAllowConsYears} from './publication-time-allow-cons-years';\nexport {default as publicationTimeAllowConsYearsMulti} from './publication-time-allow-cons-years-multi';\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';\nexport {default as mediaType} from './media-type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,wBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,qBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,QAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,gBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,8BAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,mCAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,SAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,mBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,UAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,aAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,UAAA,GAAAhB,sBAAA,CAAAC,OAAA;AAAkD,SAAAD,uBAAAiB,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA","ignoreList":[]}
@@ -7,36 +7,8 @@ var _marcRecord = require("@natlibfi/marc-record");
7
7
  var features = _interopRequireWildcard(require("."));
8
8
  var _debug = _interopRequireDefault(require("debug"));
9
9
  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); }
10
- 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; }
10
+ 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 && {}.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; }
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- /**
13
- *
14
- * @licstart The following is the entire license notice for the JavaScript code in this file.
15
- *
16
- * Melinda record matching modules for Javascript
17
- *
18
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
19
- *
20
- * This file is part of melinda-record-matching-js
21
- *
22
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
23
- * it under the terms of the GNU Lesser General Public License as
24
- * published by the Free Software Foundation, either version 3 of the
25
- * License, or (at your option) any later version.
26
- *
27
- * melinda-record-matching-js is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU Lesser General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU Affero General Public License
33
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- *
35
- * @licend The above is the entire license notice
36
- * for the JavaScript code in this file.
37
- *
38
- */
39
-
40
12
  const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib:test');
41
13
  const debugData = debug.extend('data');
42
14
  describe('match-detection/features/bib/', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","expect","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from '.';\nimport createDebugLogger from 'debug';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');\nconst debugData = debug.extend('data');\n\n\ndescribe('match-detection/features/bib/', () => {\n generateTests({\n path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n\n callback: ({enabled = true, feature, options, type, ...expectations}) => {\n\n if (!enabled) {\n return;\n }\n\n debug(`Testing: ${feature} ${type}`);\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n debugData(`Record: ${record}`);\n const {extract} = features[feature](options);\n\n expect(extract({record})).to.eql(expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n expect(compare(featuresA, featuresB)).to.equal(expectedPoints);\n return;\n }\n\n throw new Error(`Invalid type ${type}`);\n }\n });\n});\n"],"mappings":";;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAsC,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,C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,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","debug","createDebugLogger","debugData","extend","describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","expect","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"sourcesContent":["\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from '.';\nimport createDebugLogger from 'debug';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');\nconst debugData = debug.extend('data');\n\n\ndescribe('match-detection/features/bib/', () => {\n generateTests({\n path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n\n callback: ({enabled = true, feature, options, type, ...expectations}) => {\n\n if (!enabled) {\n return;\n }\n\n debug(`Testing: ${feature} ${type}`);\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n debugData(`Record: ${record}`);\n const {extract} = features[feature](options);\n\n expect(extract({record})).to.eql(expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n expect(compare(featuresA, featuresB)).to.equal(expectedPoints);\n return;\n }\n\n throw new Error(`Invalid type ${type}`);\n }\n });\n});\n"],"mappings":";;AACA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAA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;QACtB,MAAM;UAACW,SAAS;UAAEC,SAAS;UAAEC;QAAc,CAAC,GAAGZ,YAAY;QAC3D,MAAM;UAACa;QAAO,CAAC,GAAGvD,QAAQ,CAACuC,OAAO,CAAC,CAACC,OAAO,CAAC;QAE5C,IAAAS,YAAM,EAACM,OAAO,CAACH,SAAS,EAAEC,SAAS,CAAC,CAAC,CAACH,EAAE,CAACM,KAAK,CAACF,cAAc,CAAC;QAC9D;MACF;MAEA,MAAM,IAAIG,KAAK,CAAE,gBAAehB,IAAK,EAAC,CAAC;IACzC;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -8,34 +8,6 @@ var _standardIdentifierFactory = _interopRequireDefault(require("./standard-iden
8
8
  var _isbn = require("isbn3");
9
9
  var _debug = _interopRequireDefault(require("debug"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- /**
12
- *
13
- * @licstart The following is the entire license notice for the JavaScript code in this file.
14
- *
15
- * Melinda record matching modules for Javascript
16
- *
17
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
18
- *
19
- * This file is part of melinda-record-matching-js
20
- *
21
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
22
- * it under the terms of the GNU Lesser General Public License as
23
- * published by the Free Software Foundation, either version 3 of the
24
- * License, or (at your option) any later version.
25
- *
26
- * melinda-record-matching-js is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
- * GNU Lesser General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU Affero General Public License
32
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
- *
34
- * @licend The above is the entire license notice
35
- * for the JavaScript code in this file.
36
- *
37
- */
38
-
39
11
  const debug = (0, _debug.default)(`@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers:ISBN`);
40
12
  const debugData = debug.extend('data');
41
13
  var _default = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"isbn.js","names":["_standardIdentifierFactory","_interopRequireDefault","require","_isbn","_debug","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","IDENTIFIER_NAME","validatorAndNormalizer","string","isbnParseResult","isbnParse","JSON","stringify","valid","value","replace","isbn13","extract","compare","createInterface","identifier","pattern","subfieldCodes","validIdentifierSubfieldCodes","invalidIdentifierSubfieldCodes","name","exports"],"sources":["../../../../src/match-detection/features/bib/isbn.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 createInterface from './standard-identifier-factory';\nimport {parse as isbnParse} from 'isbn3';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger(`@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers:ISBN`);\nconst debugData = debug.extend('data');\n\nexport default () => {\n const IDENTIFIER_NAME = 'ISBN';\n\n function validatorAndNormalizer(string) {\n const isbnParseResult = isbnParse(string);\n debugData(`isbnParseResult: ${JSON.stringify(isbnParseResult)}`);\n if (isbnParseResult === null) {\n debug(`Not parseable ISBN, just removing hyphens`);\n return {valid: false, value: string.replace(/-/ug, '')};\n }\n debug(`Parseable ISBN, normalizing to ISBN-13`);\n return {valid: true, value: isbnParseResult.isbn13};\n }\n\n const {extract, compare} = createInterface({identifier: IDENTIFIER_NAME, pattern: /^020$/u, subfieldCodes: ['a', 'z'], validIdentifierSubfieldCodes: ['a'], invalidIdentifierSubfieldCodes: ['z'], validatorAndNormalizer});\n return {extract, compare, name: IDENTIFIER_NAME};\n};\n\n"],"mappings":";;;;;;AA4BA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA9BtC;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;;AAMA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAE,sFAAqF,CAAC;AACvH,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAAC,IAAAC,QAAA,GAExBA,CAAA,KAAM;EACnB,MAAMC,eAAe,GAAG,MAAM;EAE9B,SAASC,sBAAsBA,CAACC,MAAM,EAAE;IACtC,MAAMC,eAAe,GAAG,IAAAC,WAAS,EAACF,MAAM,CAAC;IACzCL,SAAS,CAAE,oBAAmBQ,IAAI,CAACC,SAAS,CAACH,eAAe,CAAE,EAAC,CAAC;IAChE,IAAIA,eAAe,KAAK,IAAI,EAAE;MAC5BR,KAAK,CAAE,2CAA0C,CAAC;MAClD,OAAO;QAACY,KAAK,EAAE,KAAK;QAAEC,KAAK,EAAEN,MAAM,CAACO,OAAO,CAAC,KAAK,EAAE,EAAE;MAAC,CAAC;IACzD;IACAd,KAAK,CAAE,wCAAuC,CAAC;IAC/C,OAAO;MAACY,KAAK,EAAE,IAAI;MAAEC,KAAK,EAAEL,eAAe,CAACO;IAAM,CAAC;EACrD;EAEA,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,kCAAe,EAAC;IAACC,UAAU,EAAEd,eAAe;IAAEe,OAAO,EAAE,QAAQ;IAAEC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IAAEC,4BAA4B,EAAE,CAAC,GAAG,CAAC;IAAEC,8BAA8B,EAAE,CAAC,GAAG,CAAC;IAAEjB;EAAsB,CAAC,CAAC;EAC3N,OAAO;IAACU,OAAO;IAAEC,OAAO;IAAEO,IAAI,EAAEnB;EAAe,CAAC;AAClD,CAAC;AAAAoB,OAAA,CAAA1B,OAAA,GAAAK,QAAA"}
1
+ {"version":3,"file":"isbn.js","names":["_standardIdentifierFactory","_interopRequireDefault","require","_isbn","_debug","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","IDENTIFIER_NAME","validatorAndNormalizer","string","isbnParseResult","isbnParse","JSON","stringify","valid","value","replace","isbn13","extract","compare","createInterface","identifier","pattern","subfieldCodes","validIdentifierSubfieldCodes","invalidIdentifierSubfieldCodes","name","exports"],"sources":["../../../../src/match-detection/features/bib/isbn.js"],"sourcesContent":["\nimport createInterface from './standard-identifier-factory';\nimport {parse as isbnParse} from 'isbn3';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger(`@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers:ISBN`);\nconst debugData = debug.extend('data');\n\nexport default () => {\n const IDENTIFIER_NAME = 'ISBN';\n\n function validatorAndNormalizer(string) {\n const isbnParseResult = isbnParse(string);\n debugData(`isbnParseResult: ${JSON.stringify(isbnParseResult)}`);\n if (isbnParseResult === null) {\n debug(`Not parseable ISBN, just removing hyphens`);\n return {valid: false, value: string.replace(/-/ug, '')};\n }\n debug(`Parseable ISBN, normalizing to ISBN-13`);\n return {valid: true, value: isbnParseResult.isbn13};\n }\n\n const {extract, compare} = createInterface({identifier: IDENTIFIER_NAME, pattern: /^020$/u, subfieldCodes: ['a', 'z'], validIdentifierSubfieldCodes: ['a'], invalidIdentifierSubfieldCodes: ['z'], validatorAndNormalizer});\n return {extract, compare, name: IDENTIFIER_NAME};\n};\n\n"],"mappings":";;;;;;AACA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEtC,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAE,sFAAqF,CAAC;AACvH,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAAC,IAAAC,QAAA,GAExBA,CAAA,KAAM;EACnB,MAAMC,eAAe,GAAG,MAAM;EAE9B,SAASC,sBAAsBA,CAACC,MAAM,EAAE;IACtC,MAAMC,eAAe,GAAG,IAAAC,WAAS,EAACF,MAAM,CAAC;IACzCL,SAAS,CAAE,oBAAmBQ,IAAI,CAACC,SAAS,CAACH,eAAe,CAAE,EAAC,CAAC;IAChE,IAAIA,eAAe,KAAK,IAAI,EAAE;MAC5BR,KAAK,CAAE,2CAA0C,CAAC;MAClD,OAAO;QAACY,KAAK,EAAE,KAAK;QAAEC,KAAK,EAAEN,MAAM,CAACO,OAAO,CAAC,KAAK,EAAE,EAAE;MAAC,CAAC;IACzD;IACAd,KAAK,CAAE,wCAAuC,CAAC;IAC/C,OAAO;MAACY,KAAK,EAAE,IAAI;MAAEC,KAAK,EAAEL,eAAe,CAACO;IAAM,CAAC;EACrD;EAEA,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,kCAAe,EAAC;IAACC,UAAU,EAAEd,eAAe;IAAEe,OAAO,EAAE,QAAQ;IAAEC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IAAEC,4BAA4B,EAAE,CAAC,GAAG,CAAC;IAAEC,8BAA8B,EAAE,CAAC,GAAG,CAAC;IAAEjB;EAAsB,CAAC,CAAC;EAC3N,OAAO;IAACU,OAAO;IAAEC,OAAO;IAAEO,IAAI,EAAEnB;EAAe,CAAC;AAClD,CAAC;AAAAoB,OAAA,CAAA1B,OAAA,GAAAK,QAAA","ignoreList":[]}
@@ -6,33 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Melinda record matching modules for Javascript
14
- *
15
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-record-matching-js
18
- *
19
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Lesser General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-record-matching-js is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Lesser General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Affero General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
9
  var _default = () => {
37
10
  const {
38
11
  extract,
@@ -1 +1 @@
1
- {"version":3,"file":"issn.js","names":["_standardIdentifierFactory","_interopRequireDefault","require","obj","__esModule","default","_default","extract","compare","createInterface","pattern","subfieldCodes","name","exports"],"sources":["../../../../src/match-detection/features/bib/issn.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 createInterface from './standard-identifier-factory';\n\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^022$/u, subfieldCodes: ['a', 'z', 'y']});\n return {extract, compare, name: 'ISSN'};\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA5B5D;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;AA1BA,IAAAG,QAAA,GA8BeA,CAAA,KAAM;EACnB,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,kCAAe,EAAC;IAACC,OAAO,EAAE,QAAQ;IAAEC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;EAAC,CAAC,CAAC;EAC/F,OAAO;IAACJ,OAAO;IAAEC,OAAO;IAAEI,IAAI,EAAE;EAAM,CAAC;AACzC,CAAC;AAAAC,OAAA,CAAAR,OAAA,GAAAC,QAAA"}
1
+ {"version":3,"file":"issn.js","names":["_standardIdentifierFactory","_interopRequireDefault","require","obj","__esModule","default","_default","extract","compare","createInterface","pattern","subfieldCodes","name","exports"],"sources":["../../../../src/match-detection/features/bib/issn.js"],"sourcesContent":["\nimport createInterface from './standard-identifier-factory';\n\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^022$/u, subfieldCodes: ['a', 'z', 'y']});\n return {extract, compare, name: 'ISSN'};\n};\n"],"mappings":";;;;;;AACA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE7CA,CAAA,KAAM;EACnB,MAAM;IAACC,OAAO;IAAEC;EAAO,CAAC,GAAG,IAAAC,kCAAe,EAAC;IAACC,OAAO,EAAE,QAAQ;IAAEC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;EAAC,CAAC,CAAC;EAC/F,OAAO;IAACJ,OAAO;IAAEC,OAAO;IAAEI,IAAI,EAAE;EAAM,CAAC;AACzC,CAAC;AAAAC,OAAA,CAAAR,OAAA,GAAAC,QAAA","ignoreList":[]}
@@ -7,34 +7,6 @@ exports.default = void 0;
7
7
  var _debug = _interopRequireDefault(require("debug"));
8
8
  var _matchingUtils = require("../../../matching-utils");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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-2023 University Of Helsinki (The National Library Of Finland)
17
- *
18
- * This file is part of melinda-record-matching-js
19
- *
20
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Lesser General Public License as
22
- * published by the Free Software Foundation, either version 3 of the
23
- * License, or (at your option) any later version.
24
- *
25
- * melinda-record-matching-js is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Lesser General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @licend The above is the entire license notice
34
- * for the JavaScript code in this file.
35
- *
36
- */
37
-
38
10
  const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:language');
39
11
  const debugData = debug.extend('data');
40
12
  var _default = () => ({
@@ -1 +1 @@
1
- {"version":3,"file":"language.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","value008","get008Value","values041","get041Values","JSON","stringify","length","allValues","undefined","concat","uniqueSortedValues","Set","sort","value","get","code","slice","isLangCodeForALanguage","filter","ind2","map","subfields","flat","langCodePattern","test","compare","a","b","every","element","index","matchingValues","possibleMatchValues","maxValues","getMatchCounts","missingCount","misMatchCount","penaltyForMissing","penaltyForMisMatch","points","Number","toFixed","exports"],"sources":["../../../../src/match-detection/features/bib/language.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-2023 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 {getMatchCounts} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:language');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Language',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (!value008 && values041.length < 1) {\n debugData(`{$label} No actual values found`);\n return [];\n }\n\n const allValues = value008 === undefined ? values041 : values041.concat(value008);\n const uniqueSortedValues = [...new Set(allValues)].sort();\n\n return uniqueSortedValues;\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`${label} 008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`${label} 008 code: ${code}`);\n return isLangCodeForALanguage(code) ? code : undefined;\n }\n\n // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes\n\n function get041Values() {\n return record.get(/^041$/u)\n .filter(({ind2}) => ind2 === ' ')\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'a' || code === 'd')\n .filter(({value}) => value && isLangCodeForALanguage(value))\n .map(({value}) => value);\n }\n\n // Check if a string is a possible, validly formed language code for a single language\n // Currently accept also codes in capitals\n function isLangCodeForALanguage(code) {\n if (code.length !== 3) {\n debugData(`Code ${code} is not correct length (3) for a language code.`);\n return false;\n }\n if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {\n debugData(`Code ${code} is not code for a spesific language.`);\n return false;\n }\n const langCodePattern = /^[a-z][a-z][a-z]$/ui;\n if (!langCodePattern.test(code)) {\n debugData(`Code ${code} is not valid as a language code`);\n return false;\n }\n return true;\n }\n\n },\n // eslint-disable-next-line max-statements\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n if (a.length === b.length && a.every((element, index) => element === b[index])) {\n debugData(`All languages match`);\n return 0.1;\n }\n\n const {matchingValues, possibleMatchValues, maxValues} = getMatchCounts(a, b);\n\n if (matchingValues < 1) {\n debug(`Both have languages, but none of these match.`);\n return -1.0;\n }\n debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);\n // ignore non-matches if there is mismatching amount of values\n debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);\n //we give some kind of penalty for mismatching amount of values instead of simple divide?\n const missingCount = maxValues - possibleMatchValues;\n const misMatchCount = possibleMatchValues - matchingValues;\n debug(`\\t missing: ${missingCount}`);\n debug(`\\t mismatches: ${misMatchCount}`);\n\n const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);\n const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);\n debug(`\\t points: penaltyForMissing: ${penaltyForMissing}`);\n debug(`\\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);\n\n const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));\n debug(`Total points: ${points}`);\n\n return points;\n }\n});\n"],"mappings":";;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAuD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7BvD;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,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,qEAAqE,CAAC;AACtG,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAAC,IAAAC,QAAA,GAExBA,CAAA,MAAO;EACpB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,MAAM,GAAGC,MAAM,CAACA,MAAM,CAAC,GAAG,GAAGF,kBAAkB,GAAGD,iBAAiB,CAAC,CAACI,OAAO,CAAC,CAAC,CAAC,CAAC;IACtFnD,KAAK,CAAE,iBAAgBiD,MAAO,EAAC,CAAC;IAEhC,OAAOA,MAAM;EACf;AACF,CAAC,CAAC;AAAAG,OAAA,CAAArD,OAAA,GAAAK,QAAA"}
1
+ {"version":3,"file":"language.js","names":["_debug","_interopRequireDefault","require","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","debugData","extend","_default","name","extract","record","recordExternal","label","value008","get008Value","values041","get041Values","JSON","stringify","length","allValues","undefined","concat","uniqueSortedValues","Set","sort","value","get","code","slice","isLangCodeForALanguage","filter","ind2","map","subfields","flat","langCodePattern","test","compare","a","b","every","element","index","matchingValues","possibleMatchValues","maxValues","getMatchCounts","missingCount","misMatchCount","penaltyForMissing","penaltyForMisMatch","points","Number","toFixed","exports"],"sources":["../../../../src/match-detection/features/bib/language.js"],"sourcesContent":["\nimport createDebugLogger from 'debug';\nimport {getMatchCounts} from '../../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features:language');\nconst debugData = debug.extend('data');\n\nexport default () => ({\n name: 'Language',\n extract: ({record, recordExternal}) => {\n const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';\n\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (!value008 && values041.length < 1) {\n debugData(`{$label} No actual values found`);\n return [];\n }\n\n const allValues = value008 === undefined ? values041 : values041.concat(value008);\n const uniqueSortedValues = [...new Set(allValues)].sort();\n\n return uniqueSortedValues;\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`${label} 008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`${label} 008 code: ${code}`);\n return isLangCodeForALanguage(code) ? code : undefined;\n }\n\n // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes\n\n function get041Values() {\n return record.get(/^041$/u)\n .filter(({ind2}) => ind2 === ' ')\n .map(({subfields}) => subfields)\n .flat()\n .filter(({code}) => code === 'a' || code === 'd')\n .filter(({value}) => value && isLangCodeForALanguage(value))\n .map(({value}) => value);\n }\n\n // Check if a string is a possible, validly formed language code for a single language\n // Currently accept also codes in capitals\n function isLangCodeForALanguage(code) {\n if (code.length !== 3) {\n debugData(`Code ${code} is not correct length (3) for a language code.`);\n return false;\n }\n if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {\n debugData(`Code ${code} is not code for a spesific language.`);\n return false;\n }\n const langCodePattern = /^[a-z][a-z][a-z]$/ui;\n if (!langCodePattern.test(code)) {\n debugData(`Code ${code} is not valid as a language code`);\n return false;\n }\n return true;\n }\n\n },\n // eslint-disable-next-line max-statements\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n if (a.length === b.length && a.every((element, index) => element === b[index])) {\n debugData(`All languages match`);\n return 0.1;\n }\n\n const {matchingValues, possibleMatchValues, maxValues} = getMatchCounts(a, b);\n\n if (matchingValues < 1) {\n debug(`Both have languages, but none of these match.`);\n return -1.0;\n }\n debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);\n // ignore non-matches if there is mismatching amount of values\n debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);\n //we give some kind of penalty for mismatching amount of values instead of simple divide?\n const missingCount = maxValues - possibleMatchValues;\n const misMatchCount = possibleMatchValues - matchingValues;\n debug(`\\t missing: ${missingCount}`);\n debug(`\\t mismatches: ${misMatchCount}`);\n\n const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);\n const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);\n debug(`\\t points: penaltyForMissing: ${penaltyForMissing}`);\n debug(`\\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);\n\n const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));\n debug(`Total points: ${points}`);\n\n return points;\n }\n});\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAAuD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,qEAAqE,CAAC;AACtG,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAAC,IAAAC,QAAA,GAExBA,CAAA,MAAO;EACpBC,IAAI,EAAE,UAAU;EAChBC,OAAO,EAAEA,CAAC;IAACC,MAAM;IAAEC;EAAc,CAAC,KAAK;IACrC,MAAMC,KAAK,GAAGD,cAAc,IAAIA,cAAc,CAACC,KAAK,GAAGD,cAAc,CAACC,KAAK,GAAG,QAAQ;IAEtF,MAAMC,QAAQ,GAAGC,WAAW,CAAC,CAAC;IAC9B,MAAMC,SAAS,GAAGC,YAAY,CAAC,CAAC;IAChCX,SAAS,CAAE,GAAEO,KAAM,SAAQK,IAAI,CAACC,SAAS,CAACL,QAAQ,CAAE,UAASI,IAAI,CAACC,SAAS,CAACH,SAAS,CAAE,EAAC,CAAC;IAEzF,IAAI,CAACF,QAAQ,IAAIE,SAAS,CAACI,MAAM,GAAG,CAAC,EAAE;MACrCd,SAAS,CAAE,iCAAgC,CAAC;MAC5C,OAAO,EAAE;IACX;IAEA,MAAMe,SAAS,GAAGP,QAAQ,KAAKQ,SAAS,GAAGN,SAAS,GAAGA,SAAS,CAACO,MAAM,CAACT,QAAQ,CAAC;IACjF,MAAMU,kBAAkB,GAAG,CAAC,GAAG,IAAIC,GAAG,CAACJ,SAAS,CAAC,CAAC,CAACK,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