codexparser 0.0.39 → 0.0.41

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.
@@ -5,7 +5,7 @@ const text =
5
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. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4"
6
6
  const single = "Ge 27.27-29,32-40 Heb 11.20 Heb. 12.17 Jonah 3"
7
7
  const jd = "Jd. 5"
8
- const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3"
8
+ const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3 He 12:13-15"
9
9
  const passages = parser.parse(single + " " + text + " " + jd + " " + cor)
10
10
  console.log(passages.getPassages())
11
11
  //const passages = parser.parse('Romans 8:9,12,15,17,20,28')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
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/quicktest.js ADDED
@@ -0,0 +1,5 @@
1
+ const BibleParser = require("./src/CodexParser.js")
2
+ const string = "He 4.4"
3
+ const parser = new BibleParser()
4
+ const result = parser.parse(string)
5
+ console.log(result.getPassages())
@@ -27,19 +27,25 @@ class CodexParser {
27
27
  * @return {array} The found passages from the text.
28
28
  */
29
29
  scan(text) {
30
- const abbrs = text.match(/(?:He)(?=.\d+)/gm)
31
- const matches = abbrs.map(string => {
32
- return {
33
- abbr: string,
34
- book: this.bookify(string)
30
+ text = text.trim()
31
+ console.log(text)
32
+ const abbrs = text.matchAll(/He(?=.\d)/gim)
33
+ if (abbrs) {
34
+ const matches = [...abbrs].map((match) => {
35
+ return {
36
+ abbr: match[0],
37
+ book: this.bookify(match[0]),
38
+ index: match.index,
39
+ }
40
+ })
41
+ console.log(matches)
42
+ for (let i = matches.length - 1; i >= 0; i--) {
43
+ const match = matches[i]
44
+ text = text.substring(0, match.index) + match.book + text.substring(match.index + match.abbr.length)
35
45
  }
36
- })
37
- for(let i = 0; i < matches.length; i++) {
38
- const match = matches[i]
39
- text = text.replace(match.abbr, match.book)
40
46
  }
41
47
  const passages = this.crawler.parse(text).parsed_entities()
42
- this.found.push(...passages.flatMap((passage) => passage.entities))
48
+ this.found.push(...passages.flatMap((passage) => passage.entities))
43
49
  }
44
50
 
45
51
  /**
package/src/regex.js CHANGED
@@ -4,7 +4,7 @@ const verseRegex = /\b[:.].+\b/gm
4
4
  const chapterRange = /.?\s?(?:[-—–])\s?/gm
5
5
  const chapterRangeVerseRegex = /(?:.\d+)?/gm
6
6
  const chapterVerseRange =
7
- /.?(?:\d+)((?:[:.])(?:(\d+)?)(?:(,\s?\d+)*)?(?:\s?[-–—]\s?\d+)?(?:,\s?\d+(?:\s?[-–—]\s?\d+)?)?(?:[:.]\d+)?)?/gim
7
+ /\.?\s(?:\d+[:.])?\d+[a-e]?(?:(?:\s?[-–—]|,)(?!\s[1-3]\s+[A-Z])\s?(?:\d+[:.])?\d+[a-e]?)*/gim
8
8
  const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
9
9
  module.exports.bookRegex = bookRegex
10
10
  module.exports.chapterRegex = chapterRegex
@@ -1,6 +1,5 @@
1
- const CodexParser = require("./src/CodexParser.js")
2
-
3
- const parser = new CodexParser()
4
- const scripture = "And then he said, turn to He 1:1-3, 8. and He doesn't like it"
5
- const result = parser.parse(`${scripture}. Please turn in your Bibles.`)
6
- console.log(result.getPassages())
1
+ const BibleParser = require("./src/CodexParser.js")
2
+ const parser = new BibleParser()
3
+ const string = "Genesis 1.1 He 4.4"
4
+ const result = parser.parse(string)
5
+ console.log(result.getPassages())