scripture-guide 1.0.41 → 1.0.43

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.
@@ -22,21 +22,29 @@ const findMatches = (content,books,lang_extra) => {
22
22
 
23
23
 
24
24
  const bookSubStrings = fullBookMatches.map(bookMatch=>{
25
- const matchCount = content.match(new RegExp(bookMatch,"ig")).length;
26
25
  const substrings = content.match(new RegExp(bookMatch,"ig")).flat();
27
26
  return substrings;
28
27
  }).flat().reduce((prev,current)=>{
29
28
  if(prev.includes(current)) return prev;
30
29
  return [...prev,current]
31
30
  },[]).filter(i=>!!i).map(substring=>{
31
+ substring = substring.trim();
32
32
  let positions = [];
33
33
  let index = content.indexOf(substring);
34
34
  while (index != -1) {
35
35
  positions.push(index);
36
36
  index = content.indexOf(substring, index + 1);
37
37
  } return [substring,positions];
38
- });
39
-
38
+ }).map(([substring,positions])=>{
39
+ const preChars = positions.map(i=>content.substring(i-1,i));
40
+ positions = positions.filter((i,index)=>{
41
+ const charRightBeforeMatch = preChars[index];
42
+ const leadingCharIsInvalid = !/^(\s|\W|)$/.test(charRightBeforeMatch);
43
+ return !leadingCharIsInvalid;
44
+ });
45
+ if(!positions.length) return false;
46
+ return [substring,positions];
47
+ }).filter(i=>!!i);
40
48
 
41
49
  const possiblyOverlappingMatches = bookSubStrings.map(([substring,positions])=>{
42
50
  return positions.map(i=>{
@@ -95,10 +103,6 @@ function findMatchIndexes(content, matches,lookupReference, lang_extra) {
95
103
  .map(a=>{
96
104
 
97
105
  const substring = content.substring(a[0],a[1]).replace(tail,"").trim();
98
- const charRightBeforeMatch = content.substring(a[0]-1,a[0]);
99
- const leadingCharIsInvalid = !/^(\s|\W|)$/.test(charRightBeforeMatch);
100
- // console.log({substring, charRightBeforeMatch, leadingCharIsInvalid});
101
- if(leadingCharIsInvalid) return false;
102
106
  const verse_ids = lookupReference(substring).verse_ids;
103
107
  //console.log({a,substring,verse_ids});
104
108
  if(verse_ids.length > 0) return [a[0],a[0]+substring.length];
@@ -184,10 +188,13 @@ const processReferenceDetection = (content,books,lang_extra,lookupReference,call
184
188
 
185
189
 
186
190
 
187
- joiners = lang_extra.joiners || ["^[;, ]*(and|c\.*f\.*)*$"];
188
- const gapThatMayBeMerged = gapsBetweenIndeces.map(([start,end])=>{
189
- const string = content.substring(start,end).trim();
190
- const canBeMerged = joiners.some(joiner=>(new RegExp(joiner,"ig")).test(string));
191
+
192
+ joiners = lang_extra.joiners || ["^[;, ]*(and|c\\.*f\\.*)*$"];
193
+ const gapThatMayBeMerged = gapsBetweenIndeces.map(([start,end],i)=>{
194
+ const gapString = gapStrings[i];
195
+ const canBeMerged = joiners.some(joiner=>(new RegExp(joiner,"ig")).test(gapString));
196
+ const matchingJoiner = joiners.find(joiner=>(new RegExp(joiner,"ig")).test(gapString));
197
+ //console.log({gapString,matchingJoiner});
191
198
  return canBeMerged;
192
199
  });
193
200
 
@@ -66,6 +66,9 @@ module.exports = {
66
66
  pre_rules: [
67
67
  //replace dashes in book names with spaces
68
68
  ["-([^0-9 ])", " $1"],
69
+ [", *([^0-9])", "; $1"],
70
+ ["(hoặc|và|so với)", "; "],
71
+ [";\\s*Giao", "và Giao"],
69
72
  ],
70
73
  books:{
71
74
  "Sáng Thế": ["STK[yý]", "Sáng Thế Ký","S[áa]ng *Th[ếe] *(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at *Ê *D[íi]p *T[ôo] *(K[yý])*","Xu[ấa]t h[àa]nh *(k[yý])*"], "Lê Vi": ["L[êe] *Vi *(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n *S[ốo] *(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c *Truy[ềe]n *Lu[ậa]t *L[ệe] *(K[yý])*"], "Giô Suê": ["Gi[ôo] *Su[êe]"], "Các Quan Xét": ["C[áa]c *Quan *X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru *T[ơo]"], "1 Sa Mu Ên": ["1 *Sa *Mu *Ên","1 *SM[EÊ]n"], "2 Sa Mu Ên": ["2 *Sa *Mu *Ên","2 *SM[EÊ]n"], "1 Các Vua": ["1 *C[áa]c *Vua","1 *Vua"], "2 Các Vua": ["2 *C[áa]c *Vua","2 *Vua"], "1 Sử Ký": ["1 *S[ửu] *K[yý]"], "2 Sử Ký": ["2 *S[ửu] *K[yý]"], "E Xơ Ra": ["E *X[ơo] *Ra"], "Nê Hê Mi": ["N[êe] *H[êe] *Mi"], "Ê Xơ Tê": ["Ê *X[ơo] *T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i* *Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m *Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n *[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa] *Ca"], "Ê Sai": ["[ÊE] *Sai"], "Giê Rê Mi": ["GRMi","Gi[êe] *R[êe] *Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca *Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê *X[êe] *Chi *[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a *Ni *[ÊE]n"], "Ô Sê": ["[ÔO] *S[êe]"], "Giô Ên": ["Gi[ôo] *[ÊE]n"], "A Mốt": ["A *M[ốo]t"], "Áp Đia": ["[ÁA]p *Đia"], "Giô Na": ["Gi[ôo] *Na"], "Mi Chê": ["Mi *Ch[êe]"], "Na Hum": ["Na *Hum"], "Ha Ba Cúc": ["HBCuc","Ha *Ba *C[úu]c"], "Sô Phô Ni": ["S[ôo]* *Ph*[ôo]* *Ni"], "A Ghê": ["A *Gh[êe]"], "Xa Cha Ri": ["Xa* *Ch*a* *Ri"], "Ma La Chi": ["Ma* *La* *Chi"], "Ma Thi Ơ": ["Ma *Thi *[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu *Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng *Vụ *C[áa]c *Sứ *Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo] *Ma"], "1 Cô Rinh Tô": ["1 *C[ôo]* *Ri*n*h* *T[ôo]"], "2 Cô Rinh Tô": ["2 *C[ôo]* *Ri*n*h* *T[ôo]"], "Ga La Ti": ["Ga *La *Ti"], "Ê Phê Sô": ["[ÊE] *Ph[êe] *S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi *L[íi]p"], "Cô Lô Se": ["C[ôo] *L[ôo] *Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1 *Tê *Sa *L[ôo] *Ni *Ca","1 *TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2 *Tê *Sa *L[ôo] *Ni *Ca","2 *TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1 *Ti *Mô *Th[êe]","1 *TMTh[ÊE]"], "2 Ti Mô Thê": ["2 *Ti *Mô *Th[êe]","2 *TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi *L[êe] *Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe] *Bơ *Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia *C[ơo]"], "1 Phi E Rơ": ["1 *Phi *E *R[ơo]","1 *PER[ƠO]"], "2 Phi E Rơ": ["2 *Phi *E *R[ơo]","2 *PER[ƠO]"], "1 Giăng": ["1 *Gio*[ăa]ng*"], "2 Giăng": ["2 *Gio*[ăa]ng*"], "3 Giăng": ["3 *Gio*[ăa]ng*"], "Giu Đe": ["Giu *[ĐD]e"], "Khải Huyền": ["Kh[ảa]i *Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1 *N[êe] *Phi"], "2 Nê Phi": ["2 *N[êe] *Phi"], "Gia Cốp": ["Gi*a* *C[ốo]p"], "Ê Nót": ["[ÊE] *N[óo]t"], "Gia Rôm": ["Gi*a* *R[ôo]m"], "Ôm Ni": ["[ÔO]m *Ni"], "Lời Mặc Môn": ["L[ờo]i *M[ặa]c *M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo] *Si *A"], "An Ma": ["An *Ma"], "Hê La Man": ["H[êe]* *La* *Man"], "3 Nê Phi": ["3 *N[êe] *Phi"], "4 Nê Phi": ["4 *N[êe] *Phi"], "Mặc Môn": ["M[ậa]c *M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE] *The"], "Mô Rô Ni": ["M[ôo] *R[ôo] *Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o *L[ýi] *v[àa] *Giao *[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i *Se"], "Áp Ra Ham": ["[ÁA]p *Ra *Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph *Smith—Ma *Thi *[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph *Smith—L[ịi]ch *S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng *T[íi]n *[ĐD]i[ềe]u", "NT[ĐD]"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
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/test/data/en.txt CHANGED
@@ -7,4 +7,21 @@ The fruit mentioned in 1 Nephi 8:9-12 represents something desirable and joyous.
7
7
  In accordance with David’s last words at 2 Sam 23.3 (cf. Mos 23.8; 29.16). The Davidic reference may have been included as a conciliatory gesture to his descendants among the Mulekites. The reading in P (“thereby”) implies that keeping the commandments leads to rejoicing and love.
8
8
  As Jacob’s priestly lineage comes to an end, the transferal of the plates to Benjamin means that both the Large and Small Plates of Nephi are in the possession of the Nephite kings; cf. WoM 1.10. Amaleki’s reference to spiritual gifts and his assertion about the sources of good and evil will be repeated at Moro 7.12, 16–17; 10.13–16; cf. Alma 5.40. The order of gifts listed generally reflects 1 Cor 12.10.
9
9
  Consistently D&C 3:16-17 no "Samites" Mormon 1:8 mentioned across the board in Restoration scripture; cf. Jacob 1:13; 4 Nephi 1:38; Mormon 1:8; D&C 3:17-18
10
- The Nephites thought of themselves as living on an island, and they believed that other groups of Israelites had been led away by God to other islands as well; see 1 Ne 19.10,15–16;21.1,8;22.3–4;2 Ne 10.7–8;29.7. Note also the mention of “isles” in Isa 51.5, which Jacob quoted at 2 Ne 8.5.
10
+ The Nephites thought of themselves as living on an island, and they believed that other groups of Israelites had been led away by God to other islands as well; see 1 Ne 19.10,15–16;21.1,8;22.3–4;2 Ne 10.7–8;29.7. Note also the mention of “isles” in Isa 51.5, which Jacob quoted at 2 Ne 8.5.
11
+ There is a difference between being reconciled to the will of God (accepting the contingencies of salvation history, even as they may apply negatively to one’s posterity), unique here, and being reconciled unto God (repenting of personal sins in accordance with the plan of salvation), which occurs three times in the NT and four times in the BoM. In the NT, God always reconciles humans to himself through Christ; the BoM, by contrast, invites people to reconcile themselves to God, by availing themselves of Christ’s atonement; cf. 2 Nephi 33.9; Jacob 4.11. Nevertheless, even if salvation requires an element of human volition, the process is initiated and completed through the grace of God; see 2 Nephi 25.23n.
12
+ See Deut 30.19; Jacob2 draws on Lehi1’s elaboration at 2 Ne 2.26–29 as well as on Jeremiah’s allusion at Jer 21.8.
13
+ In 2 Nephi 9:13 it says, "O how great the plan of our God!" Hugh Nibley notes that the word "plan" is not found in the Bible, yet it's found forty-two times in the Book of Mormon . . . and thirty-six times in the book of Alma. . . . Origen tells us that in the early church they taught that you earned your position here before you came here. So whatever happened to the plan? How did it drop out of the Bible? . . . When the temple was lost the rabbis took over. They were learned men but they were not priests. . . . The philosophers at the School of Alexandria took it over, and in their place you have the doctrines of St. Augustine--this takes the place of the plan. That is, you are predestined to damnation or you are predestined to salvation. . . . This predestination doctrine of St. Augustine was taken over by the Lutherans and by the Calvinists especially. What happens to you is because you were predestined that way. Of course, you didn't live before you came here; you didn't earn it or anything like that. . . . All creation had to be instantaneously, simultaneously complete. Everything was completely there all at once, so you had no background or anything. [Hugh W. Nibley, Teachings of the Book of Mormon, pp. 295-296] [See the commentary on Jarom 1:2; Alma 22:13]
14
+ Isa 61.10; 2 Ne 4.33.
15
+ WB includes “hindrance, opposition,” though both Jacob and Nephi knew of Jesus’s future crucifixion; see 2 Nephi 6.9;1 Ne 11.33;19.10.
16
+
17
+ “to choose the way of everlasting death or the way of eternal life” • See Deut 30.19; Jacob2 draws on Lehi1’s elaboration at 2 Ne 2.26–29 as well as on Jeremiah’s allusion at Jer 21.8.
18
+ Note Source
19
+ Jacob concludes by referencing the plan of salvation; see 2 Nephi 9.53–54n.
20
+ Note Source
21
+ A synopsis of Lehi’s words at 2 Nephi 2.26–29, which were an elaboration of Deut 30.19. Here, however, the expression is conflated with Jeremiah’s interpretation of the same Deut verse at Jer 21.8: “I set before you the way of life, and the way of death.”
22
+ Note Source
23
+ There is a difference between being reconciled to the will of God (accepting the contingencies of salvation history, even as they may apply negatively to one’s posterity), unique here, and being reconciled unto God (repenting of personal sins in accordance with the plan of salvation), which occurs three times in the NT and four times in the BoM. In the NT, God always reconciles humans to himself through Christ; the BoM, by contrast, invites people to reconcile themselves to God, by availing themselves of Christ’s atonement; cf. 2 Nephi 33.9; Jacob 4.11. Nevertheless, even if salvation requires an element of human volition, the process is initiated and completed through the grace of God; see 2 Nephi 25.23n.
24
+ Note Source
25
+ WB includes “hindrance, opposition,” though both Jacob and Nephi knew of Jesus’s future crucifixion; see 2 Nephi 6.9;1 Ne 11.33;19.10.
26
+ “Everlasting death” • Here and in 2 Nephi 10:23, can be contrasted with the temporary death that everyone will experience and then be rescued from by the Resurrection. Elsewhere the BoM uses the term “second death” to describe the post-resurrection, post-judgment separation from God that will never end (e.g., Alma 12.32: “a second death, which was an everlasting death”).
27
+ The combination of repentance, baptism, faith, and enduring to the end (along with the Holy Ghost) is identified as the doctrine of Christ at 2 Nephi 31.2–21, and the essence of the gospel at 3 Ne 27.13–22. Although Jacob in these two verses, and later Nephi (in ch. 31), speaks in general, abstract terms about baptism, there are no recorded baptisms in the BoM until Alma baptizes at Mos 18, nearly four hundred years later, where the practice appears to be something new.