@natlibfi/melinda-record-matching 3.0.1-alpha.1 → 3.0.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.
@@ -16,7 +16,7 @@ jobs:
16
16
 
17
17
  steps:
18
18
  - name: Checkout the code
19
- uses: actions/checkout@v2
19
+ uses: actions/checkout@v3
20
20
  - name: Use Node.js ${{ matrix.node-version }}
21
21
  uses: actions/setup-node@v3
22
22
  with:
@@ -58,7 +58,7 @@ jobs:
58
58
  if: contains(github.ref, 'refs/tags/')
59
59
 
60
60
  steps:
61
- - uses: actions/checkout@v2
61
+ - uses: actions/checkout@v3
62
62
  # Setup .npmrc file to publish to npm
63
63
  - uses: actions/setup-node@v3
64
64
  with:
@@ -75,11 +75,18 @@ Object.defineProperty(exports, "title", {
75
75
  return _title.default;
76
76
  }
77
77
  });
78
+ Object.defineProperty(exports, "titleVersionOriginal", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _titleVersionOriginal.default;
82
+ }
83
+ });
78
84
  var _hostComponent = _interopRequireDefault(require("./host-component"));
79
85
  var _isbn = _interopRequireDefault(require("./isbn"));
80
86
  var _issn = _interopRequireDefault(require("./issn"));
81
87
  var _otherStandardIdentifier = _interopRequireDefault(require("./other-standard-identifier"));
82
88
  var _title = _interopRequireDefault(require("./title"));
89
+ var _titleVersionOriginal = _interopRequireDefault(require("./title-version-original"));
83
90
  var _authors = _interopRequireDefault(require("./authors"));
84
91
  var _recordType = _interopRequireDefault(require("./record-type"));
85
92
  var _publicationTime = _interopRequireDefault(require("./publication-time"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAyD"}
1
+ {"version":3,"file":"index.js","names":[],"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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAyD"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _debug = _interopRequireDefault(require("debug"));
8
+ var _natural = require("natural");
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
+ var _default = ({
38
+ treshold = 10
39
+ } = {}) => ({
40
+ name: 'titleVersionOriginal',
41
+ extract: ({
42
+ record
43
+ }) => {
44
+ const title = getTitle();
45
+ if (title) {
46
+ return [title.replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase()];
47
+ }
48
+ return [];
49
+ function getTitle() {
50
+ const [field] = record.get(/^245$/u);
51
+ if (field) {
52
+ return field.subfields.filter(({
53
+ code
54
+ }) => ['a', 'b'].includes(code)).map(({
55
+ value
56
+ }) => value).join('');
57
+ }
58
+ }
59
+ },
60
+ compare: (a, b) => {
61
+ const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:match-detection:features/bib/title-version-original');
62
+ const distance = (0, _natural.LevenshteinDistance)(a[0], b[0]);
63
+ if (distance === 0) {
64
+ return 0.5;
65
+ }
66
+ const maxLength = getMaxLength();
67
+ const percentage = distance / maxLength * 100;
68
+ debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);
69
+ if (percentage <= treshold) {
70
+ return 0.3;
71
+ }
72
+ return -0.5;
73
+ function getMaxLength() {
74
+ return a[0].length > b[0].length ? a[0].length : b[0].length;
75
+ }
76
+ }
77
+ });
78
+ exports.default = _default;
79
+ //# sourceMappingURL=title-version-original.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title-version-original.js","names":["treshold","name","extract","record","title","getTitle","replace","toLowerCase","field","get","subfields","filter","code","includes","map","value","join","compare","a","b","debug","createDebugLogger","distance","leven","maxLength","getMaxLength","percentage","length"],"sources":["../../../../src/match-detection/features/bib/title-version-original.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 {LevenshteinDistance as leven} from 'natural';\n\nexport default ({treshold = 10} = {}) => ({\n name: 'titleVersionOriginal',\n extract: ({record}) => {\n const title = getTitle();\n\n if (title) {\n return [title.replace(/[^\\p{Letter}\\p{Number}]/gu, '').toLowerCase()];\n }\n\n return [];\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n return field.subfields\n .filter(({code}) => ['a', 'b'].includes(code))\n .map(({value}) => value)\n .join('');\n }\n }\n },\n compare: (a, b) => {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/title-version-original');\n const distance = leven(a[0], b[0]);\n\n if (distance === 0) {\n return 0.5;\n }\n\n const maxLength = getMaxLength();\n const percentage = distance / maxLength * 100;\n\n debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);\n\n if (percentage <= treshold) {\n return 0.3;\n }\n\n return -0.5;\n\n function getMaxLength() {\n return a[0].length > b[0].length ? a[0].length : b[0].length;\n }\n\n }\n});\n"],"mappings":";;;;;;AA4BA;AACA;AAAqD;AA7BrD;AACA;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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IA,UAAU,IAAI1B,QAAQ,EAAE;MAC1B,OAAO,GAAG;IACZ;IAEA,OAAO,CAAC,GAAG;IAEX,SAASyB,YAAY,GAAG;MACtB,OAAOP,CAAC,CAAC,CAAC,CAAC,CAACS,MAAM,GAAGR,CAAC,CAAC,CAAC,CAAC,CAACQ,MAAM,GAAGT,CAAC,CAAC,CAAC,CAAC,CAACS,MAAM,GAAGR,CAAC,CAAC,CAAC,CAAC,CAACQ,MAAM;IAC9D;EAEF;AACF,CAAC,CAAC;AAAA"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-record-matching-js.git"
15
15
  },
16
16
  "license": "LGPL-3.0+",
17
- "version": "3.0.1-alpha.1",
17
+ "version": "3.0.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=14"
@@ -31,6 +31,7 @@ export {default as isbn} from './isbn';
31
31
  export {default as issn} from './issn';
32
32
  export {default as otherStandardIdentifier} from './other-standard-identifier';
33
33
  export {default as title} from './title';
34
+ export {default as titleVersionOriginal} from './title-version-original';
34
35
  export {default as authors} from './authors';
35
36
  export {default as recordType} from './record-type';
36
37
  export {default as publicationTime} from './publication-time';
@@ -0,0 +1,78 @@
1
+ /**
2
+ *
3
+ * @licstart The following is the entire license notice for the JavaScript code in this file.
4
+ *
5
+ * Melinda record matching modules for Javascript
6
+ *
7
+ * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
8
+ *
9
+ * This file is part of melinda-record-matching-js
10
+ *
11
+ * melinda-record-matching-js program is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU Lesser General Public License as
13
+ * published by the Free Software Foundation, either version 3 of the
14
+ * License, or (at your option) any later version.
15
+ *
16
+ * melinda-record-matching-js is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Affero General Public License
22
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
+ *
24
+ * @licend The above is the entire license notice
25
+ * for the JavaScript code in this file.
26
+ *
27
+ */
28
+
29
+ import createDebugLogger from 'debug';
30
+ import {LevenshteinDistance as leven} from 'natural';
31
+
32
+ export default ({treshold = 10} = {}) => ({
33
+ name: 'titleVersionOriginal',
34
+ extract: ({record}) => {
35
+ const title = getTitle();
36
+
37
+ if (title) {
38
+ return [title.replace(/[^\p{Letter}\p{Number}]/gu, '').toLowerCase()];
39
+ }
40
+
41
+ return [];
42
+
43
+ function getTitle() {
44
+ const [field] = record.get(/^245$/u);
45
+
46
+ if (field) {
47
+ return field.subfields
48
+ .filter(({code}) => ['a', 'b'].includes(code))
49
+ .map(({value}) => value)
50
+ .join('');
51
+ }
52
+ }
53
+ },
54
+ compare: (a, b) => {
55
+ const debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib/title-version-original');
56
+ const distance = leven(a[0], b[0]);
57
+
58
+ if (distance === 0) {
59
+ return 0.5;
60
+ }
61
+
62
+ const maxLength = getMaxLength();
63
+ const percentage = distance / maxLength * 100;
64
+
65
+ debug(`'${a}' vs '${b}': Max length = ${maxLength}, distance = ${distance}, percentage = ${percentage}`);
66
+
67
+ if (percentage <= treshold) {
68
+ return 0.3;
69
+ }
70
+
71
+ return -0.5;
72
+
73
+ function getMaxLength() {
74
+ return a[0].length > b[0].length ? a[0].length : b[0].length;
75
+ }
76
+
77
+ }
78
+ });