codexparser 0.0.69 → 0.0.71
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/bcv_test.js +1 -1
- package/mcleanTest.js +14 -0
- package/package.json +1 -1
- package/src/CodexParser.js +26 -13
- package/src/regex.js +1 -1
- package/sub-verse-scripture-test.js +1 -1
package/bcv_test.js
CHANGED
|
@@ -6,7 +6,7 @@ const jd = "Jd. 5"
|
|
|
6
6
|
const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3 He 10:13 Rev 12:13"
|
|
7
7
|
|
|
8
8
|
const parser = new bcv_parser()
|
|
9
|
-
const textParser = parser.parse(
|
|
9
|
+
const textParser = parser.parse("Gen 13:14-16 Clement of Letter to the Romanse, Letter to the Corinthians [51; 77; 111] 10:4-5; Jubilees [14; 43; 46; 118; 175; 179] 13:19-20; Genesis Apocryphon 21:8-10, 13 // Gen 13:15 Gal 3:16; Pseudo-Philo 8:3 Allusions - Jub 19:21-22; QapGn 21:8-10 // Gen 13:15 - Ac 7:5")
|
|
10
10
|
const passages = textParser.parsed_entities()
|
|
11
11
|
|
|
12
12
|
passages.forEach((passage) => {
|
package/mcleanTest.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const BibleParser = require("./src/CodexParser.js")
|
|
2
|
+
const util = require("util")
|
|
3
|
+
|
|
4
|
+
const dump = (item) => {
|
|
5
|
+
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const parser = new BibleParser()
|
|
9
|
+
|
|
10
|
+
const text =
|
|
11
|
+
"Gen 1:1 - Jos Ant 1:27; Just Apol 1:59, 64; Mel Pasc 47; Ph Aet 19; Her 122; Opif 26-27; Theoph 2.10 Allusions Jn 1:1; Heb 11:3; DialSav 127:20; 4Ez 6:38; Mel Pasc 104; Ph QuGen 4:215; Opif 29; Mos 2:266; Plant 86; Praem 1; Sacrif 8; PrMan 2; Prov 8:22; Tat 5"
|
|
12
|
+
|
|
13
|
+
parser.find(text)
|
|
14
|
+
dump(parser.getPassages())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.71",
|
|
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/src/CodexParser.js
CHANGED
|
@@ -91,6 +91,16 @@ class CodexParser {
|
|
|
91
91
|
this.scan(reference)
|
|
92
92
|
for (let i = 0; i < this.found.length; i++) {
|
|
93
93
|
const result = this.found[i]
|
|
94
|
+
if (result.type === "range" && result.start.b !== result.end.b) {
|
|
95
|
+
console.log("=================")
|
|
96
|
+
const newPassageFound = result.end.b + " " + result.end.c + ":" + result.end.v
|
|
97
|
+
const newPassageToAdd = this.crawler.parse(newPassageFound).parsed_entities()[0].entities
|
|
98
|
+
this.found.splice(i + 1, 0, ...newPassageToAdd)
|
|
99
|
+
result.end.b = result.start.b
|
|
100
|
+
result.end.c = result.start.c
|
|
101
|
+
result.end.v = result.start.v
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
const passage = {
|
|
95
105
|
book: this.bookify(result.start.b),
|
|
96
106
|
chapter: result.start.c,
|
|
@@ -113,7 +123,7 @@ class CodexParser {
|
|
|
113
123
|
next = this.found[i + 1]
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
|
-
if (passage.type === "range") {
|
|
126
|
+
if (passage.type === "range" && passage.book === result.end.b) {
|
|
117
127
|
if (result.start.c !== result.end.c) {
|
|
118
128
|
passage.verses = [result.start.v]
|
|
119
129
|
passage.to = {
|
|
@@ -146,7 +156,11 @@ class CodexParser {
|
|
|
146
156
|
versify(passage) {
|
|
147
157
|
if (passage.start.v !== passage.end.v) {
|
|
148
158
|
if (passage.type === "range") {
|
|
149
|
-
|
|
159
|
+
if (passage.start.b === passage.end.b) {
|
|
160
|
+
return [`${passage.start.v}-${passage.end.v}`]
|
|
161
|
+
} else {
|
|
162
|
+
return [passage.start.v]
|
|
163
|
+
}
|
|
150
164
|
} else {
|
|
151
165
|
if (passage.type !== "bc") {
|
|
152
166
|
const verses = []
|
|
@@ -215,16 +229,15 @@ class CodexParser {
|
|
|
215
229
|
.trim()
|
|
216
230
|
}
|
|
217
231
|
find(text) {
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
const passages = []
|
|
232
|
+
const bookNames = this.bookRegex.toString().split("|").slice(8)
|
|
233
|
+
const books = [...this.bible.old, ...this.bible.new, ...bookNames]
|
|
221
234
|
for (let i = 0; i < books.length; i++) {
|
|
222
235
|
const book = books[i].toLowerCase()
|
|
223
236
|
const index = text.toLowerCase().indexOf(book)
|
|
224
237
|
// Checks to see if the previous character is a colon. If it is, skip.
|
|
225
238
|
// This makes sure that if you have a case like Genesis 1:1 John 1:1, the code knows that
|
|
226
239
|
// the book cannot be 1 John.
|
|
227
|
-
if (text[index - 1] && text[index - 1].includes(":")) continue
|
|
240
|
+
if (text[index - 1] && text[index - 1].includes(":") && text[index - 1].match(/[a-zA-Z]/)) continue
|
|
228
241
|
|
|
229
242
|
// Get the book and chapter
|
|
230
243
|
if (index > -1) {
|
|
@@ -236,10 +249,10 @@ class CodexParser {
|
|
|
236
249
|
let chapterStartIndex = null
|
|
237
250
|
let chapterEndIndex = null
|
|
238
251
|
let j = bookEndIndex + 1
|
|
239
|
-
while (j < text.length) {
|
|
252
|
+
while (j < text.length && !text[j].match(/[a-zA-Z]/)) {
|
|
240
253
|
const match = text.substring(j).match(/^\s*(\d+)/)
|
|
241
254
|
if (match) {
|
|
242
|
-
chapter = match[1]
|
|
255
|
+
chapter = parseInt(match[1])
|
|
243
256
|
chapterStartIndex = j
|
|
244
257
|
chapterEndIndex = j + match[0].length
|
|
245
258
|
break
|
|
@@ -251,9 +264,8 @@ class CodexParser {
|
|
|
251
264
|
let verseStartIndex = null
|
|
252
265
|
let verseEndIndex = null
|
|
253
266
|
let verse
|
|
254
|
-
while (verseIndex < text.length) {
|
|
267
|
+
while (verseIndex < text.length && !text[verseIndex].match(/[a-zA-Z]/)) {
|
|
255
268
|
const match = text.substring(verseIndex).match(/^\s*?(\d+)[^a-zA-Z]*/)
|
|
256
|
-
|
|
257
269
|
if (match) {
|
|
258
270
|
verseStartIndex = verseIndex
|
|
259
271
|
verseEndIndex = verseIndex + match[0].length
|
|
@@ -269,14 +281,15 @@ class CodexParser {
|
|
|
269
281
|
passage.index = {
|
|
270
282
|
start: index,
|
|
271
283
|
}
|
|
272
|
-
|
|
284
|
+
this.passages.push(passage)
|
|
273
285
|
}
|
|
274
286
|
}
|
|
275
|
-
return
|
|
287
|
+
return this
|
|
276
288
|
}
|
|
277
289
|
|
|
278
290
|
regex(text) {
|
|
279
291
|
this.found = text.match(this.scripturesRegex)
|
|
292
|
+
console.log(this.found)
|
|
280
293
|
return this
|
|
281
294
|
}
|
|
282
295
|
|
|
@@ -339,7 +352,7 @@ class CodexParser {
|
|
|
339
352
|
this.passages.push(passage)
|
|
340
353
|
}
|
|
341
354
|
|
|
342
|
-
this.found =
|
|
355
|
+
this.found = this.passages.map((passage) => passage.scripture)
|
|
343
356
|
return this
|
|
344
357
|
}
|
|
345
358
|
}
|
package/src/regex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const bookRegex =
|
|
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|
|
|
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|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
3
|
const EzraAbbrv = /(Ez)(?![a-zA-Z])/gim
|
|
4
4
|
const chapterRegex = /(\d+)(?=[:.])/gim
|
|
5
5
|
const verseRegex = /(?<=[:.])[\d: .\-]+(?:, ?[\d\-]+)*(?<![ .])/gim
|
|
@@ -11,5 +11,5 @@ parser.options({
|
|
|
11
11
|
invalid_sequence_strategy: "include",
|
|
12
12
|
single_chapter_1_strategy: "verse",
|
|
13
13
|
})
|
|
14
|
-
const result = parser.parse("
|
|
14
|
+
const result = parser.parse("Gen 13:14-16 Clement of Letter to the Romanse, Letter to the Corinthians [51; 77; 111] 10:4-5; Jubilees [14; 43; 46; 118; 175; 179] 13:19-20; Genesis Apocryphon 21:8-10, 13 // Gen 13:15 Gal 3:16; Pseudo-Philo 8:3 Allusions - Jub 19:21-22; QapGn 21:8-10 // Gen 13:15 - Ac 7:5")
|
|
15
15
|
dump(result.getPassages())
|