codexparser 0.0.20 → 0.0.22

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.
@@ -0,0 +1,8 @@
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
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
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": {
@@ -50,6 +50,7 @@ class CodexParser {
50
50
  for (let i = 0; i < this.found.length; i++) {
51
51
  const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
52
52
  const book = this.found[i].match(this.bookRegex)
53
+ if(book === null) continue
53
54
  let verse,
54
55
  chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
55
56
  if (this.found[i].match(this.verseRegex))
package/src/regex.js CHANGED
@@ -1,14 +1,13 @@
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\s?[sS](?:[a-zA-Z]+)?|2\s?[sS](?:[a-zA-Z]+)?|1\s?[kK](?:[a-zA-Z]+)?|2\s?[kK](?:[a-zA-Z]+)?|1\s?[cC]hr(?:[a-zA-Z]+)?|2\s?[cC]hr(?:[a-zA-Z]+)?|[eE]z(?:[a-zA-Z]+)?|[nN]e(?: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|[jJ](?:[d|ude]+)?|[Rr|Aa](?:[a-zA-Z]+)?))/gim
1
+ const bookRegex = /(?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Ge|Gn|Exo|Ex|Exod|Lev|Le|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Kin|Chron|Chronicles|Ezra|Ezr|Ez|Neh|Ne|Esth|Es|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|Mt|Mrk|Mk|Mr|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Phil|Php|Col|Col|Th|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Hebrews|Heb|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|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap)/gmi
3
2
  const chapterRegex = /\b(?:\.?\s?\d+[:|\.]?)\b/gm
4
3
  const verseRegex = /\b[:.](\d+(?:,?\s*?\d+?|-|–|—\d+)*)?\d+\b/gm
5
- const chapterRange = /\s?(?:[-|—|–])\s?/gm
6
- const chapterRangeVerseRegex = /.\d+/gm
7
- const scripturesRegex = new RegExp(
8
- `(${bookRegex.source})(${chapterRegex.source})?(${verseRegex.source})(${chapterRange.source}?)?(${chapterRangeVerseRegex.source})?(${chapterRegex.source})?(${chapterRangeVerseRegex.source})?`,
9
- "gmi"
10
- )
4
+ const chapterRange = /.?\s?(?:[-—–])\s?/gm
5
+ const chapterRangeVerseRegex = /(?:.\d+)?/gm
6
+ const chapterVerseRange =
7
+ /.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s\d+)*)?\S([:.]?\d+)?(,\s?\d+[–—-]\s?\d+)?)?(?:[:.]\d+)?/gim
8
+ const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
11
9
 
10
+ console.log(scripturesRegex)
12
11
  module.exports.bookRegex = bookRegex
13
12
  module.exports.chapterRegex = chapterRegex
14
13
  module.exports.scripturesRegex = scripturesRegex
package/test.js CHANGED
@@ -2,13 +2,15 @@ const CodexParser = require("./src/CodexParser.js")
2
2
 
3
3
  const parser = new CodexParser()
4
4
  const text =
5
- "The passages that we are looking at tonight 1 Cor 12:34 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."
6
- const single = "Ge 27.27-29,89-40 Heb 11.20"
5
+ "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."
6
+ const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17"
7
7
  const jd = "Jd. 5"
8
- /* const passages = parser.parse(single)
9
- console.log(passages) */
10
- const textParser = parser.parse(text)
11
- console.log(textParser)
12
- /*
8
+ const cor = "1 Cor 12:34 2 Cor 3:4"
9
+ const passages = parser.parse(single)
10
+ console.log(passages)
11
+ const fullText = parser.parse(text)
12
+ console.log(fullText)
13
13
  const jude = parser.parse(jd)
14
- console.log(jude) */
14
+ console.log(jude)
15
+ const textParser = parser.parse(cor)
16
+ console.log(textParser)