scripture-guide 1.0.26 → 1.0.27
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/data/scriptdetect.js +1 -0
- package/package.json +1 -1
- package/scriptures-compiled.js +13 -5
- package/scriptures.js +13 -3
- package/test-detect.js +1 -1
package/data/scriptdetect.js
CHANGED
|
@@ -12,6 +12,7 @@ const prepareBlacklist = (lang_extras) => {
|
|
|
12
12
|
blacklist.push("\\b(AC3|PS2|PS3|PS4)\\b"); //Common file extentions
|
|
13
13
|
blacklist.push("\\b(ps|PS)[1-9]\\b"); //Common file extentions'
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
var blacklist_pattern = new RegExp("(" + blacklist.join("|") + ")", 'g');
|
|
16
17
|
|
|
17
18
|
return blacklist_pattern;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripture-guide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
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
|
@@ -522,6 +522,9 @@ var detectReferences = function detectReferences(content, callBack) {
|
|
|
522
522
|
callBack = callBack ? callBack : function (i) {
|
|
523
523
|
return "[".concat(i, "]");
|
|
524
524
|
};
|
|
525
|
+
var trimExternalMatchStrings = function trimExternalMatchStrings(i) {
|
|
526
|
+
return i.trim().replace(/^[^0-9]*\(/g, '').replace(/\)[^0-9]*$/g, '').replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
|
|
527
|
+
};
|
|
525
528
|
var hasNoAlpha = !/[A-Za-z]/.test(content);
|
|
526
529
|
if (hasNoAlpha && wordBreak) wordBreak = "";
|
|
527
530
|
var src = raw_regex.books.map(function (i) {
|
|
@@ -538,11 +541,12 @@ var detectReferences = function detectReferences(content, callBack) {
|
|
|
538
541
|
var matches = ((_content$match = content.match(pattern)) === null || _content$match === void 0 ? void 0 : _content$match.filter(function (i) {
|
|
539
542
|
return !blacklist_pattern.test(i);
|
|
540
543
|
})) || [];
|
|
541
|
-
matches = matches.map(
|
|
542
|
-
return i.trim().replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
|
|
543
|
-
});
|
|
544
|
+
matches = matches.map(trimExternalMatchStrings);
|
|
544
545
|
matches = matches.filter(function (i) {
|
|
545
|
-
return i.length <=
|
|
546
|
+
return i.length <= 1000;
|
|
547
|
+
});
|
|
548
|
+
console.log({
|
|
549
|
+
matches: matches
|
|
546
550
|
});
|
|
547
551
|
|
|
548
552
|
// split by matches
|
|
@@ -550,7 +554,11 @@ var detectReferences = function detectReferences(content, callBack) {
|
|
|
550
554
|
try {
|
|
551
555
|
pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
|
|
552
556
|
} catch (error) {
|
|
553
|
-
console.
|
|
557
|
+
console.error(error);
|
|
558
|
+
console.log({
|
|
559
|
+
matches: matches,
|
|
560
|
+
pattern: pattern
|
|
561
|
+
});
|
|
554
562
|
return content;
|
|
555
563
|
}
|
|
556
564
|
content = pieces.map(function (i, j) {
|
package/scriptures.js
CHANGED
|
@@ -506,6 +506,13 @@ const detectReferences = (content,callBack,wordBreak="\\b") => {
|
|
|
506
506
|
|
|
507
507
|
callBack = callBack ? callBack : (i)=>{return `[${i}]`};
|
|
508
508
|
|
|
509
|
+
const trimExternalMatchStrings = (i) => i.trim().
|
|
510
|
+
replace(/^[^0-9]*\(/g, '').
|
|
511
|
+
replace(/\)[^0-9]*$/g, '').
|
|
512
|
+
replace(/[,;!?.()]+$/ig, "").
|
|
513
|
+
replace(/^[,;!?.()]+/ig, " ").
|
|
514
|
+
trim();
|
|
515
|
+
|
|
509
516
|
const hasNoAlpha = !/[A-Za-z]/.test(content);
|
|
510
517
|
if(hasNoAlpha && wordBreak) wordBreak = "";
|
|
511
518
|
|
|
@@ -515,15 +522,18 @@ const detectReferences = (content,callBack,wordBreak="\\b") => {
|
|
|
515
522
|
const pattern = preparePattern(bookMatchList,wordBreak,lang_extra);
|
|
516
523
|
const blacklist_pattern = prepareBlacklist();
|
|
517
524
|
var matches = content.match(pattern)?.filter(i => !blacklist_pattern.test(i)) || [];
|
|
518
|
-
matches = matches.map(
|
|
519
|
-
matches = matches.filter(i => i.length <=
|
|
525
|
+
matches = matches.map(trimExternalMatchStrings)
|
|
526
|
+
matches = matches.filter(i => i.length <= 1000);
|
|
527
|
+
|
|
528
|
+
console.log({matches});
|
|
520
529
|
|
|
521
530
|
// split by matches
|
|
522
531
|
let pieces;
|
|
523
532
|
try {
|
|
524
533
|
pieces = matches.length ? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
|
|
525
534
|
} catch (error) {
|
|
526
|
-
console.
|
|
535
|
+
console.error(error);
|
|
536
|
+
console.log({matches,pattern});
|
|
527
537
|
return content;
|
|
528
538
|
}
|
|
529
539
|
|
package/test-detect.js
CHANGED
|
@@ -6,7 +6,7 @@ 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
8
|
"For example, in Matthew 27:51, the earth quakes and ro",
|
|
9
|
-
"
|
|
9
|
+
"It aligns with other scriptures (3 Nephi 12:2, Mosiah 18:13, Moses 6:52).",
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
lines.forEach(l=>{
|