scripture-guide 1.0.24 → 1.0.26

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/README.md CHANGED
@@ -130,3 +130,5 @@ Following this structure, the verse_ids corresponding to each book, chapter and
130
130
  ## Authors
131
131
 
132
132
  * **KC Kern** - *Initial work* - [kckern](https://github.com/kckern)
133
+
134
+ ```npm run build && node test.js```
@@ -168,7 +168,7 @@ module.exports = {
168
168
  i = i.replace("~", "-");
169
169
  i = i.replace(/(\d+) *장/g, "$1");
170
170
  i = i.replace(/(\d+) *절/g, "$1");
171
-
171
+ i = i.replace(/([\u3131-\uD79D]) *(\d+)/ig, "$1 $2");
172
172
  return i;
173
173
  }
174
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "A utility for biblical and scripture reference parsing that enables structured queries based on strings of traditional scripture references (e.g. John 3:16). ",
5
5
  "main": "scriptures-compiled.js",
6
6
  "scripts": {
@@ -541,8 +541,18 @@ var detectReferences = function detectReferences(content, callBack) {
541
541
  matches = matches.map(function (i) {
542
542
  return i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
543
543
  });
544
- //split by matches
545
- var pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
544
+ matches = matches.filter(function (i) {
545
+ return i.length <= 100;
546
+ });
547
+
548
+ // split by matches
549
+ var pieces;
550
+ try {
551
+ pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
552
+ } catch (error) {
553
+ console.log('Invalid regular expression:', error);
554
+ return content;
555
+ }
546
556
  content = pieces.map(function (i, j) {
547
557
  if (j % 2 == 0) return i;
548
558
  return callBack(i);
package/scriptures.js CHANGED
@@ -514,15 +514,23 @@ const detectReferences = (content,callBack,wordBreak="\\b") => {
514
514
  const bookMatchList = [...dst, ...src].map(i => [i]);
515
515
  const pattern = preparePattern(bookMatchList,wordBreak,lang_extra);
516
516
  const blacklist_pattern = prepareBlacklist();
517
- var matches = content.match(pattern)?.filter(i=>!blacklist_pattern.test(i)) || [];
518
- matches = matches.map(i => i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim());
519
- //split by matches
520
- const pieces = matches.length? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
521
-
522
- content = pieces.map((i,j)=>{
523
- if(j%2==0) return i;
517
+ var matches = content.match(pattern)?.filter(i => !blacklist_pattern.test(i)) || [];
518
+ matches = matches.map(i => i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim())
519
+ matches = matches.filter(i => i.length <= 100);
520
+
521
+ // split by matches
522
+ let pieces;
523
+ try {
524
+ pieces = matches.length ? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
525
+ } catch (error) {
526
+ console.log('Invalid regular expression:', error);
527
+ return content;
528
+ }
529
+
530
+ content = pieces.map((i, j) => {
531
+ if (j % 2 == 0) return i;
524
532
  return callBack(i);
525
- }).join("").replace(/\s+/g," ").trim();
533
+ }).join("").replace(/\s+/g, " ").trim();
526
534
 
527
535
  return content;
528
536
  }
package/test-detect.js CHANGED
@@ -5,7 +5,8 @@ const {lookup, generateReference, setLanguage, detectReferences}= require("./scr
5
5
  const lines = [
6
6
  "Please refer to Genesis 20 in the bible",
7
7
  "Please refer to 3 Nephi 5:1-3 in the Book of Mormon",
8
- "For example, in Matthew 27:51, the earth quakes and ro"
8
+ "For example, in Matthew 27:51, the earth quakes and ro",
9
+ "(Here is a compound referece) at (the end of a sentence. (Alma 5:1-3; 6:7-9; Genesis 1:1-2)",
9
10
  ]
10
11
 
11
12
  lines.forEach(l=>{
@@ -13,7 +14,7 @@ lines.forEach(l=>{
13
14
  console.log({result});
14
15
  });
15
16
 
16
- //process.exit(0);
17
+ process.exit(0);
17
18
 
18
19
  setLanguage("ko");
19
20
 
package/test-lang.js CHANGED
@@ -9,9 +9,7 @@ setLanguage("ko");
9
9
  //korean tests
10
10
  const lookUpTests = [
11
11
  "이더서 13장 18절",
12
-
13
-
14
-
12
+ "니전5.2",
15
13
 
16
14
  ]
17
15