scv-bilara 3.175.22 → 3.176.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scv-bilara",
3
- "version": "3.175.22",
3
+ "version": "3.176.1",
4
4
  "description": "SuttaCentral bilara-data library",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -15,7 +15,7 @@
15
15
  "log-instance": "^1.6.0",
16
16
  "memo-again": "^0.10.0",
17
17
  "merkle-json": "^2.2.0",
18
- "scv-esm": "^1.115.566",
18
+ "scv-esm": "^1.115.567",
19
19
  "suttacentral-api": "^2.17.55",
20
20
  "tmp": "^0.2.3"
21
21
  },
package/src/defines.cjs CHANGED
@@ -1,19 +1,24 @@
1
1
  module.exports.DBG_BD_INIT = 0; // BilaraData creation
2
2
  module.exports.DBG_EXEC = 0;
3
3
  module.exports.DBG_EXAMPLES = 0;
4
- module.exports.DBG_GREP = 0;
5
4
  module.exports.DBG_MLD = 0;
6
5
  module.exports.DBG = {
7
6
  FIND: 0,
8
- FINDARGS: 0,
9
7
  MLD_CTOR: 0,
10
8
  MLD_LOAD: 0,
11
9
  MLD_TITLES: 0,
12
- SEEKER: 0,
10
+ SEEKER: {
11
+ CTOR: 0,
12
+ FINDARGS: 0,
13
+ GREP: 0,
14
+ SLOWGREP: 0,
15
+ SANITIZE_PATTERN: 0,
16
+ SLOWFIND: 0,
17
+ SLOWFINDID: 0,
18
+ SLOWFINDPHRASE: 0,
19
+ SLOWFINDTRILINGUAL: 0,
20
+ },
13
21
  SEARCH_SCRIPT: 0,
14
- SLOWFIND: 0,
15
- SLOWFINDID: 0,
16
- SLOWFINDTRILINGUAL: 0,
17
22
  SUTTA_UIDSEARCH: 0,
18
23
  TRILINGUALDOC: 0,
19
24
  VERBOSE: 0,
package/src/seeker.cjs CHANGED
@@ -25,15 +25,15 @@
25
25
 
26
26
  const {
27
27
  DBG,
28
- DBG_GREP,
29
28
  } = require("./defines.cjs");
29
+ const { SEEKER } = DBG;
30
30
 
31
31
  var wscount = 0;
32
32
 
33
33
  class Seeker {
34
34
  constructor(opts = {}) {
35
35
  const msg = "Seeker.ctor()";
36
- const dbg = DBG.SEEKER;
36
+ const dbg = SEEKER.CTOR;
37
37
  (opts.logger || logger).logInstance(this, opts);
38
38
  let bilaraData =
39
39
  (this.bilaraData = opts.bilaraData || new BilaraData(opts));
@@ -251,7 +251,7 @@
251
251
 
252
252
  grep(opts = {}) {
253
253
  const msg = "Seeker.grep() ";
254
- const dbg = DBG_GREP;
254
+ const dbg = SEEKER.GREP;
255
255
  var {
256
256
  author,
257
257
  pattern,
@@ -270,6 +270,7 @@
270
270
  var reTipCat = this.tipitakaRegExp(tipitakaCategories);
271
271
  lang = lang || language || this.lang;
272
272
  var root = this.root.replace(`${Files.APP_DIR}/`, "");
273
+ dbg && console.log(msg, {root});
273
274
  var slowOpts = {
274
275
  author,
275
276
  pattern,
@@ -314,7 +315,7 @@
314
315
 
315
316
  static async slowGrep(opts) {
316
317
  const msg = "Seeker.slowGrep ";
317
- const dbg = DBG_GREP;
318
+ const dbg = SEEKER.SLOWGREP;
318
319
  try {
319
320
  var {
320
321
  author,
@@ -327,6 +328,7 @@
327
328
  root,
328
329
  patPrimary,
329
330
  } = opts;
331
+ dbg && console.log(msg, JSON.stringify(opts, null, 2));
330
332
  if (!root.startsWith("/")) {
331
333
  root = `${Files.APP_DIR}/${root}`;
332
334
  }
@@ -379,7 +381,7 @@
379
381
  dbg && console.log(msg, {cmd, execOpts, lines, paths});
380
382
  return paths;
381
383
  } catch (e) {
382
- logger.warn(`slowGrep()`, JSON.stringify(opts), e.message, cmd);
384
+ logger.warn(msg, JSON.stringify(opts), e.message, cmd);
383
385
  throw e;
384
386
  }
385
387
  }
@@ -531,7 +533,7 @@
531
533
 
532
534
  findArgs(args) {
533
535
  const msg = "Seeker.findArgs() ";
534
- const dbg = DBG.SEEKER || DBG.FINDARGS;
536
+ const dbg = SEEKER.FINDARGS;
535
537
  const dbgv = DBG.VERBOSE;
536
538
  if (!(args instanceof Array)) {
537
539
  throw new Error("findArgs(?ARRAY-OF-ARGS?)");
@@ -803,7 +805,7 @@
803
805
 
804
806
  slowFindId(opts={}) {
805
807
  const msg = "Seeker.slowFindId() ";
806
- const dbg = DBG.SEEKER || DBG.SLOWFIND || DBG.SLOWFINDID;
808
+ const dbg = SEEKER.SLOWFINDID;
807
809
  const dbgv = DBG.VERBOSE && dbg;
808
810
  let {
809
811
  lang='en',
@@ -870,7 +872,7 @@
870
872
 
871
873
  async slowFind(findArgs) {
872
874
  const msg = "Seeker.slowFind() ";
873
- const dbg = DBG.SLOWFIND;
875
+ const dbg = SEEKER.SLOWFIND;
874
876
  try {
875
877
  var msStart = Date.now();
876
878
  let result;
@@ -893,7 +895,7 @@
893
895
 
894
896
  async slowFindLegacy(findArgs) {
895
897
  const msg = "Seeker.slowFindLegacy() ";
896
- const dbg = DBG.SEEKER || DBG.SLOWFIND;
898
+ const dbg = SEEKER.SLOWFIND;
897
899
  var msStart = Date.now();
898
900
  var {
899
901
  author,
@@ -1069,7 +1071,7 @@
1069
1071
 
1070
1072
  async slowFindTrilingual(findArgs) {
1071
1073
  const msg = "Seeker.slowFindTrilingual()";
1072
- const dbg = DBG.SEEKER || DBG.SLOWFIND || DBG.SLOWFINDID;
1074
+ const dbg = SEEKER.SLOWFIND || SEEKER.SLOWFINDID;
1073
1075
  const dbgv = DBG.VERBOSE && dbg;
1074
1076
  var msStart = Date.now();
1075
1077
  var {
@@ -1259,8 +1261,8 @@
1259
1261
  }
1260
1262
 
1261
1263
  async slowFindPhrase(args = {}) {
1262
- const msg = "Seeker.slowFindPhrase() ";
1263
- const dbg = DBG.SEEKER;
1264
+ const msg = "S4R.slowFindPhrase:";
1265
+ const dbg = SEEKER.SLOWFINDPHRASE;
1264
1266
  let {
1265
1267
  author,
1266
1268
  lang,
@@ -1275,6 +1277,7 @@
1275
1277
  author = author || AuthorsV2.langAuthor(searchLang, {
1276
1278
  category: tipitakaCategories,
1277
1279
  });
1280
+ let phrasePat = pattern.replaceAll(/\s/mg, '\\s');
1278
1281
  try {
1279
1282
  let msStart = Date.now();
1280
1283
  let bd = this.bilaraData;
@@ -1285,7 +1288,7 @@
1285
1288
  let uids, suttaRefs;
1286
1289
  let searchOpts = {
1287
1290
  author,
1288
- pattern,
1291
+ pattern: phrasePat,
1289
1292
  searchLang,
1290
1293
  maxResults,
1291
1294
  lang,
@@ -1297,11 +1300,13 @@
1297
1300
  searchOpts
1298
1301
  );
1299
1302
  if (lines.length) {
1300
- dbg && console.log(msg, {resultPattern, lines});
1303
+ dbg && console.log(msg+'1.1', {resultPattern, lines});
1301
1304
  this.debug(msg, `phrase`, {
1302
1305
  resultPattern, lines: lines.length });
1303
1306
  } else {
1304
1307
  method = "keywords";
1308
+ searchOpts.pattern = pattern;
1309
+ dbg && console.log(msg+'1.2', {resultPattern, lines});
1305
1310
  let data = await this.keywordSearch(searchOpts);
1306
1311
  var { lines, resultPattern } = data;
1307
1312
  this.debug(msg, `keywords`, {
@@ -1312,7 +1317,7 @@
1312
1317
  sortLines && lines.sort(sortLines);
1313
1318
  suttaRefs =
1314
1319
  lines.map((line) => BilaraPath.pathParts(line).suttaRef);
1315
- dbg && console.log(msg, `suttaRefs`, suttaRefs);
1320
+ dbg && console.log(msg+9, `suttaRefs`, suttaRefs);
1316
1321
  return {
1317
1322
  method,
1318
1323
  resultPattern,