codexparser 0.0.3 → 0.0.5

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.5",
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,209 @@
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
+ Mark: "Mark",
153
+ Luke: "Luke",
154
+ John: "John",
155
+ Acts: "Acts",
156
+ Act: "Acts",
157
+ Rom: "Romans",
158
+ R: "Romans",
159
+ "1Cor": "1 Corinthians",
160
+ "2Cor": "2 Corinthians",
161
+ Gal: "Galatians",
162
+ Eph: "Ephesians",
163
+ Phil: "Philippians",
164
+ Col: "Colossians",
165
+ "1Thess": "1 Thessalonians",
166
+ "2Thess": "2 Thessalonians",
167
+ "1Tim": "1 Timothy",
168
+ "2Tim": "2 Timothy",
169
+ Titus: "Titus",
170
+ Phlm: "Philemon",
171
+ Heb: "Hebrews",
172
+ Jas: "James",
173
+ "1Pet": "1 Peter",
174
+ "2Pet": "2 Peter",
175
+ "1John": "1 John",
176
+ "2John": "2 John",
177
+ "3John": "3 John",
178
+ Jude: "Jude",
179
+ Rev: "Revelation",
180
+ Mt: "Matthew",
181
+ Mc: "Mark",
182
+ L: "Luke",
183
+ J: "John",
184
+ Act: "Acts",
185
+ R: "Romans",
186
+ "1K": "1 Corinthians",
187
+ "2K": "2 Corinthians",
188
+ G: "Galatians",
189
+ E: "Ephesians",
190
+ Ph: "Philippians",
191
+ Kol: "Colossians",
192
+ "1Th": "1 Thessalonians",
193
+ "2Th": "2 Thessalonians",
194
+ "1T": "1 Timothy",
195
+ "2T": "2 Timothy",
196
+ Tt: "Titus",
197
+ Phm: "Philemon",
198
+ H: "Hebrews",
199
+ Jc: "James",
200
+ "1P": "1 Peter",
201
+ "2P": "2 Peter",
202
+ "1J": "1 John",
203
+ "2J": "2 John",
204
+ "3J": "3 John",
205
+ Jd: "Jude",
206
+ Ap: "Revelation",
207
+ }
208
+
209
+ 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-Z])?|[hH]o(?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[aA](?:[a-zA-Z])?|[oO](?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[mM](?:[a-zA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P]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())