codexparser 0.0.37 → 0.0.39
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/all-scripture-test.js +1 -0
- package/bcv_test.js +2 -2
- package/package.json +7 -2
- package/src/CodexParser.js +15 -3
- package/src/regex.js +1 -1
- package/sub-verse-scripture-test.js +3 -3
package/all-scripture-test.js
CHANGED
|
@@ -7,4 +7,5 @@ const single = "Ge 27.27-29,32-40 Heb 11.20 Heb. 12.17 Jonah 3"
|
|
|
7
7
|
const jd = "Jd. 5"
|
|
8
8
|
const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3"
|
|
9
9
|
const passages = parser.parse(single + " " + text + " " + jd + " " + cor)
|
|
10
|
+
console.log(passages.getPassages())
|
|
10
11
|
//const passages = parser.parse('Romans 8:9,12,15,17,20,28')
|
package/bcv_test.js
CHANGED
|
@@ -3,10 +3,10 @@ const text =
|
|
|
3
3
|
"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
4
|
const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
|
|
5
5
|
const jd = "Jd. 5"
|
|
6
|
-
const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3"
|
|
6
|
+
const cor = "Hos 1:1-3, 8 Song of Solomon 1:2, Song of Songs 2:2. Ezek 17:3. Ezekiel 17:3 He 10:13"
|
|
7
7
|
|
|
8
8
|
const parser = new bcv_parser()
|
|
9
|
-
const textParser = parser.parse(text + single + jd + cor)
|
|
9
|
+
const textParser = parser.parse(text + single + jd + cor.replace(/He/, "Hebrews"))
|
|
10
10
|
const passages = textParser.parsed_entities()
|
|
11
11
|
|
|
12
12
|
passages.forEach((passage) => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
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": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"
|
|
8
|
+
"webpack": "webpack --mode=production",
|
|
9
|
+
"build": "browserify src/CodexParser.js -t | uglifyjs > dist/CodexParser.js"
|
|
9
10
|
},
|
|
10
11
|
"author": "Jeremy Menicucci",
|
|
11
12
|
"license": "ISC",
|
|
@@ -16,8 +17,12 @@
|
|
|
16
17
|
"@babel/preset-react": "^7.23.3",
|
|
17
18
|
"axios": "^1.7.2",
|
|
18
19
|
"babel-loader": "^9.1.3",
|
|
20
|
+
"browserify": "^17.0.0",
|
|
21
|
+
"fs": "^0.0.1-security",
|
|
19
22
|
"glob": "^10.4.1",
|
|
20
23
|
"path": "^0.12.7",
|
|
24
|
+
"uglify-es": "^3.3.9",
|
|
25
|
+
"uglifyify": "^5.0.2",
|
|
21
26
|
"webpack": "^5.90.3",
|
|
22
27
|
"webpack-cli": "^5.1.4"
|
|
23
28
|
},
|
package/src/CodexParser.js
CHANGED
|
@@ -27,8 +27,19 @@ 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)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
for(let i = 0; i < matches.length; i++) {
|
|
38
|
+
const match = matches[i]
|
|
39
|
+
text = text.replace(match.abbr, match.book)
|
|
40
|
+
}
|
|
30
41
|
const passages = this.crawler.parse(text).parsed_entities()
|
|
31
|
-
this.found.push(...passages.flatMap((passage) => passage.entities))
|
|
42
|
+
this.found.push(...passages.flatMap((passage) => passage.entities))
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
/**
|
|
@@ -49,8 +60,7 @@ class CodexParser {
|
|
|
49
60
|
}
|
|
50
61
|
const uniqueBooks = [...new Set(books)]
|
|
51
62
|
const booksWithResults = []
|
|
52
|
-
|
|
53
|
-
// in order to be able to identify if comma separated verses goes with it or not.
|
|
63
|
+
|
|
54
64
|
for (const book of uniqueBooks) {
|
|
55
65
|
const found = this.found.filter((passage) => passage.start.b === book)
|
|
56
66
|
booksWithResults.push(found)
|
|
@@ -129,9 +139,11 @@ class CodexParser {
|
|
|
129
139
|
subPassage.verses =
|
|
130
140
|
passage.start.v !== passage.end.v ? [passage.start.v, passage.end.v] : [passage.start.v]
|
|
131
141
|
}
|
|
142
|
+
subPassage.testament = this.bible.old.includes(subPassage.book) ? "old" : "new"
|
|
132
143
|
this.passages.push(subPassage)
|
|
133
144
|
}
|
|
134
145
|
}
|
|
146
|
+
firstPassage.testament = this.bible.old.includes(firstPassage.book) ? "old" : "new"
|
|
135
147
|
this.passages.push(firstPassage)
|
|
136
148
|
//console.log(this.passages)
|
|
137
149
|
}
|
package/src/regex.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const bookRegex = /((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|
|
|
1
|
+
const bookRegex = /((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|Ez|Neh|Ne|Esth|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|Mrk|Mk|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Phil|Php|Col|Col|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Hebrews|Heb|He|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
|
|
2
2
|
const chapterRegex = /\b(?:\.?\s?\d+[:|\.]?)\b/gm
|
|
3
3
|
const verseRegex = /\b[:.].+\b/gm
|
|
4
4
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const CodexParser = require("./src/CodexParser.js")
|
|
2
2
|
|
|
3
3
|
const parser = new CodexParser()
|
|
4
|
-
const scripture = "
|
|
5
|
-
|
|
6
|
-
|
|
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())
|