codexparser 0.1.0 → 0.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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": {
@@ -165,7 +165,7 @@ class CodexParser {
165
165
  }
166
166
 
167
167
  // Trim any period from the end of the reference
168
- chapterVerse = chapterVerse.trim().replace(/[.,:;!?]+$/, "")
168
+ chapterVerse = chapterVerse.trim().replace(/[^a-zA-Z0-9]+$/, "")
169
169
 
170
170
  // Replace any periods within the reference with colons for easier parsing
171
171
  const formattedReference = chapterVerse.replace(/\./g, ":")
@@ -272,7 +272,7 @@ class CodexParser {
272
272
  parsedPassage.to = {
273
273
  book: book,
274
274
  chapter: Number(end),
275
- verse: this.chapterVerses[book][end],
275
+ verses: this.chapterVerses[book][end],
276
276
  }
277
277
  } else {
278
278
  parsedPassage.verses.push(`${startVerse}-${end}`)
@@ -1,20 +0,0 @@
1
- const CodexParser = 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 CodexParser({
9
- invalid_sequence_strategy: "include",
10
- invalid_passage_strategy: "include",
11
- })
12
- const 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`
13
- const single = "Ge 27.27-29,39-41 Heb 11.20 Heb. 12.17 Jonah 3 "
14
- const jd = "Jd. 5"
15
- const cor = "1 Cor 12:4 2 Cor 3:4"
16
- const noSpace = "Re13.8 "
17
- const ezra = " Ez 1:3"
18
- const passages = parser.parse(text + single + jd + cor + noSpace + ezra)
19
- console.log(text + single + jd + cor + noSpace + ezra)
20
- dump(passages.getPassages())
@@ -1,8 +0,0 @@
1
- const fs = require("fs")
2
- const CodexParser = require("./src/CodexParser.js")
3
- const parser = new CodexParser()
4
- const bible = JSON.parse(fs.readFileSync("./bibles/updated_kjv.json", "utf8"))
5
-
6
- bible.books.forEach(book => {
7
- console.log(book)
8
- })
@@ -1,5 +0,0 @@
1
- const BibleParser = require("./src/CodexParser.js")
2
- const string = "Revelation 3:5; 7:14; 12:7; 13:8; 16:18; 20:1-6"
3
- const parser = new BibleParser()
4
- const passages = parser.parse(string)
5
- //console.log(passages.getPassages())
package/find-test.js DELETED
@@ -1,20 +0,0 @@
1
- const BibleParser = require("./src/CodexParser.js")
2
-
3
- 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
4
-
5
- Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
6
-
7
- Jd. 5
8
- Jd 6
9
-
10
- 1 Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
11
-
12
- Leviticus 16:6 He 5.3 He 7.27
13
-
14
- Hos 10:1-3, 8 and 1 John 2:23f
15
-
16
- exod15.18. 2 Cor 12:23 Malachi 3:32`
17
-
18
- const parser = new BibleParser()
19
- const result = parser.find("Isaiah 29:16; 45:9 // Romans 9:20").enhance()
20
- console.log(result)
package/jstester.js DELETED
@@ -1,329 +0,0 @@
1
- const BibleParser = require("./src/CodexParser.js")
2
- const parser = new BibleParser()
3
- const books = [
4
- "Gen",
5
- "Ge",
6
- "Gn",
7
- "Exo",
8
- "Ex",
9
- "Exod",
10
- "Lev",
11
- "Le",
12
- "Lv",
13
- "Num",
14
- "Nu",
15
- "Nm",
16
- "Nb",
17
- "Deut",
18
- "Dt",
19
- "Josh",
20
- "Jos",
21
- "Jsh",
22
- "Judg",
23
- "Jdg",
24
- "Jg",
25
- "Jdgs",
26
- "Rth",
27
- "Ru",
28
- "Sam",
29
- "Samuel",
30
- "Kings",
31
- "Kgs",
32
- "Kin",
33
- "Chron",
34
- "Chronicles",
35
- "Ezra",
36
- "Ezr",
37
- "Ez",
38
- "Neh",
39
- "Ne",
40
- "Esth",
41
- "Es",
42
- "Job",
43
- "Job",
44
- "Jb",
45
- "Pslm",
46
- "Ps",
47
- "Psalms",
48
- "Psa",
49
- "Psm",
50
- "Pss",
51
- "Prov",
52
- "Pr",
53
- "Prv",
54
- "Eccles",
55
- "Ec",
56
- "Song",
57
- "So",
58
- "Canticles",
59
- "Song of Songs",
60
- "SOS",
61
- "Isa",
62
- "Is",
63
- "Jer",
64
- "Je",
65
- "Jr",
66
- "Lam",
67
- "La",
68
- "Ezek",
69
- "Eze",
70
- "Ezk",
71
- "Dan",
72
- "Da",
73
- "Dn",
74
- "Hos",
75
- "Ho",
76
- "Joel",
77
- "Joe",
78
- "Jl",
79
- "Amos",
80
- "Am",
81
- "Obad",
82
- "Ob",
83
- "Jnh",
84
- "Jon",
85
- "Micah",
86
- "Mic",
87
- "Nah",
88
- "Na",
89
- "Hab",
90
- "Zeph",
91
- "Zep",
92
- "Zp",
93
- "Haggai",
94
- "Hag",
95
- "Hg",
96
- "Zech",
97
- "Zec",
98
- "Zc",
99
- "Mal",
100
- "Mal",
101
- "Ml",
102
- "Matt",
103
- "Mt",
104
- "Mrk",
105
- "Mk",
106
- "Mr",
107
- "Luk",
108
- "Lk",
109
- "John",
110
- "Jn",
111
- "Jhn",
112
- "Acts",
113
- "Ac",
114
- "Rom",
115
- "Ro",
116
- "Rm",
117
- "Co",
118
- "Cor",
119
- "Corinthians",
120
- "Gal",
121
- "Ga",
122
- "Ephes",
123
- "Eph",
124
- "Phil",
125
- "Php",
126
- "Col",
127
- "Col",
128
- "Th",
129
- "Thes",
130
- "Thess",
131
- "Thessalonians",
132
- "Ti",
133
- "Tim",
134
- "Timothy",
135
- "Titus",
136
- "Tit",
137
- "Philem",
138
- "Phm",
139
- "Hebrews",
140
- "Heb",
141
- "He",
142
- "James",
143
- "Jas",
144
- "Jm",
145
- "Pe",
146
- "Pet",
147
- "Pt",
148
- "Peter",
149
- "Jn",
150
- "Jo",
151
- "Joh",
152
- "Jhn",
153
- "John",
154
- "Jude",
155
- "Jd",
156
- "Jud",
157
- "Jud",
158
- "Rev",
159
- "The Revelation",
160
- "Genesis",
161
- "Exodus",
162
- "Leviticus",
163
- "Numbers",
164
- "Deuteronomy",
165
- "Joshua",
166
- "Judges",
167
- "Ruth",
168
- "Samuel",
169
- "Kings",
170
- "Chronicles",
171
- "Ezra",
172
- "Nehemiah",
173
- "Esther",
174
- "Job",
175
- "Psalms",
176
- "Psalm",
177
- "Proverbs",
178
- "Ecclesiastes",
179
- "Song of Solomon",
180
- "Isaiah",
181
- "Jeremiah",
182
- "Lamentations",
183
- "Ezekiel",
184
- "Daniel",
185
- "Hosea",
186
- "Joel",
187
- "Amos",
188
- "Obadiah",
189
- "Jonah",
190
- "Micah",
191
- "Nahum",
192
- "Habakkuk",
193
- "Zephaniah",
194
- "Haggai",
195
- "Zechariah",
196
- "Malachi",
197
- "Matthew",
198
- "Mark",
199
- "Luke",
200
- "John",
201
- "Acts",
202
- "Romans",
203
- "Corinthians",
204
- "Galatians",
205
- "Ephesians",
206
- "Philippians",
207
- "Colossians",
208
- "Thessalonians",
209
- "Timothy",
210
- "Titus",
211
- "Philemon",
212
- "Hebrews",
213
- "James",
214
- "Peter",
215
- "John",
216
- "Revelation",
217
- "Re",
218
- "Ap",
219
- "Jd.",
220
- "Heb.",
221
- ]
222
-
223
- const preStrings = ["III", "II", "I", "1st", "2nd", "3rd", "First", "Second", "Third", "1", "2", "3"]
224
- const preStringed = [
225
- "Sam",
226
- "Samuel",
227
- "Kings",
228
- "Kgs",
229
- "Kin",
230
- "Chron",
231
- "Chronicles",
232
- "Corinthians",
233
- "Co",
234
- "Cor",
235
- "Thessalonians",
236
- "Th",
237
- "Thes",
238
- "Thess",
239
- "Timothy",
240
- "Ti",
241
- "Tim",
242
- "Peter",
243
- "Pe",
244
- "Pet",
245
- "Pt",
246
- "John",
247
- "Jn",
248
- "Jhn",
249
- ]
250
- 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
251
-
252
- Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
253
-
254
- Jd. 5
255
- Jd 6
256
-
257
- 1 Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
258
-
259
- Leviticus 16:6 He 5.3 He 7.27
260
-
261
- Hos 10:1-3, 8 and 1 John 2:23
262
-
263
- exod15.18. 2 Cor 12:23 Malachi 3:32`
264
- //add the prestringed versions e.g. 1 Peter
265
- for (let b = 0; b < preStringed.length; b++) {
266
- for (let pre = 0; pre < preStrings.length; pre++) {
267
- books.push(preStrings[pre] + " " + preStringed[b])
268
- }
269
- }
270
- // add the book name with . at the end as this seems to be added sometimes, at least to the shortened forms
271
- const length = books.length
272
- for (let b = 0; b < length; b++) {
273
- books.push(books[b] + ".")
274
- }
275
-
276
- // sort descending - longer items first
277
- books.sort((a, b) => b.length - a.length)
278
- let booksAt = []
279
- // go thro' each book finding where it matches in text
280
- for (let b = 0; b < books.length; b++) {
281
- const book = books[b]
282
- let chNoInText = 0
283
- while (chNoInText < text.length) {
284
- let j = text.indexOf(book, chNoInText)
285
- if (j < 0) break
286
- if (j + book.length < text.length && !text.charAt(j + book.length).match(/^[a-z]+$/)) {
287
- booksAt.push([book, j])
288
- let replacement = book
289
- for (let k = 0; k < book.length; k++) {
290
- replacement = replacement.replace(book.charAt(k), "X")
291
- }
292
- text = text.replace(book, replacement) // to prevent a shorter version matching
293
- }
294
- chNoInText = j + book.length + 1
295
- }
296
- }
297
- // into ascending order of start position
298
- booksAt.sort(function (a, b) {
299
- return a[1] - b[1]
300
- })
301
- newText = ""
302
- let chNoInText = 0
303
-
304
- let passages = []
305
- for (let b = 0; b < booksAt.length; b++) {
306
- while (chNoInText < booksAt[b][1]) {
307
- //copy across characters to start of book
308
- newText += text.charAt(chNoInText)
309
- chNoInText++
310
- }
311
- newText += "<span class='passage'>" + booksAt[b][0]
312
- let passage = booksAt[b][0]
313
- chNoInText += booksAt[b][0].length //skip the 'fill-in characters
314
- for (let i = 0; i < 100; i++) {
315
- chNoInText++
316
- const nextCh = text.charAt(chNoInText)
317
- //test whether are at the end of the chapter(s) and verse(s)
318
- if (nextCh.match(/^[a-z]+$/)) break
319
- if (nextCh.match(/^[A-Z]+$/)) break
320
- newText += text.charAt(chNoInText - 1)
321
- passage += text.charAt(chNoInText - 1)
322
- }
323
- passages.push(passage.trim())
324
- newText += "</span>&nbsp;"
325
- }
326
-
327
- const found = parser.find(text)
328
-
329
-
package/mcleanTest.js DELETED
@@ -1,14 +0,0 @@
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/quicktest.js DELETED
@@ -1,5 +0,0 @@
1
- const BibleParser = require("./src/CodexParser.js")
2
- const string = "Ezra 1:20 Ezk 23:22"
3
- const parser = new BibleParser()
4
- const result = parser.parse(string)
5
- console.log(result.getPassages())
package/regex-tester.js DELETED
@@ -1,32 +0,0 @@
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
- }
7
-
8
- const parser = new CodexParser()
9
- const passage = "jer 9.24 1 cor 1.31 Jd 1"
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
11
-
12
- Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
13
-
14
- Jd. 5
15
- Jd 6
16
-
17
- 1Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
18
-
19
- Leviticus 16:6 He 5.3 He 7.27
20
-
21
- Hos 10:1-3, 8 and 1 John 2:23
22
-
23
- exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 2 Kings 4:8,17-37 Psalm 113-118`
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"
30
-
31
- parser.regex(text).regexParser()
32
- dump(parser.getPassages())
package/scan-test.js DELETED
@@ -1,10 +0,0 @@
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
- let text = `Psalm 94:4-100:6 MT`
8
- const parser = new BibleParser()
9
- const result = parser.find(text).enhance()
10
- dump(result)
@@ -1,16 +0,0 @@
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
- const string = "Malachi 3:32"
8
- const parser = new BibleParser()
9
- parser.options({
10
- invalid_passage_strategy: "include",
11
- invalid_sequence_strategy: "include",
12
- single_chapter_1_strategy: "verse",
13
- sequence_combination_strategy: "combine",
14
- })
15
- const result = parser.parse("Jude 5-7,11 Numbers 14:29-30 Genesis 19:24-25 Genesis 4:3-8 Numbers 31:16 Numbers 16:1-50")
16
- dump(result.getPassages())