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 +2 -0
- package/data/scriptlang.js +1 -1
- package/package.json +1 -1
- package/scriptures-compiled.js +12 -2
- package/scriptures.js +16 -8
- package/test-detect.js +3 -2
- package/test-lang.js +1 -3
package/README.md
CHANGED
package/data/scriptlang.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
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": {
|
package/scriptures-compiled.js
CHANGED
|
@@ -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
|
-
|
|
545
|
-
|
|
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
|
|
518
|
-
matches = matches.map(i => i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim())
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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
|
-
|
|
17
|
+
process.exit(0);
|
|
17
18
|
|
|
18
19
|
setLanguage("ko");
|
|
19
20
|
|