codexparser 0.0.3 → 0.0.6

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.0.3",
3
+ "version": "0.0.6",
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": {
@@ -1,5 +1,6 @@
1
1
  const bible = require("./bible")
2
2
  const { bookRegex, bookAbbrRegex, chapterRegex, verseRegex, scripturesRegex, abbrScripturesRegex } = require("./regex")
3
+ const abbrevations = require("./abbr")
3
4
 
4
5
  class CodexParser {
5
6
  constructor() {
@@ -12,6 +13,7 @@ class CodexParser {
12
13
  this.verseRegex = verseRegex
13
14
  this.scripturesRegex = scripturesRegex
14
15
  this.abbrScripturesRegex = abbrScripturesRegex
16
+ this.abbrevations = abbrevations
15
17
  }
16
18
 
17
19
  /**
@@ -55,17 +57,22 @@ class CodexParser {
55
57
  }
56
58
  bookify(book) {
57
59
  let bookified
58
- bookified = this.bible.new.find(
59
- (b) =>
60
- b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
61
- b.toLowerCase().includes(book.toLowerCase())
62
- )
60
+
61
+ bookified = this.abbrevations[book]
62
+
63
63
  if (!bookified) {
64
- bookified = this.bible.old.find(
64
+ bookified = this.bible.new.find(
65
65
  (b) =>
66
66
  b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
67
67
  b.toLowerCase().includes(book.toLowerCase())
68
68
  )
69
+ if (!bookified) {
70
+ bookified = this.bible.old.find(
71
+ (b) =>
72
+ b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
73
+ b.toLowerCase().includes(book.toLowerCase())
74
+ )
75
+ }
69
76
  }
70
77
  return bookified
71
78
  }
package/src/abbr.js ADDED
@@ -0,0 +1,276 @@
1
+ const abbrevations = {
2
+ Gen: "Genesis",
3
+ Ge: "Genesis",
4
+ Gn: "Genesis",
5
+ Ex: "Exodus",
6
+ Exo: "Exodus",
7
+ Exod: "Exodus",
8
+ Lev: "Leviticus",
9
+ Le: "Leviticus",
10
+ Lv: "Leviticus",
11
+ Num: "Numbers",
12
+ Nu: "Numbers",
13
+ Nb: "Numbers",
14
+ Nm: "Numbers",
15
+ Deut: "Deuteronomy",
16
+ De: "Deuteronomy",
17
+ Dt: "Deuteronomy",
18
+ Josh: "Joshua",
19
+ Jos: "Joshua",
20
+ Jsh: "Joshua",
21
+ Judg: "Judges",
22
+ Jdg: "Judges",
23
+ Jg: "Judges",
24
+ Jdg: "Judges",
25
+ Ruth: "Ruth",
26
+ Rth: "Ruth",
27
+ Ru: "Ruth",
28
+ "1Sam": "1 Samuel",
29
+ "1Sam": "1 Samuel",
30
+ "1Sa": "1 Samuel",
31
+ "1S": "1 Samuel",
32
+ "1 Sam": "1 Samuel",
33
+ "1 Sm": "1 Samuel",
34
+ "1 Sa": "1 Samuel",
35
+ "1 S": "1 Samuel",
36
+ "2 Sam": "2 Samuel",
37
+ "2 Sm": "2 Samuel",
38
+ "2 Sa": "2 Samuel",
39
+ "2 S": "2 Samuel",
40
+ "II Sam": "2 Samuel",
41
+ "II Sa": "2 Samuel",
42
+ "2Sam": "2 Samuel",
43
+ "2Sm": "2 Samuel",
44
+ "2Sa": "2 Samuel",
45
+ "2S": "2 Samuel",
46
+ "1Kgs": "1 Kings",
47
+ "1 Kgs": "1 Kings",
48
+ "1Kgs": "1 Kings",
49
+ "1 Ki": "1 Kings",
50
+ "1Ki": "1 Kings",
51
+ "1Kin": "1 Kings",
52
+ "1 Kin": "1 Kings",
53
+ "1 Ki": "1 Kings",
54
+ "1K": "1 Kings",
55
+ "1 K": "1 Kings",
56
+ "2 Kgs": "2 Kings",
57
+ "2 Ki": "2 Kings",
58
+ "2Kgs": "2 Kings",
59
+ "2Kin": "2 Kings",
60
+ "2Ki": "2 Kings",
61
+ "2K": "2 Kings",
62
+ "2 K": "2 Kings",
63
+ "1 Chron": "1 Chronicles",
64
+ "1 Chr": "1 Chronicles",
65
+ "1 Ch": "1 Chronicles",
66
+ "1Chron": "1 Chronicles",
67
+ "1Chr": "1 Chronicles",
68
+ "1Ch": "1 Chronicles",
69
+ "I Chron": "1 Chronicles",
70
+ "I Chr": "1 Chronicles",
71
+ "I Ch": "1 Chronicles",
72
+ "1st Chron": "1 Chronicles",
73
+ "2 Chron": "2 Chronicles",
74
+ "2 Chr": "2 Chronicles",
75
+ "2 Ch": "2 Chronicles",
76
+ "2Chron": "2 Chronicles",
77
+ "2Chr": "2 Chronicles",
78
+ "2Ch": "2 Chronicles",
79
+ "II Chron": "2 Chronicles",
80
+ "II Chr": "2 Chronicles",
81
+ "II Ch": "2 Chronicles",
82
+ Ezra: "Ezra",
83
+ Ezr: "Ezra",
84
+ Ez: "Ezra",
85
+ Neh: "Nehemiah",
86
+ Ne: "Nehemiah",
87
+ Esth: "Esther",
88
+ Est: "Esther",
89
+ Es: "Esther",
90
+ Job: "Job",
91
+ Jb: "Job",
92
+ Ps: "Psalms",
93
+ Psalm: "Psalms",
94
+ Pslm: "Psalms",
95
+ Psa: "Psalms",
96
+ Psm: "Psalms",
97
+ Pss: "Psalms",
98
+ Prov: "Proverbs",
99
+ Pro: "Proverbs",
100
+ Prv: "Proverbs",
101
+ Pr: "Proverbs",
102
+ Eccl: "Ecclesiastes",
103
+ Eccles: "Ecclesiastes",
104
+ Eccle: "Ecclesiastes",
105
+ Ecc: "Ecclesiastes",
106
+ Ec: "Ecclesiastes",
107
+ Qoh: "Ecclesiastes",
108
+ Song: "Song of Songs",
109
+ SOS: "Song of Songs",
110
+ So: "Song of Songs",
111
+ Cant: "Song of Songs",
112
+ Isa: "Isaiah",
113
+ Is: "Isaiah",
114
+ Jer: "Jeremiah",
115
+ Je: "Jeremiah",
116
+ Lam: "Lamentations",
117
+ La: "Lamentations",
118
+ Ezek: "Ezekiel",
119
+ Eze: "Ezekiel",
120
+ Ezk: "Ezekiel",
121
+ Dan: "Daniel",
122
+ Da: "Daniel",
123
+ Dn: "Daniel",
124
+ Hos: "Hosea",
125
+ Ho: "Hosea",
126
+ Joel: "Joel",
127
+ Jl: "Joel",
128
+ Amos: "Amos",
129
+ Am: "Amos",
130
+ Ob: "Obadiah",
131
+ Obad: "Obadiah",
132
+ Jonah: "Jonah",
133
+ Jnh: "Jonah",
134
+ Jon: "Jonah",
135
+ Mic: "Micah",
136
+ Mc: "Micah",
137
+ Nah: "Nahum",
138
+ Na: "Nahum",
139
+ Hb: "Habakkuk",
140
+ Hab: "Habakkuk",
141
+ Zeph: "Zephaniah",
142
+ Zep: "Zephaniah",
143
+ Zp: "Zephaniah",
144
+ Hag: "Haggai",
145
+ Hg: "Haggai",
146
+ Zech: "Zechariah",
147
+ Zec: "Zechariah",
148
+ Zc: "Zechariah",
149
+ Mal: "Malachi",
150
+ Ml: "Malachi",
151
+ Matt: "Matthew",
152
+ Mt: "Matthew",
153
+ Mark: "Mark",
154
+ Mrk: "Mark",
155
+ Mar: "Mark",
156
+ Mk: "Mark",
157
+ Mr: "Mark",
158
+ Luke: "Luke",
159
+ Luk: "Luke",
160
+ Lk: "Luke",
161
+ John: "John",
162
+ Joh: "John",
163
+ Jhn: "John",
164
+ Jn: "John",
165
+ Acts: "Acts",
166
+ Act: "Acts",
167
+ Ac: "Acts",
168
+ Rom: "Romans",
169
+ Ro: "Romans",
170
+ Rm: "Romans",
171
+ "1Cor": "1 Corinthians",
172
+ "1 Cor": "1 Corinthians",
173
+ "1 Co": "1 Corinthians",
174
+ "1 Cor": "1 Corinthians",
175
+ "1 Co": "1 Corinthians",
176
+ "1Co": "1 Corinthians",
177
+ "2Cor": "2 Corinthians",
178
+ "2 Cor": "2 Corinthians",
179
+ "2 Co": "2 Corinthians",
180
+ "2Co": "2 Corinthians",
181
+ "2Cor": "2 Corinthians",
182
+ "2 Cor": "2 Corinthians",
183
+ Gal: "Galatians",
184
+ Ga: "Galatians",
185
+ Eph: "Ephesians",
186
+ Ephes: "Ephesians",
187
+ Phil: "Philippians",
188
+ Php: "Philippians",
189
+ Pp: "Philippians",
190
+ Col: "Colossians",
191
+ Co: "Colossians",
192
+ "1Thess": "1 Thessalonians",
193
+ "1 Thess": "1 Thessalonians",
194
+ "1 Th": "1 Thessalonians",
195
+ "1Th": "1 Thessalonians",
196
+ "2Thess": "2 Thessalonians",
197
+ "2 Thess": "2 Thessalonians",
198
+ "2 Th": "2 Thessalonians",
199
+ "2Th": "2 Thessalonians",
200
+ "2Thess": "2 Thessalonians",
201
+ "1Tim": "1 Timothy",
202
+ "1 Ti": "1 Timothy",
203
+ "1 Ti": "1 Timothy",
204
+ "1Tim": "1 Timothy",
205
+ "2Tim": "2 Timothy",
206
+ "2 Ti": "2 Timothy",
207
+ "2 Ti": "2 Timothy",
208
+ "2Tim": "2 Timothy",
209
+ Titus: "Titus",
210
+ Tt: "Titus",
211
+ Tit: "Titus",
212
+ Ti: "Titus",
213
+ Phlm: "Philemon",
214
+ Phm: "Philemon",
215
+ Phile: "Philemon",
216
+ Ph: "Philemon",
217
+ Hebr: "Hebrews",
218
+ Heb: "Hebrews",
219
+ He: "Hebrews",
220
+ Jas: "James",
221
+ Jm: "James",
222
+ James: "James",
223
+ "1Pet": "1 Peter",
224
+ "1 Pe": "1 Peter",
225
+ "1 Pe": "1 Peter",
226
+ "1Pet": "1 Peter",
227
+ "2Pet": "2 Peter",
228
+ "2 Pe": "2 Peter",
229
+ "2 Pe": "2 Peter",
230
+ "2Pet": "2 Peter",
231
+ "1John": "1 John",
232
+ "1 Jo": "1 John",
233
+ "1 Jo": "1 John",
234
+ "1John": "1 John",
235
+ "2John": "2 John",
236
+ "2 Jo": "2 John",
237
+ "2 Jo": "2 John",
238
+ "2John": "2 John",
239
+ "2 John": "2 John",
240
+ "3John": "3 John",
241
+ "3 John": "3 John",
242
+ Jude: "Jude",
243
+ Jud: "Jude",
244
+ Jd: "Jude",
245
+ Rev: "Revelation",
246
+ Re: "Revelation",
247
+ Mt: "Matthew",
248
+ Mc: "Mark",
249
+ L: "Luke",
250
+ J: "John",
251
+ Act: "Acts",
252
+ R: "Romans",
253
+ "1K": "1 Corinthians",
254
+ "2K": "2 Corinthians",
255
+ G: "Galatians",
256
+ E: "Ephesians",
257
+ Ph: "Philippians",
258
+ Kol: "Colossians",
259
+ "1Th": "1 Thessalonians",
260
+ "2Th": "2 Thessalonians",
261
+ "1T": "1 Timothy",
262
+ "2T": "2 Timothy",
263
+ Tt: "Titus",
264
+ Phm: "Philemon",
265
+ H: "Hebrews",
266
+ Jc: "James",
267
+ "1P": "1 Peter",
268
+ "2P": "2 Peter",
269
+ "1J": "1 John",
270
+ "2J": "2 John",
271
+ "3J": "3 John",
272
+ Jd: "Jude",
273
+ Ap: "Revelation",
274
+ }
275
+
276
+ module.exports = abbrevations
package/src/regex.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const bookRegex =
2
- /(?:(?:[gG]e(?:[a-zA-Z])?|[eE]x(?:[a-zA-Z])?|[lL]e(?:[a-zA-Z])?|[nN]u(?:[a-zA-Z])?|[dD]e(?:[a-zA-Z])?|[jJ]o(?:[a-zA-Z])?|[jJ]u(?:[a-zA-Z])?|[rR]u(?:[a-zA-Z])?|1 [sS](?:[a-zA-Z])?|2 [sS](?:[a-zA-Z])?|1 [kK](?:[a-zA-Z])?|2 [kK](?:[a-zA-Z])?|1 [cC]hr(?:[a-zA-Z])?|2 [cC]hr(?:[a-zA-Z])?|[eE]z(?:[a-zA-Z])?|[nN]e(?:[a-zA-Z])?|[eE]s(?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[pP]s(?:[a-zA-Z])?|[pP]r(?:[a-zA-Z])?|[eE]cc(?:[a-zA-Z])?|[sS]o(?:[a-zA-Z])?|[iI]s(?:[a-zA-Z])?|[jJ]e(?:[a-zA-Z])?|[lL]a(?:[a-zA-Z])?|[eE]z(?:[a-zA-Z])?|[dD](?:[a-zA-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|[jJ]dg|[rR]ut|1 [sS]a|2 [sS]a|1 [kK]gs|2 [kK]gs|1 [cC]hr|2 [cC]hr|[eE]zr|[nN]eh|[eE]st|[jJ]ob|[pP]sa|[pP]ro|[eE]cc|[sS]on|[iI]sa|[jJ]er|[lL]am|[eE]ze|[dD]an|[hH]os|[jJ]oe|[aA]mo|[oO]ba|[jJ]on|[mM]ic|[nN]ah|[hH]ab|[zZ]ep|[hH]ag|[zZ]ec|[mM]al|[mM]att|[mM]ar|[lL]uk|[jJ]oh|[aA]ct|[rR]om|1 [cC]or|2 [cC]or|[gG]al|[eE]ph|[pP]hi|[cC]ol|1 [tT]hess|2 [tT]hess|1 [tT]i|2 [tT]i|[tT]it|[pP]hm|[hH]eb|[jJ]am|1 [pP]e|2 [pP]e|1 [jJ]o|2 [jJ]o|3 [jJ]o|[jJ]ud|[rR]ev))/gim
5
5
  const chapterRegex = /(?:\s?\d+:?)/g
package/test.js CHANGED
@@ -3,7 +3,7 @@ const CodexParser = require("./src/CodexParser.js")
3
3
  const parser = new CodexParser()
4
4
  const text =
5
5
  "The passages that we are looking at tonight are found in 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles."
6
- const single = "Ju 2.9"
6
+ const single = "Mt 2.9"
7
7
  parser.parse(single)
8
8
  //parser.parse(single)
9
9
  console.log(parser.getPassages())