@natlibfi/melinda-record-matching 2.0.1-alpha.1 → 2.0.7-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/.github/CODEOWNERS +2 -0
  2. package/.github/dependabot.yml +40 -0
  3. package/.github/workflows/melinda-node-tests.yml +70 -0
  4. package/README.md +1 -1
  5. package/dist/candidate-search/candidate-search-utils.js +3 -6
  6. package/dist/candidate-search/candidate-search-utils.js.map +1 -1
  7. package/dist/candidate-search/index.js +115 -50
  8. package/dist/candidate-search/index.js.map +1 -1
  9. package/dist/candidate-search/index.spec.js +41 -48
  10. package/dist/candidate-search/index.spec.js.map +1 -1
  11. package/dist/candidate-search/query-list/bib.js +154 -64
  12. package/dist/candidate-search/query-list/bib.js.map +1 -1
  13. package/dist/candidate-search/query-list/bib.spec.js +1 -10
  14. package/dist/candidate-search/query-list/bib.spec.js.map +1 -1
  15. package/dist/candidate-search/query-list/index.js +4 -10
  16. package/dist/candidate-search/query-list/index.js.map +1 -1
  17. package/dist/index.js +498 -50
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.spec.js +60 -34
  20. package/dist/index.spec.js.map +1 -1
  21. package/dist/match-detection/features/bib/all-source-ids.js +16 -19
  22. package/dist/match-detection/features/bib/all-source-ids.js.map +1 -1
  23. package/dist/match-detection/features/bib/authors.js +31 -35
  24. package/dist/match-detection/features/bib/authors.js.map +1 -1
  25. package/dist/match-detection/features/bib/bibliographic-level.js +3 -3
  26. package/dist/match-detection/features/bib/bibliographic-level.js.map +1 -1
  27. package/dist/match-detection/features/bib/host-component.js +3 -3
  28. package/dist/match-detection/features/bib/host-component.js.map +1 -1
  29. package/dist/match-detection/features/bib/index.js +28 -13
  30. package/dist/match-detection/features/bib/index.js.map +1 -1
  31. package/dist/match-detection/features/bib/index.spec.js +9 -13
  32. package/dist/match-detection/features/bib/index.spec.js.map +1 -1
  33. package/dist/match-detection/features/bib/isbn.js +28 -6
  34. package/dist/match-detection/features/bib/isbn.js.map +1 -1
  35. package/dist/match-detection/features/bib/issn.js +0 -4
  36. package/dist/match-detection/features/bib/issn.js.map +1 -1
  37. package/dist/match-detection/features/bib/language.js +69 -41
  38. package/dist/match-detection/features/bib/language.js.map +1 -1
  39. package/dist/match-detection/features/bib/media-type.js +83 -0
  40. package/dist/match-detection/features/bib/media-type.js.map +1 -0
  41. package/dist/match-detection/features/bib/melinda-id.js +0 -4
  42. package/dist/match-detection/features/bib/melinda-id.js.map +1 -1
  43. package/dist/match-detection/features/bib/melinda-identifier-factory.js +6 -17
  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 +1 -4
  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 +256 -0
  48. package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +1 -0
  49. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +71 -0
  50. package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +1 -0
  51. package/dist/match-detection/features/bib/publication-time.js +9 -8
  52. package/dist/match-detection/features/bib/publication-time.js.map +1 -1
  53. package/dist/match-detection/features/bib/record-type.js +6 -3
  54. package/dist/match-detection/features/bib/record-type.js.map +1 -1
  55. package/dist/match-detection/features/bib/standard-identifier-factory.js +129 -39
  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 +79 -0
  58. package/dist/match-detection/features/bib/title-version-original.js.map +1 -0
  59. package/dist/match-detection/features/bib/title.js +29 -22
  60. package/dist/match-detection/features/bib/title.js.map +1 -1
  61. package/dist/match-detection/features/index.js +0 -4
  62. package/dist/match-detection/features/index.js.map +1 -1
  63. package/dist/match-detection/index.js +94 -47
  64. package/dist/match-detection/index.js.map +1 -1
  65. package/dist/match-detection/index.spec.js +25 -15
  66. package/dist/match-detection/index.spec.js.map +1 -1
  67. package/dist/matching-utils.js +63 -15
  68. package/dist/matching-utils.js.map +1 -1
  69. package/package.json +27 -24
  70. package/src/candidate-search/index.js +93 -31
  71. package/src/candidate-search/index.spec.js +27 -24
  72. package/src/candidate-search/query-list/bib.js +149 -22
  73. package/src/candidate-search/query-list/index.js +1 -1
  74. package/src/index.js +310 -38
  75. package/src/index.spec.js +49 -21
  76. package/src/match-detection/features/bib/all-source-ids.js +3 -3
  77. package/src/match-detection/features/bib/authors.js +23 -16
  78. package/src/match-detection/features/bib/bibliographic-level.js +1 -1
  79. package/src/match-detection/features/bib/host-component.js +1 -1
  80. package/src/match-detection/features/bib/index.js +4 -0
  81. package/src/match-detection/features/bib/index.spec.js +10 -2
  82. package/src/match-detection/features/bib/isbn.js +21 -2
  83. package/src/match-detection/features/bib/language.js +63 -22
  84. package/src/match-detection/features/bib/media-type.js +77 -0
  85. package/src/match-detection/features/bib/melinda-identifier-factory.js +2 -3
  86. package/src/match-detection/features/bib/other-standard-identifier.js +2 -0
  87. package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +268 -0
  88. package/src/match-detection/features/bib/publication-time-allow-cons-years.js +67 -0
  89. package/src/match-detection/features/bib/publication-time.js +9 -4
  90. package/src/match-detection/features/bib/record-type.js +5 -1
  91. package/src/match-detection/features/bib/standard-identifier-factory.js +107 -22
  92. package/src/match-detection/features/bib/title-version-original.js +78 -0
  93. package/src/match-detection/features/bib/title.js +27 -7
  94. package/src/match-detection/index.js +60 -22
  95. package/src/match-detection/index.spec.js +18 -4
  96. package/src/matching-utils.js +62 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/bibliographic-level.js"],"names":["name","extract","r","leader","compare","a","b"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,qBADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,MAAF,CAAS,CAAT,IAAc,CAACD,CAAC,CAACC,MAAF,CAAS,CAAT,CAAD,CAAd,GAA8B,EAFxB;AAGpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AAHtB,CAAP,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport default () => ({\n name: 'Bibliographic level',\n extract: r => r.leader[7] ? [r.leader[7]] : [],\n compare: (a, b) => a[0] === b[0] ? 0.1 : -0.2\n});\n"],"file":"bibliographic-level.js"}
1
+ {"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"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  *
10
9
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -34,9 +33,10 @@ exports.default = void 0;
34
33
  */
35
34
  var _default = () => ({
36
35
  name: 'Host/Component record',
37
- extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],
36
+ extract: ({
37
+ record
38
+ }) => record.get(/^773$/u).length > 0 ? ['component'] : ['host'],
38
39
  compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0
39
40
  });
40
-
41
41
  exports.default = _default;
42
42
  //# sourceMappingURL=host-component.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/host-component.js"],"names":["name","extract","r","get","length","compare","a","b"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAEe,OAAO;AACpBA,EAAAA,IAAI,EAAE,uBADc;AAEpBC,EAAAA,OAAO,EAAEC,CAAC,IAAIA,CAAC,CAACC,GAAF,CAAM,QAAN,EAAgBC,MAAhB,GAAyB,CAAzB,GAA6B,CAAC,WAAD,CAA7B,GAA6C,CAAC,MAAD,CAFvC;AAGpBC,EAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC,CAAD,CAAD,KAASC,CAAC,CAAC,CAAD,CAAV,GAAgB,GAAhB,GAAsB,CAAC;AAHtB,CAAP,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport default () => ({\n name: 'Host/Component record',\n extract: r => r.get(/^773$/u).length > 0 ? ['component'] : ['host'],\n compare: (a, b) => a[0] === b[0] ? 0.0 : -1.0\n});\n"],"file":"host-component.js"}
1
+ {"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"}
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "language", {
45
45
  return _language.default;
46
46
  }
47
47
  });
48
+ Object.defineProperty(exports, "mediaType", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _mediaType.default;
52
+ }
53
+ });
48
54
  Object.defineProperty(exports, "melindaId", {
49
55
  enumerable: true,
50
56
  get: function () {
@@ -63,6 +69,18 @@ Object.defineProperty(exports, "publicationTime", {
63
69
  return _publicationTime.default;
64
70
  }
65
71
  });
72
+ Object.defineProperty(exports, "publicationTimeAllowConsYears", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _publicationTimeAllowConsYears.default;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "publicationTimeAllowConsYearsMulti", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _publicationTimeAllowConsYearsMulti.default;
82
+ }
83
+ });
66
84
  Object.defineProperty(exports, "recordType", {
67
85
  enumerable: true,
68
86
  get: function () {
@@ -75,30 +93,27 @@ Object.defineProperty(exports, "title", {
75
93
  return _title.default;
76
94
  }
77
95
  });
78
-
96
+ Object.defineProperty(exports, "titleVersionOriginal", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _titleVersionOriginal.default;
100
+ }
101
+ });
79
102
  var _hostComponent = _interopRequireDefault(require("./host-component"));
80
-
81
103
  var _isbn = _interopRequireDefault(require("./isbn"));
82
-
83
104
  var _issn = _interopRequireDefault(require("./issn"));
84
-
85
105
  var _otherStandardIdentifier = _interopRequireDefault(require("./other-standard-identifier"));
86
-
87
106
  var _title = _interopRequireDefault(require("./title"));
88
-
107
+ var _titleVersionOriginal = _interopRequireDefault(require("./title-version-original"));
89
108
  var _authors = _interopRequireDefault(require("./authors"));
90
-
91
109
  var _recordType = _interopRequireDefault(require("./record-type"));
92
-
93
110
  var _publicationTime = _interopRequireDefault(require("./publication-time"));
94
-
111
+ var _publicationTimeAllowConsYears = _interopRequireDefault(require("./publication-time-allow-cons-years"));
112
+ var _publicationTimeAllowConsYearsMulti = _interopRequireDefault(require("./publication-time-allow-cons-years-multi"));
95
113
  var _language = _interopRequireDefault(require("./language"));
96
-
97
114
  var _bibliographicLevel = _interopRequireDefault(require("./bibliographic-level"));
98
-
99
115
  var _melindaId = _interopRequireDefault(require("./melinda-id"));
100
-
101
116
  var _allSourceIds = _interopRequireDefault(require("./all-source-ids"));
102
-
117
+ var _mediaType = _interopRequireDefault(require("./media-type"));
103
118
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
104
119
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport {default as hostComponent} from './host-component';\nexport {default as isbn} from './isbn';\nexport {default as issn} from './issn';\nexport {default as otherStandardIdentifier} from './other-standard-identifier';\nexport {default as title} from './title';\nexport {default as authors} from './authors';\nexport {default as recordType} from './record-type';\nexport {default as publicationTime} from './publication-time';\nexport {default as language} from './language';\nexport {default as bibliographicLevel} from './bibliographic-level';\nexport {default as melindaId} from './melinda-id';\nexport {default as allSourceIds} from './all-source-ids';\n"],"file":"index.js"}
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,21 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
4
-
5
4
  var _fixura = require("@natlibfi/fixura");
6
-
7
5
  var _chai = require("chai");
8
-
9
6
  var _marcRecord = require("@natlibfi/marc-record");
10
-
11
7
  var features = _interopRequireWildcard(require("."));
12
-
8
+ var _debug = _interopRequireDefault(require("debug"));
13
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
-
15
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
-
17
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
12
  /**
20
13
  *
21
14
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -43,6 +36,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
43
36
  * for the JavaScript code in this file.
44
37
  *
45
38
  */
39
+
40
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib:test');
41
+ const debugData = debug.extend('data');
46
42
  describe('match-detection/features/bib/', () => {
47
43
  (0, _fixugen.default)({
48
44
  path: [__dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],
@@ -50,7 +46,6 @@ describe('match-detection/features/bib/', () => {
50
46
  fixura: {
51
47
  reader: _fixura.READERS.JSON
52
48
  },
53
- // eslint-disable-next-line max-statements
54
49
  callback: ({
55
50
  enabled = true,
56
51
  feature,
@@ -61,7 +56,7 @@ describe('match-detection/features/bib/', () => {
61
56
  if (!enabled) {
62
57
  return;
63
58
  }
64
-
59
+ debug(`Testing: ${feature} ${type}`);
65
60
  if (type === 'extract') {
66
61
  const {
67
62
  expectedFeatures,
@@ -70,13 +65,15 @@ describe('match-detection/features/bib/', () => {
70
65
  const record = new _marcRecord.MarcRecord(inputRecord, {
71
66
  subfieldValues: false
72
67
  });
68
+ debugData(`Record: ${record}`);
73
69
  const {
74
70
  extract
75
71
  } = features[feature](options);
76
- (0, _chai.expect)(extract(record)).to.eql(expectedFeatures);
72
+ (0, _chai.expect)(extract({
73
+ record
74
+ })).to.eql(expectedFeatures);
77
75
  return;
78
76
  }
79
-
80
77
  if (type === 'compare') {
81
78
  const {
82
79
  featuresA,
@@ -89,7 +86,6 @@ describe('match-detection/features/bib/', () => {
89
86
  (0, _chai.expect)(compare(featuresA, featuresB)).to.equal(expectedPoints);
90
87
  return;
91
88
  }
92
-
93
89
  throw new Error(`Invalid type ${type}`);
94
90
  }
95
91
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/index.spec.js"],"names":["describe","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","enabled","feature","options","type","expectations","expectedFeatures","inputRecord","record","MarcRecord","subfieldValues","extract","features","to","eql","featuresA","featuresB","expectedPoints","compare","equal","Error"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA;AACA;AACA;AACA;AACA;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kBC,OAAlB,CAAlB;AAEA,0BAAOe,OAAO,CAACH,SAAD,EAAYC,SAAZ,CAAd,EAAsCH,EAAtC,CAAyCM,KAAzC,CAA+CF,cAA/C;AACA;AACD;;AAED,YAAM,IAAIG,KAAJ,CAAW,gBAAehB,IAAK,EAA/B,CAAN;AACD;AA/BW,GAAd;AAiCD,CAlCO,CAAR","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 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 '.';\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 // eslint-disable-next-line max-statements\n callback: ({enabled = true, feature, options, type, ...expectations}) => {\n\n if (!enabled) {\n return;\n }\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\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"],"file":"index.spec.js"}
1
+ {"version":3,"file":"index.spec.js","names":["_fixugen","_interopRequireDefault","require","_fixura","_chai","_marcRecord","features","_interopRequireWildcard","_debug","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","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,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KA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@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
9
-
8
+ var _isbn = require("isbn3");
9
+ var _debug = _interopRequireDefault(require("debug"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
11
  /**
13
12
  *
14
13
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -36,20 +35,43 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
36
35
  * for the JavaScript code in this file.
37
36
  *
38
37
  */
38
+
39
+ const debug = (0, _debug.default)(`@natlibfi/melinda-record-matching:match-detection:features:standard-identifiers:ISBN`);
40
+ const debugData = debug.extend('data');
39
41
  var _default = () => {
42
+ const IDENTIFIER_NAME = 'ISBN';
43
+ function validatorAndNormalizer(string) {
44
+ const isbnParseResult = (0, _isbn.parse)(string);
45
+ debugData(`isbnParseResult: ${JSON.stringify(isbnParseResult)}`);
46
+ if (isbnParseResult === null) {
47
+ debug(`Not parseable ISBN, just removing hyphens`);
48
+ return {
49
+ valid: false,
50
+ value: string.replace(/-/ug, '')
51
+ };
52
+ }
53
+ debug(`Parseable ISBN, normalizing to ISBN-13`);
54
+ return {
55
+ valid: true,
56
+ value: isbnParseResult.isbn13
57
+ };
58
+ }
40
59
  const {
41
60
  extract,
42
61
  compare
43
62
  } = (0, _standardIdentifierFactory.default)({
63
+ identifier: IDENTIFIER_NAME,
44
64
  pattern: /^020$/u,
45
- subfieldCodes: ['a', 'z']
65
+ subfieldCodes: ['a', 'z'],
66
+ validIdentifierSubfieldCodes: ['a'],
67
+ invalidIdentifierSubfieldCodes: ['z'],
68
+ validatorAndNormalizer
46
69
  });
47
70
  return {
48
71
  extract,
49
72
  compare,
50
- name: 'ISBN'
73
+ name: IDENTIFIER_NAME
51
74
  };
52
75
  };
53
-
54
76
  exports.default = _default;
55
77
  //# sourceMappingURL=isbn.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/isbn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAIe,MAAM;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAAgB;AAACC,IAAAA,OAAO,EAAE,QAAV;AAAoBC,IAAAA,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN;AAAnC,GAAhB,CAA3B;AACA,SAAO;AAACH,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBG,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createInterface from './standard-identifier-factory';\n\nexport default () => {\n const {extract, compare} = createInterface({pattern: /^020$/u, subfieldCodes: ['a', 'z']});\n return {extract, compare, name: 'ISBN'};\n};\n"],"file":"isbn.js"}
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"}
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _standardIdentifierFactory = _interopRequireDefault(require("./standard-identifier-factory"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  /**
13
10
  *
14
11
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -50,6 +47,5 @@ var _default = () => {
50
47
  name: 'ISSN'
51
48
  };
52
49
  };
53
-
54
50
  exports.default = _default;
55
51
  //# sourceMappingURL=issn.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/issn.js"],"names":["extract","compare","pattern","subfieldCodes","name"],"mappings":";;;;;;;AA4BA;;;;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAIe,MAAM;AACnB,QAAM;AAACA,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAqB,wCAAgB;AAACC,IAAAA,OAAO,EAAE,QAAV;AAAoBC,IAAAA,aAAa,EAAE,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX;AAAnC,GAAhB,CAA3B;AACA,SAAO;AAACH,IAAAA,OAAD;AAAUC,IAAAA,OAAV;AAAmBG,IAAAA,IAAI,EAAE;AAAzB,GAAP;AACD,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport 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"],"file":"issn.js"}
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"}
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _debug = _interopRequireDefault(require("debug"));
9
-
8
+ var _matchingUtils = require("../../../matching-utils");
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /* eslint-disable max-statements */
13
-
14
10
  /**
15
11
  *
16
12
  * @licstart The following is the entire license notice for the JavaScript code in this file.
17
13
  *
18
14
  * Melinda record matching modules for Javascript
19
15
  *
20
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
16
+ * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
21
17
  *
22
18
  * This file is part of melinda-record-matching-js
23
19
  *
@@ -38,46 +34,38 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
38
34
  * for the JavaScript code in this file.
39
35
  *
40
36
  */
37
+
41
38
  const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features:language');
42
39
  const debugData = debug.extend('data');
43
-
44
40
  var _default = () => ({
45
41
  name: 'Language',
46
- extract: record => {
42
+ extract: ({
43
+ record,
44
+ recordExternal
45
+ }) => {
46
+ const label = recordExternal && recordExternal.label ? recordExternal.label : 'record';
47
47
  const value008 = get008Value();
48
48
  const values041 = get041Values();
49
- debugData(`008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
50
-
51
- if (value008 && values041.length > 0) {
52
- debugData(`There's both 008 and 041, searching for value in both`);
53
- const correspondingValue = values041.find(v => v === value008);
54
- debugData(`Corresponding value: ${correspondingValue}`);
55
- return correspondingValue ? [correspondingValue] : [];
56
- }
57
-
49
+ debugData(`${label} 008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);
58
50
  if (!value008 && values041.length < 1) {
59
- debugData(`No actual values found`);
51
+ debugData(`{$label} No actual values found`);
60
52
  return [];
61
53
  }
62
-
63
- return value008 ? [value008] : [values041[0]];
64
-
54
+ const allValues = value008 === undefined ? values041 : values041.concat(value008);
55
+ const uniqueSortedValues = [...new Set(allValues)].sort();
56
+ return uniqueSortedValues;
65
57
  function get008Value() {
66
- var _record$get, _record$get$;
67
-
68
- const value = ((_record$get = record.get(/^008$/u)) === null || _record$get === void 0 ? void 0 : (_record$get$ = _record$get[0]) === null || _record$get$ === void 0 ? void 0 : _record$get$.value) || undefined;
69
- debugData(`008 value: ${value}`);
70
-
58
+ const value = record.get(/^008$/u)?.[0]?.value || undefined;
59
+ debugData(`${label} 008 value: ${value}`);
71
60
  if (!value) {
72
61
  return undefined;
73
62
  }
74
-
75
63
  const code = value.slice(35, 38);
76
- debugData(`008 code: ${code}`);
77
- return code === '|||' || code === ' ' || code === '^^^' ? undefined : code;
78
- } // Main language for the resource: in the first f041 $a or f041 $d
79
- // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes
64
+ debugData(`${label} 008 code: ${code}`);
65
+ return isLangCodeForALanguage(code) ? code : undefined;
66
+ }
80
67
 
68
+ // Uses only f041s that have 2nd ind ' ', which means that the codes used are MARC 21 language codes
81
69
 
82
70
  function get041Values() {
83
71
  return record.get(/^041$/u).filter(({
@@ -86,28 +74,68 @@ var _default = () => ({
86
74
  subfields
87
75
  }) => subfields).flat().filter(({
88
76
  code
89
- }) => code === 'a' || code === 'd').map(({
77
+ }) => code === 'a' || code === 'd').filter(({
78
+ value
79
+ }) => value && isLangCodeForALanguage(value)).map(({
90
80
  value
91
81
  }) => value);
92
82
  }
83
+
84
+ // Check if a string is a possible, validly formed language code for a single language
85
+ // Currently accept also codes in capitals
86
+ function isLangCodeForALanguage(code) {
87
+ if (code.length !== 3) {
88
+ debugData(`Code ${code} is not correct length (3) for a language code.`);
89
+ return false;
90
+ }
91
+ if (code === '|||' || code === ' ' || code === '^^^' || code === 'mul' || code === 'zxx') {
92
+ debugData(`Code ${code} is not code for a spesific language.`);
93
+ return false;
94
+ }
95
+ const langCodePattern = /^[a-z][a-z][a-z]$/ui;
96
+ if (!langCodePattern.test(code)) {
97
+ debugData(`Code ${code} is not valid as a language code`);
98
+ return false;
99
+ }
100
+ return true;
101
+ }
93
102
  },
103
+ // eslint-disable-next-line max-statements
94
104
  compare: (a, b) => {
95
- debugData(`Comparing ${JSON.stringify(a[0])} and ${JSON.stringify(b[0])}`);
96
-
105
+ debugData(`Comparing ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
97
106
  if (a.length === 0 || b.length === 0) {
98
107
  debugData(`No language to compare`);
99
108
  return 0;
100
109
  }
101
-
102
- debugData(`There area languages to compare`);
103
-
104
- if (a[0] === b[0]) {
110
+ if (a.length === b.length && a.every((element, index) => element === b[index])) {
111
+ debugData(`All languages match`);
105
112
  return 0.1;
106
113
  }
107
-
108
- return a[0] === 'und' || b[0] === 'und' ? 0.0 : -1.0;
114
+ const {
115
+ matchingValues,
116
+ possibleMatchValues,
117
+ maxValues
118
+ } = (0, _matchingUtils.getMatchCounts)(a, b);
119
+ if (matchingValues < 1) {
120
+ debug(`Both have languages, but none of these match.`);
121
+ return -1.0;
122
+ }
123
+ debug(`Both have languages, ${matchingValues}/${possibleMatchValues} valid languages match.`);
124
+ // ignore non-matches if there is mismatching amount of values
125
+ debug(`Possible matches: ${possibleMatchValues}/${maxValues}`);
126
+ //we give some kind of penalty for mismatching amount of values instead of simple divide?
127
+ const missingCount = maxValues - possibleMatchValues;
128
+ const misMatchCount = possibleMatchValues - matchingValues;
129
+ debug(`\t missing: ${missingCount}`);
130
+ debug(`\t mismatches: ${misMatchCount}`);
131
+ const penaltyForMissing = 0.02 * (maxValues - possibleMatchValues);
132
+ const penaltyForMisMatch = 0.05 * (possibleMatchValues - matchingValues);
133
+ debug(`\t points: penaltyForMissing: ${penaltyForMissing}`);
134
+ debug(`\t points: penaltyForMisMatch: ${penaltyForMisMatch}`);
135
+ const points = Number(Number(0.1 - penaltyForMisMatch - penaltyForMissing).toFixed(2));
136
+ debug(`Total points: ${points}`);
137
+ return points;
109
138
  }
110
139
  });
111
-
112
140
  exports.default = _default;
113
141
  //# sourceMappingURL=language.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/match-detection/features/bib/language.js"],"names":["debug","debugData","extend","name","extract","record","value008","get008Value","values041","get041Values","JSON","stringify","length","correspondingValue","find","v","value","get","undefined","code","slice","filter","ind2","map","subfields","flat","compare","a","b"],"mappings":";;;;;;;AA6BA;;;;AA7BA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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CAAC,CAAD,CAAD,KAAS,KAAT,IAAkBC,CAAC,CAAC,CAAD,CAAD,KAAS,KAA3B,GAAmC,GAAnC,GAAyC,CAAC,GAAjD;AACD;AA7DmB,CAAP,C","sourcesContent":["/* eslint-disable max-statements */\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createDebugLogger from 'debug';\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 => {\n const value008 = get008Value();\n const values041 = get041Values();\n debugData(`008: ${JSON.stringify(value008)}, 041: ${JSON.stringify(values041)}`);\n\n if (value008 && values041.length > 0) {\n debugData(`There's both 008 and 041, searching for value in both`);\n const correspondingValue = values041.find(v => v === value008);\n debugData(`Corresponding value: ${correspondingValue}`);\n return correspondingValue ? [correspondingValue] : [];\n }\n\n if (!value008 && values041.length < 1) {\n debugData(`No actual values found`);\n return [];\n }\n\n return value008 ? [value008] : [values041[0]];\n\n function get008Value() {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n debugData(`008 value: ${value}`);\n\n if (!value) {\n return undefined;\n }\n\n const code = value.slice(35, 38);\n debugData(`008 code: ${code}`);\n return code === '|||' || code === ' ' || code === '^^^' ? undefined : code;\n }\n\n // Main language for the resource: in the first f041 $a or f041 $d\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 .map(({value}) => value);\n }\n },\n compare: (a, b) => {\n debugData(`Comparing ${JSON.stringify(a[0])} and ${JSON.stringify(b[0])}`);\n\n if (a.length === 0 || b.length === 0) {\n debugData(`No language to compare`);\n return 0;\n }\n\n debugData(`There area languages to compare`);\n\n if (a[0] === b[0]) {\n return 0.1;\n }\n\n return a[0] === 'und' || b[0] === 'und' ? 0.0 : -1.0;\n }\n});\n"],"file":"language.js"}
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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