codexparser 0.0.60 → 0.0.62
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 +1 -1
- package/regex-tester.js +15 -4
- package/src/CodexParser.js +13 -13
- package/src/abbr.js +43 -24
- package/src/regex.js +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"description": "This is a Javascript Bible parser and text scanner. It will search through texts and collate all scripture references into an array and parse them into objects, and it will parse passages into objects by book, chapter, verse, and testament. ",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/regex-tester.js
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
const CodexParser = require("./src/CodexParser")
|
|
2
|
+
const util = require("util")
|
|
3
|
+
|
|
4
|
+
const dump = (item) => {
|
|
5
|
+
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
|
+
}
|
|
2
7
|
|
|
3
8
|
const parser = new CodexParser()
|
|
4
9
|
const passage = "jer 9.24 1 cor 1.31 Jd 1"
|
|
5
|
-
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19
|
|
10
|
+
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19. 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4
|
|
6
11
|
|
|
7
12
|
Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
8
13
|
|
|
9
14
|
Jd. 5
|
|
10
15
|
Jd 6
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
1Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
|
|
13
18
|
|
|
14
19
|
Leviticus 16:6 He 5.3 He 7.27
|
|
15
20
|
|
|
16
21
|
Hos 10:1-3, 8 and 1 John 2:23
|
|
17
22
|
|
|
18
|
-
exod15.18. 2 Cor 12:23 Malachi 3:32`
|
|
23
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 2 Kings 4:8,17-37`
|
|
24
|
+
|
|
25
|
+
const philemon = "Phlm 1 Phlm 1:2 Philemon 1:3 Phil 2:3 Phile 7"
|
|
26
|
+
|
|
27
|
+
const ez = "Ezekiel 12:3 Ezek 1:2 Ezk 2:2 Ezra 1:1 Ezr 1:2 Ez 3:4-5"
|
|
28
|
+
|
|
29
|
+
const noSpace = "1 Thess 2.15-16"
|
|
19
30
|
|
|
20
31
|
parser.regex(text).regexParser()
|
|
21
|
-
|
|
32
|
+
dump(parser.getPassages())
|
package/src/CodexParser.js
CHANGED
|
@@ -169,19 +169,17 @@ class CodexParser {
|
|
|
169
169
|
if (typeof book !== "string") {
|
|
170
170
|
book = book[0]
|
|
171
171
|
}
|
|
172
|
-
let bookified
|
|
173
|
-
|
|
172
|
+
let bookified = Object.keys(this.abbrevations).find((abbr) => {
|
|
173
|
+
return abbr.toLowerCase() === book.toLowerCase()
|
|
174
|
+
})
|
|
175
|
+
bookified = this.abbrevations[bookified]
|
|
174
176
|
if (!bookified) {
|
|
175
177
|
bookified = this.bible.new.find(
|
|
176
|
-
(b) =>
|
|
177
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
178
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
178
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
179
179
|
)
|
|
180
180
|
if (!bookified) {
|
|
181
181
|
bookified = this.bible.old.find(
|
|
182
|
-
(b) =>
|
|
183
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
184
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
182
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
185
183
|
)
|
|
186
184
|
}
|
|
187
185
|
}
|
|
@@ -275,7 +273,6 @@ class CodexParser {
|
|
|
275
273
|
|
|
276
274
|
regex(text) {
|
|
277
275
|
this.found = text.match(this.scripturesRegex)
|
|
278
|
-
console.log(this.found)
|
|
279
276
|
return this
|
|
280
277
|
}
|
|
281
278
|
|
|
@@ -301,8 +298,12 @@ class CodexParser {
|
|
|
301
298
|
verse = this.found[i].split(" ")[1]
|
|
302
299
|
chapter = "1"
|
|
303
300
|
} else {
|
|
304
|
-
if (this.found[i].match(this.verseRegex))
|
|
301
|
+
if (this.found[i].match(this.verseRegex) && !hasChapterRange)
|
|
305
302
|
verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
|
|
303
|
+
else if (this.found[i].match(this.verseRegex) && hasChapterRange)
|
|
304
|
+
verse = this.found[i].match(this.verseRegex)
|
|
305
|
+
? this.found[i].match(this.verseRegex)[0].split("-")[0].trim()
|
|
306
|
+
: ["Empty"]
|
|
306
307
|
}
|
|
307
308
|
if (!verse && this.found[i].match(/\d+/)) {
|
|
308
309
|
chapter = this.found[i].match(/\d+/)[0]
|
|
@@ -318,13 +319,12 @@ class CodexParser {
|
|
|
318
319
|
if (hasChapterRange) {
|
|
319
320
|
passage.to = {
|
|
320
321
|
book: passage.book,
|
|
321
|
-
chapter: hasChapterRange[0].match(this.chapterRegex),
|
|
322
|
-
verses: hasChapterRange[0].match(this.verseRegex)[0]
|
|
322
|
+
chapter: hasChapterRange[0].match(this.chapterRegex)[0],
|
|
323
|
+
verses: hasChapterRange[0].match(this.verseRegex)[0],
|
|
323
324
|
}
|
|
324
325
|
passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
|
|
325
326
|
passage.to.testament = this.bible.old.includes(passage.to.book) ? "old" : "new"
|
|
326
327
|
}
|
|
327
|
-
console.log(passage)
|
|
328
328
|
passage.verses =
|
|
329
329
|
typeof passage.verses !== "object"
|
|
330
330
|
? passage.verses.split(/,/).filter(Boolean)
|
package/src/abbr.js
CHANGED
|
@@ -26,23 +26,33 @@ const abbrevations = {
|
|
|
26
26
|
Rth: "Ruth",
|
|
27
27
|
Ru: "Ruth",
|
|
28
28
|
"1Sam": "1 Samuel",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"1
|
|
33
|
-
"1
|
|
34
|
-
"1
|
|
35
|
-
"1
|
|
29
|
+
"1sam": "1 Samuel",
|
|
30
|
+
"1SA": "1 Samuel",
|
|
31
|
+
"1sa": "1 Samuel",
|
|
32
|
+
"1 SAM": "1 Samuel",
|
|
33
|
+
"1 sam": "1 Samuel",
|
|
34
|
+
"1 sm": "1 Samuel",
|
|
35
|
+
"1 sa": "1 Samuel",
|
|
36
|
+
"1 s": "1 Samuel",
|
|
36
37
|
"2 Sam": "2 Samuel",
|
|
37
|
-
"2
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
38
|
+
"2 sam": "2 Samuel",
|
|
39
|
+
"2SA": "2 Samuel",
|
|
40
|
+
"2sa": "2 Samuel",
|
|
41
|
+
"2 SAM": "2 Samuel",
|
|
42
|
+
"2 sam": "2 Samuel",
|
|
43
|
+
"2 sm": "2 Samuel",
|
|
44
|
+
"2 sa": "2 Samuel",
|
|
45
|
+
"2 s": "2 Samuel",
|
|
46
|
+
"II SAM": "2 Samuel",
|
|
47
|
+
"ii sam": "2 Samuel",
|
|
48
|
+
"II SA": "2 Samuel",
|
|
49
|
+
"ii sa": "2 Samuel",
|
|
50
|
+
"2SAM": "2 Samuel",
|
|
51
|
+
"2sam": "2 Samuel",
|
|
52
|
+
"2SM": "2 Samuel",
|
|
53
|
+
"2sm": "2 Samuel",
|
|
54
|
+
"2SA": "2 Samuel",
|
|
55
|
+
"2sa": "2 Samuel",
|
|
46
56
|
"1Kgs": "1 Kings",
|
|
47
57
|
"1 Kgs": "1 Kings",
|
|
48
58
|
"1Kgs": "1 Kings",
|
|
@@ -81,6 +91,7 @@ const abbrevations = {
|
|
|
81
91
|
"II Ch": "2 Chronicles",
|
|
82
92
|
Ezra: "Ezra",
|
|
83
93
|
Ezr: "Ezra",
|
|
94
|
+
Ez: "Ezra",
|
|
84
95
|
Neh: "Nehemiah",
|
|
85
96
|
Ne: "Nehemiah",
|
|
86
97
|
Esth: "Esther",
|
|
@@ -150,6 +161,7 @@ const abbrevations = {
|
|
|
150
161
|
Matt: "Matthew",
|
|
151
162
|
Mt: "Matthew",
|
|
152
163
|
Mark: "Mark",
|
|
164
|
+
Mc: "Mark",
|
|
153
165
|
Mrk: "Mark",
|
|
154
166
|
Mar: "Mark",
|
|
155
167
|
Mk: "Mark",
|
|
@@ -179,24 +191,34 @@ const abbrevations = {
|
|
|
179
191
|
"2Co": "2 Corinthians",
|
|
180
192
|
"2Cor": "2 Corinthians",
|
|
181
193
|
"2 Cor": "2 Corinthians",
|
|
194
|
+
"1cor": "1 Corinthians",
|
|
195
|
+
"1 cor": "1 Corinthians",
|
|
196
|
+
"1 co": "1 Corinthians",
|
|
197
|
+
"1co": "1 Corinthians",
|
|
198
|
+
"2cor": "2 Corinthians",
|
|
199
|
+
"2 cor": "2 Corinthians",
|
|
200
|
+
"2 co": "2 Corinthians",
|
|
201
|
+
"2co": "2 Corinthians",
|
|
182
202
|
Gal: "Galatians",
|
|
183
203
|
Ga: "Galatians",
|
|
184
204
|
Eph: "Ephesians",
|
|
185
205
|
Ephes: "Ephesians",
|
|
186
|
-
Phil: "Philippians",
|
|
187
206
|
Php: "Philippians",
|
|
188
207
|
Pp: "Philippians",
|
|
189
208
|
Col: "Colossians",
|
|
190
209
|
Co: "Colossians",
|
|
191
210
|
"1Thess": "1 Thessalonians",
|
|
192
211
|
"1 Thess": "1 Thessalonians",
|
|
212
|
+
"1Thes": "1 Thessalonians",
|
|
213
|
+
"1 Thes": "1 Thessalonians",
|
|
193
214
|
"1 Th": "1 Thessalonians",
|
|
194
215
|
"1Th": "1 Thessalonians",
|
|
195
216
|
"2Thess": "2 Thessalonians",
|
|
196
217
|
"2 Thess": "2 Thessalonians",
|
|
218
|
+
"2Thes": "2 Thessalonians",
|
|
219
|
+
"2 Thes": "2 Thessalonians",
|
|
197
220
|
"2 Th": "2 Thessalonians",
|
|
198
221
|
"2Th": "2 Thessalonians",
|
|
199
|
-
"2Thess": "2 Thessalonians",
|
|
200
222
|
"1Tim": "1 Timothy",
|
|
201
223
|
"1 Ti": "1 Timothy",
|
|
202
224
|
"1 Tm": "1 Timothy",
|
|
@@ -213,8 +235,7 @@ const abbrevations = {
|
|
|
213
235
|
Ti: "Titus",
|
|
214
236
|
Phlm: "Philemon",
|
|
215
237
|
Phm: "Philemon",
|
|
216
|
-
|
|
217
|
-
Ph: "Philemon",
|
|
238
|
+
Philem: "Philemon",
|
|
218
239
|
Hebr: "Hebrews",
|
|
219
240
|
Heb: "Hebrews",
|
|
220
241
|
He: "Hebrews",
|
|
@@ -222,7 +243,8 @@ const abbrevations = {
|
|
|
222
243
|
Jm: "James",
|
|
223
244
|
James: "James",
|
|
224
245
|
"1Pet": "1 Peter",
|
|
225
|
-
"
|
|
246
|
+
"1pe": "1 Peter",
|
|
247
|
+
"1 pe": "1 Peter",
|
|
226
248
|
"1 Pe": "1 Peter",
|
|
227
249
|
"1Pet": "1 Peter",
|
|
228
250
|
"2Pet": "2 Peter",
|
|
@@ -255,12 +277,9 @@ const abbrevations = {
|
|
|
255
277
|
Re: "Revelation",
|
|
256
278
|
Mt: "Matthew",
|
|
257
279
|
Mc: "Mark",
|
|
258
|
-
L: "Luke",
|
|
259
|
-
J: "John",
|
|
260
280
|
Act: "Acts",
|
|
261
281
|
"1K": "1 Corinthians",
|
|
262
282
|
"2K": "2 Corinthians",
|
|
263
|
-
Ph: "Philippians",
|
|
264
283
|
Kol: "Colossians",
|
|
265
284
|
"1Th": "1 Thessalonians",
|
|
266
285
|
"2Th": "2 Thessalonians",
|
package/src/regex.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const bookRegex =
|
|
2
|
-
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|
|
|
2
|
+
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s?)?(Gen|Ge|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|Neh|Ne|Esth|Job|Job|Jb|Pslm|Ps|Psalms|Psa|Psm|Pss|Prov|Pr|Prv|Eccles|Ec|Song|So|Canticles|Song of Songs|SOS|Isa|Is|Jer|Je|Jr|Lam|La|Ezek|Eze|Ezk|Dan|Da|Dn|Hos|Ho|Joel|Joe|Jl|Amos|Am|Obad|Ob|Jnh|Jon|Micah|Mic|Nah|Na|Hab|Zeph|Zep|Zp|Haggai|Hag|Hg|Zech|Zec|Zc|Mal|Mal|Ml|Matt|Mrk|Mk|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Php|Col|Col|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Phlm|Phile|Hebrews|Heb|He|James|Jas|Jm|Pe|Pet|Pt|Peter|Jn|Jo|Joh|Jhn|John|Jude|Jd|Jud|Jud|Rev|The Revelation|Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther|Job|Psalms|Psalm|Proverbs|Ecclesiastes|Song of Solomon|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi|Matthew|Matt|Mt|Mc|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Phil|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap))/gim
|
|
3
|
+
const EzraAbbrv = /(Ez)(?![a-zA-Z])/gim
|
|
3
4
|
const chapterRegex = /(\d+)(?=[:.])/gim
|
|
4
5
|
const verseRegex = /(?<=[:.])[\d: .\-]+(?:, ?[\d\-]+)*(?<![ .])/gim
|
|
5
6
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
6
7
|
const chapterRangeVerseRegex = /(?:.\d+)?/gm
|
|
7
8
|
const chapterVerseRange =
|
|
8
|
-
/(.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,?\s?\d+[–—-]\s?\d+,?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\d+)*(?:[-–—]\d?\s?)?)(?:[:.]\d+[–-—]\s?\d+,?\s?\d+)?/gim
|
|
9
|
-
const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
|
|
10
|
-
module.exports.bookRegex = bookRegex
|
|
9
|
+
/(.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,?\s?\d+[–—-]\s?\d+,?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\s?\d+)*(?:[-–—]\d?\s?)?)(?:[:.]\d+[–-—]\s?\d+,?\s?\d+)?/gim
|
|
10
|
+
const scripturesRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})(${chapterVerseRange.source})`, "gmi")
|
|
11
|
+
module.exports.bookRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})`, "gmi") // bookRegex
|
|
11
12
|
module.exports.chapterRegex = chapterRegex
|
|
12
13
|
module.exports.scripturesRegex = scripturesRegex
|
|
13
14
|
module.exports.verseRegex = verseRegex
|