scv-esm 1.111.126 → 1.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/authors-v2.mjs +37 -21
- package/src/defines.mjs +4 -4
- package/src/sutta-ref.mjs +10 -5
package/package.json
CHANGED
package/src/authors-v2.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AUTHORSV2 from "./auto/authors-v2.mjs";
|
|
2
2
|
import { default as SuttaRef } from './sutta-ref.mjs';
|
|
3
|
-
import { DBG
|
|
3
|
+
import { DBG } from './defines.mjs';
|
|
4
4
|
|
|
5
5
|
import { default as suidMap } from './auto/suid-map.mjs';
|
|
6
6
|
|
|
@@ -10,9 +10,8 @@ export default class AuthorsV2 {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
static authorInfo(author, lang) {
|
|
13
|
-
const msg = "
|
|
14
|
-
const dbg = DBG.
|
|
15
|
-
const dbgv = DBG.VERBOSE && dbg;
|
|
13
|
+
const msg = "a72.authorInfo() ";
|
|
14
|
+
const dbg = DBG.A72_AUTHOR_INFO;
|
|
16
15
|
let keys = Object.keys(AUTHORSV2);
|
|
17
16
|
let authorInfo = keys.reduce((a,k)=>{
|
|
18
17
|
let info = AUTHORSV2[k];
|
|
@@ -20,13 +19,13 @@ export default class AuthorsV2 {
|
|
|
20
19
|
return a;
|
|
21
20
|
}
|
|
22
21
|
if (info.lang === lang || a==null) {
|
|
23
|
-
|
|
22
|
+
dbg>1 && console.log(msg, '[1]info', info.author);
|
|
24
23
|
return info;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
dbg>1 && console.log(msg, '[2]!lang', info.lang, info.author);
|
|
27
26
|
return a;
|
|
28
27
|
}, undefined);
|
|
29
|
-
|
|
28
|
+
dbg>1 && console.log(msg, '[3]info', author, authorInfo);
|
|
30
29
|
return authorInfo;
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -75,8 +74,8 @@ export default class AuthorsV2 {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
static langAuthor(lang, opts={}) {
|
|
78
|
-
const msg = "
|
|
79
|
-
const dbg = DBG.
|
|
77
|
+
const msg = "a72.langAuthor()";
|
|
78
|
+
const dbg = DBG.A72_LANG_AUTHOR;
|
|
80
79
|
let {
|
|
81
80
|
category='sutta',
|
|
82
81
|
} = opts;
|
|
@@ -99,8 +98,22 @@ export default class AuthorsV2 {
|
|
|
99
98
|
dbg && console.log(msg, '[1]lang', info.name);
|
|
100
99
|
return info;
|
|
101
100
|
}
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
|
|
102
|
+
// compare by number of MN suttas translated
|
|
103
|
+
let sutta_mn1 = info?.stats?.['sutta/mn'] || 0;
|
|
104
|
+
let sutta_mn2 = a?.stats?.['sutta/mn'] || 0;
|
|
105
|
+
let cmp = sutta_mn1 - sutta_mn2;
|
|
106
|
+
|
|
107
|
+
if (cmp === 0) { // compare by number of suttas translated
|
|
108
|
+
let sutta1 = info?.stats?.sutta || 0;
|
|
109
|
+
let sutta2 = a?.stats?.sutta || 0;
|
|
110
|
+
cmp = sutta1 - sutta2;
|
|
111
|
+
}
|
|
112
|
+
dbg && console.log(msg, '[2]stats', {sutta1, sutta2, cmp});
|
|
113
|
+
if (cmp === 0) { // compare by author name
|
|
114
|
+
cmp = AuthorsV2.compare(info.author, a && a.author);
|
|
115
|
+
dbg && console.log(msg, '[3]author', info.name, cmp);
|
|
116
|
+
}
|
|
104
117
|
if (cmp === 0) {
|
|
105
118
|
return a;
|
|
106
119
|
}
|
|
@@ -114,9 +127,8 @@ export default class AuthorsV2 {
|
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
static compareInfo(info1, info2) {
|
|
117
|
-
const msg = "
|
|
118
|
-
const dbg = DBG.
|
|
119
|
-
const dbgv = DBG.VERBOSE && dbg;
|
|
130
|
+
const msg = "a72.compareInfo()";
|
|
131
|
+
const dbg = DBG.A72_COMPARE_INFO;
|
|
120
132
|
if (info1 === info2) {
|
|
121
133
|
return 0;
|
|
122
134
|
}
|
|
@@ -135,10 +147,10 @@ export default class AuthorsV2 {
|
|
|
135
147
|
let deepl2 = info2.author.startsWith('ebt-deepl') ? 1 : 2;
|
|
136
148
|
let cmp = deepl1 - deepl2;
|
|
137
149
|
//if (info1.author.startsWith('ebt-deepl')) {
|
|
138
|
-
//
|
|
150
|
+
//dbg>1 && console.log(msg, '[1]info1', info1.name);
|
|
139
151
|
//cmp = -1;
|
|
140
152
|
//} else if (info2.author.startsWith('ebt-deepl')) {
|
|
141
|
-
//
|
|
153
|
+
//dbg>1 && console.log(msg, '[2]info2', info2.name);
|
|
142
154
|
//cmp = 1;
|
|
143
155
|
//}
|
|
144
156
|
}
|
|
@@ -149,8 +161,8 @@ export default class AuthorsV2 {
|
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
static compare(author1, author2) {
|
|
152
|
-
const msg = "
|
|
153
|
-
const dbg =
|
|
164
|
+
const msg = "a72.compare() ";
|
|
165
|
+
const dbg = DBG.A72_COMPARE;
|
|
154
166
|
author1 = !!author1 ? author1 : '';
|
|
155
167
|
author2 = !!author2 ? author2 : '';
|
|
156
168
|
let noauthor = {author:'no-author'};
|
|
@@ -193,7 +205,7 @@ export default class AuthorsV2 {
|
|
|
193
205
|
let sutta1 = info1.sutta ? 1 : 0;
|
|
194
206
|
let sutta2 = info2.sutta ? 1 : 0;
|
|
195
207
|
cmp = sutta1 - sutta2;
|
|
196
|
-
dbg && console.log(msg, '[7]sutta', cmp);
|
|
208
|
+
dbg && console.log(msg, '[7]sutta', cmp, info1.sutta, info2.sutta);
|
|
197
209
|
}
|
|
198
210
|
if (!cmp) {
|
|
199
211
|
let vinaya1 = info1.vinaya ? 1 : 0;
|
|
@@ -206,8 +218,8 @@ export default class AuthorsV2 {
|
|
|
206
218
|
}
|
|
207
219
|
|
|
208
220
|
static suttaAuthor(suttaRef) {
|
|
209
|
-
const msg = '
|
|
210
|
-
const dbg = DBG.
|
|
221
|
+
const msg = 'a72.suttaAuthor()';
|
|
222
|
+
const dbg = DBG.A72_SUTTA_AUTHOR;
|
|
211
223
|
let {
|
|
212
224
|
sutta_uid, lang, author
|
|
213
225
|
} = SuttaRef.create(suttaRef);
|
|
@@ -223,6 +235,10 @@ export default class AuthorsV2 {
|
|
|
223
235
|
let bpv = bPaths[bpk] || '';
|
|
224
236
|
let [ ignore, bpLang, bpAuthor ] = bpk.split('/');
|
|
225
237
|
let info = AuthorsV2.authorInfo(bpAuthor, bpLang);
|
|
238
|
+
if (info == null) { // aligned legacy (fr/wijayaratna)
|
|
239
|
+
dbg && console.log(msg, {bpAuthor, bpLang});
|
|
240
|
+
return a;
|
|
241
|
+
}
|
|
226
242
|
let { stats } = info;
|
|
227
243
|
let bpvParts = bpv && bpv.split('/');
|
|
228
244
|
let statsScore = stats
|
package/src/defines.mjs
CHANGED
package/src/sutta-ref.mjs
CHANGED
|
@@ -24,8 +24,8 @@ export default class SuttaRef {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
static createFromString(str='', defaultLang="pli", suids=SUIDS) {
|
|
27
|
-
const msg = '
|
|
28
|
-
const dbg = DBG.
|
|
27
|
+
const msg = 's6f.createFromString()';
|
|
28
|
+
const dbg = DBG.S6F_CREATE_FROM_STRING;
|
|
29
29
|
let refLower = str.toLowerCase();
|
|
30
30
|
let segMatch = refLower.match(/:[-0-9.]*/);
|
|
31
31
|
let segnum;
|
|
@@ -114,7 +114,7 @@ export default class SuttaRef {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
static createFromObject(obj, defaultLang="pli", suids=SUIDS) {
|
|
117
|
-
const msg = "
|
|
117
|
+
const msg = "s6f.createFromObject() ";
|
|
118
118
|
let parsed = SuttaRef.createFromString(
|
|
119
119
|
obj.sutta_uid,
|
|
120
120
|
obj.lang || defaultLang
|
|
@@ -145,18 +145,21 @@ export default class SuttaRef {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
static create(strOrObj, defaultLang="pli", suids=SUIDS) {
|
|
148
|
+
const msg = 's6f.create:';
|
|
148
149
|
try {
|
|
149
150
|
return SuttaRef.createWithError(strOrObj, defaultLang, suids);
|
|
150
151
|
} catch(e) {
|
|
151
152
|
let args = JSON.stringify(strOrObj);
|
|
152
|
-
let
|
|
153
|
-
logger.warn(
|
|
153
|
+
let emsg = `${msg} ${args} => ${e.message}`;
|
|
154
|
+
logger.warn(emsg);
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
return null;
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
static createOpts(strOrObj, opts={}) {
|
|
161
|
+
const msg = 's6f.createOpts:';
|
|
162
|
+
const dbg = DBG.S6F_CREATE_OPTS;
|
|
160
163
|
let {
|
|
161
164
|
defaultLang = 'pli',
|
|
162
165
|
suids = SUIDS,
|
|
@@ -167,6 +170,7 @@ export default class SuttaRef {
|
|
|
167
170
|
return undefined;
|
|
168
171
|
}
|
|
169
172
|
|
|
173
|
+
dbg && console.log(msg, '[1]', {strOrObj, defaultLang, normalize});
|
|
170
174
|
let sref = typeof strOrObj === 'string'
|
|
171
175
|
? SuttaRef.create(strOrObj, defaultLang, suids)
|
|
172
176
|
: SuttaRef.create(Object.assign({},strOrObj), defaultLang, suids);
|
|
@@ -174,6 +178,7 @@ export default class SuttaRef {
|
|
|
174
178
|
if (normalize && sref) {
|
|
175
179
|
let { sutta_uid, lang, author, segnum } = sref;
|
|
176
180
|
if (sutta_uid && author == null) {
|
|
181
|
+
dbg && console.log(msg, '[2]author?', {sref});
|
|
177
182
|
sref.author = AuthorsV2.suttaAuthor(sref);
|
|
178
183
|
}
|
|
179
184
|
}
|