bibletools 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/bibletools.rb +209 -0
- data.tar.gz.sig +0 -0
- metadata +112 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b39f3947e9bf8e827ce070ad544f2f03a5b28e43554588ec99e6511aaf7c7109
|
4
|
+
data.tar.gz: 6d88f41a49b461adc25993c65e2abbeffc6616b9d727bab0bcc93c3570bcc824
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '09532d8e8b4d88ae66ffdcb7f62aec4c7887cb9b87497deb5b04206f6b3c5cbcbcffa618e2ded85a683a57f43907e8f5e30dcb0d62885481fc0a95540240cad6'
|
7
|
+
data.tar.gz: ec3bc05ded3b431231eaea8f2e00cde75a4da60bc8cc4fbb6fda1cd3d8312fabd1d50aa7e096742f7beb05b36e306b853b4cd92d446a9bb060333ce544614645
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/bibletools.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: bibletools.rb
|
4
|
+
|
5
|
+
require 'rexle'
|
6
|
+
require 'yawc'
|
7
|
+
require 'nokorexi'
|
8
|
+
|
9
|
+
|
10
|
+
module BibleTools
|
11
|
+
|
12
|
+
class ScraperErr < Exception
|
13
|
+
end
|
14
|
+
|
15
|
+
class Scraper
|
16
|
+
|
17
|
+
def initialize(book: 'Exodus', url: '')
|
18
|
+
|
19
|
+
raise ScraperErr, 'Please specify the URL' if url.empty?
|
20
|
+
|
21
|
+
baseurl = url
|
22
|
+
|
23
|
+
books = ["Genesis",
|
24
|
+
"Exodus",
|
25
|
+
"Leviticus",
|
26
|
+
"Numbers",
|
27
|
+
"Deuteronomy",
|
28
|
+
"Joshua",
|
29
|
+
"Judges",
|
30
|
+
"Ruth",
|
31
|
+
"1 Samuel",
|
32
|
+
"2 Samuel",
|
33
|
+
"1 Kings",
|
34
|
+
"2 Kings",
|
35
|
+
"1 Chronicles",
|
36
|
+
"2 Chronicles",
|
37
|
+
"Ezra",
|
38
|
+
"Nehemiah",
|
39
|
+
"Tobit",
|
40
|
+
"Judith",
|
41
|
+
"Esther",
|
42
|
+
"1 Maccabees",
|
43
|
+
"2 Maccabees",
|
44
|
+
"Job",
|
45
|
+
"Psalms",
|
46
|
+
"The Proverbs",
|
47
|
+
"Ecclesiastes",
|
48
|
+
"The Song of Songs",
|
49
|
+
"Wisdom",
|
50
|
+
"Ecclesiasticus / Sirach",
|
51
|
+
"Isaiah",
|
52
|
+
"Jeremiah",
|
53
|
+
"Lamentations",
|
54
|
+
"Baruch",
|
55
|
+
"Ezekiel",
|
56
|
+
"Daniel",
|
57
|
+
"Hosea",
|
58
|
+
"Joel",
|
59
|
+
"Amos",
|
60
|
+
"Obadiah",
|
61
|
+
"Jonah",
|
62
|
+
"Micah",
|
63
|
+
"Nahum",
|
64
|
+
"Habakkuk",
|
65
|
+
"Zephaniah",
|
66
|
+
"Haggai",
|
67
|
+
"Zechariah",
|
68
|
+
"Malachi",
|
69
|
+
"Matthew",
|
70
|
+
"Mark",
|
71
|
+
"Luke",
|
72
|
+
"John",
|
73
|
+
"Acts of Apostles",
|
74
|
+
"Romans",
|
75
|
+
"1 Corinthians",
|
76
|
+
"2 Corinthians",
|
77
|
+
"Galatians",
|
78
|
+
"Ephesians",
|
79
|
+
"Philippians",
|
80
|
+
"Colossians",
|
81
|
+
"1 Thessalonians",
|
82
|
+
"2 Thessalonians",
|
83
|
+
"1 Timothy",
|
84
|
+
"2 Timothy",
|
85
|
+
"Titus",
|
86
|
+
"Philemon",
|
87
|
+
"Hebrews",
|
88
|
+
"James",
|
89
|
+
"1 Peter",
|
90
|
+
"2 Peter",
|
91
|
+
"1 John",
|
92
|
+
"2 John",
|
93
|
+
"3 John",
|
94
|
+
"Jude",
|
95
|
+
"Revelation"]
|
96
|
+
|
97
|
+
id = if book.is_a? String then
|
98
|
+
(books.index(book) + 1).to_s
|
99
|
+
else
|
100
|
+
book.to_s
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
url2 = baseurl + '?id=' + id
|
106
|
+
doc = Nokorexi.new(url2).to_doc
|
107
|
+
e = doc.root.at_css('.pagination')
|
108
|
+
endchapter = e.xpath('li')[-2].text('a')
|
109
|
+
|
110
|
+
|
111
|
+
book = Rexle.new('<book/>')
|
112
|
+
|
113
|
+
(1..endchapter.to_i).each do |chp|
|
114
|
+
|
115
|
+
c = chp.to_s
|
116
|
+
puts 'reading chapter ' + c
|
117
|
+
|
118
|
+
sleep 1
|
119
|
+
url2 = baseurl + ("?id=%s&bible_chapter=%s" % [id, c])
|
120
|
+
doc = Nokorexi.new(url2).to_doc
|
121
|
+
a = doc.root.xpath('//div/p')
|
122
|
+
a2 = a.select {|e| e2 = e.element('a'); e2.attributes[:name] if e2}
|
123
|
+
|
124
|
+
chapter = Rexle::Element.new('chapter', attributes: {no: c})
|
125
|
+
|
126
|
+
a2.each.with_index do |e, i|
|
127
|
+
|
128
|
+
puts 'processing verse ' + i.to_s
|
129
|
+
txt = e.plaintext
|
130
|
+
n = txt.slice!(0,2).to_i.to_s
|
131
|
+
chapter.add Rexle::Element.new('verse', attributes: {no: n}).add_text(txt)
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
book.root.add chapter
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
@doc = book
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
def to_doc
|
144
|
+
@doc
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
class Analyse
|
150
|
+
|
151
|
+
def initialize(bible_obj, debug: false)
|
152
|
+
|
153
|
+
@debug = debug
|
154
|
+
|
155
|
+
if bible_obj then
|
156
|
+
@doc = bible_obj.to_doc
|
157
|
+
@verses = @doc.root.xpath('chapter/verse')
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
def wordtally()
|
163
|
+
|
164
|
+
return unless @doc
|
165
|
+
Yawc.new(@doc.root.plaintext).to_h
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
alias words wordtally
|
170
|
+
|
171
|
+
def read(chapter, verse)
|
172
|
+
@doc.root.element("chapter[@no='#{chapter}']/verse[@no='#{verse}']")
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def search(keyword)
|
177
|
+
|
178
|
+
a = @verses.select {|x| x.text =~ /#{keyword}/}
|
179
|
+
|
180
|
+
a2 = a.map.with_index do |verse, i|
|
181
|
+
txt = verse.text
|
182
|
+
|
183
|
+
puts 'txt: ' + txt.inspect if @debug
|
184
|
+
|
185
|
+
n = 0
|
186
|
+
chapter = verse.parent.attributes[:no]
|
187
|
+
|
188
|
+
until txt.rstrip[-1] == '.' or n > 2 do
|
189
|
+
n +=1
|
190
|
+
nverse = read(chapter, verse.attributes[:no].to_i + n)
|
191
|
+
txt += nverse.text
|
192
|
+
end
|
193
|
+
|
194
|
+
if @debug then
|
195
|
+
puts 'n: ' + n.inspect
|
196
|
+
puts '_txt: ' + txt.inspect
|
197
|
+
end
|
198
|
+
|
199
|
+
[verse.parent.attributes[:no], verse.attributes[:no], txt]
|
200
|
+
end
|
201
|
+
|
202
|
+
h1 = a2.group_by(&:first)
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bibletools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----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y0esYh7VOkDAmBgNVHREEHzAdgRtnZW1tYXN0ZXJAamFt
|
28
|
+
ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
29
|
+
c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQC4rcqtsT3VmXV5P8azIQB6Ek/msm2u
|
30
|
+
CstleVVm/EwF7jh0gGJJiDJQN5AVgx8KuTUgMG7ZV/545tyvMehterxdOnGu/BVK
|
31
|
+
Vj4x122PiswtVHH0mEGaLAhPN7ZFwuFrcqOnBvvQu2KzHL/pq4G0H7nH2DarIRVk
|
32
|
+
Taw5ZF8P5xQvJlhZgi+5nRRiZoTwKwWqp+qqh6O4yTOWfBFRf3Jbnc5Zl+MqhOpX
|
33
|
+
uhkwF7pXCOW657/b0ZHpc4VOMtTZc7zexqAvrYluKT9RNMT8UWpS3b2jWjHSujww
|
34
|
+
T017aRDqdDpFR4Nr83t0ZE5JZlGbtMBK1vPw//PKr/r720mqWEShWNqoedmKWAj7
|
35
|
+
bJS0iHnCBeWKWn0HK15PbywyBS9X8SB8WSEabEcxFRUY6NKK3JtC6breJGNWFZih
|
36
|
+
hIlyeyH9vsaJLam1TYsSqh3KUBmRCIvc3XELg2MAlggTrHuCjBPdYXqjIOFvO6HZ
|
37
|
+
Z1XDnMf4RhcEPF4AU3Q+Fefsw4qKRWH3YUw=
|
38
|
+
-----END CERTIFICATE-----
|
39
|
+
date: 2022-11-01 00:00:00.000000000 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokorexi
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.7.0
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.7'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.7.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: yawc
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.3'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.3.0
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.3'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.3.0
|
81
|
+
description:
|
82
|
+
email: digital.robertson@gmail.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- lib/bibletools.rb
|
88
|
+
homepage: https://github.com/jrobertson/bibletools
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.3.7
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Performs a word count within a specified book. Returns the verses within
|
111
|
+
a specified book for a given keyword.
|
112
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|