bibletools 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5085703f655b244826701beeba91b5bbfc535a8d34f2d4fbbc842c6229ced5fa
4
- data.tar.gz: 27639f898a9c016fdbaf47cbaddeae392c93500145492ea0ba51f1a2ebc82e1b
3
+ metadata.gz: e10c0e0f8c335ebc195c2086d59c3d27a9a4f3d2c19e42ba85bca938365a4c2b
4
+ data.tar.gz: bf5259405950f58998288d7d17f783a6672600c053617e56e34a5363c44f938f
5
5
  SHA512:
6
- metadata.gz: a70124fe758ee62e6874e6126db903c56eb0edf8bd35f5ea7a80dae1917cc30c225191dc6eec93f35ac1f63b77dbaef461f25398a5a0db90684ece938aa427c8
7
- data.tar.gz: 861ed48ae15f6d7516d98fac70e76b2b2bc6633c90f56193b7ca4f5f8fafbeee07e12ba8adbef23cb57119ef7c0a0c9ff31e7ec49a91383f695c19955dbfc9fc
6
+ metadata.gz: f8e7b6f0a5246ab59b5db9732c8ea29e34e354c687f6a6bdae7971a99f89947a53252acad367d0a006984fbd1bf7c8349f09cf21b2b7f9b4e66d42a25a53e087
7
+ data.tar.gz: 9fd82593908e3f1a97b0a65f5d7b77bc34b8fc3e343abe1d4b81e66d4f8bb152dab81efcf3a0424a306d8df4621c7bff5a93473e5cf3b9a4e70ae8950ed897b8
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/bibletools.rb CHANGED
@@ -93,17 +93,21 @@ module BibleTools
93
93
 
94
94
  class Scraper
95
95
 
96
- def initialize(book: 'Exodus', url: '')
96
+ def initialize(book: 'Exodus', url: '', debug: false)
97
97
 
98
98
  raise ScraperErr, 'Please specify the URL' if url.empty?
99
99
 
100
100
  baseurl = url
101
101
 
102
102
  id = if book.is_a? String then
103
- (BOOKS.index(book) + 1).to_s
103
+ i = BOOKS.index(book.gsub(/\b./){|x| x.upcase})
104
+ puts 'book *' + book + '* not found' unless i
105
+ (i + 1).to_s
104
106
  else
105
107
  book.to_s
106
108
  end
109
+
110
+ puts 'id: ' + id.inspect if @debug
107
111
 
108
112
  url2 = baseurl + '?id=' + id
109
113
  doc = Nokorexi.new(url2).to_doc
@@ -180,9 +184,28 @@ module BibleTools
180
184
  # Automatically select verses; verses are selected based upon word
181
185
  # frequency
182
186
  #
183
- def asr()
187
+ def asr(chapters: [])
188
+
189
+ r = if chapters.any? then
190
+
191
+ doc = Rexle.new('<book/>')
192
+
193
+ chapters.each do |n|
194
+ e2 = @doc.root.element("chapter[@no='#{n.to_s}']")
195
+ doc.root.add e2 if e2
196
+ end
197
+
198
+ return doc
199
+
200
+ keyword = wordtally(doc: doc).keys.first
201
+ #return keyword
202
+ #get the wordstally for the chapters
203
+ assoc_r(keyword, doc)
204
+
205
+ else
206
+ assoc_r()
207
+ end
184
208
 
185
- r = assoc_r()
186
209
  e = r[1].root.element('chapter/verse')
187
210
  verse_no = e.attributes[:no]
188
211
  chptr_no = e.parent.attributes[:no]
@@ -190,9 +213,11 @@ module BibleTools
190
213
  # we are backtracking the results to hopefully find a new branch to explore
191
214
  trail = r.first
192
215
 
216
+ #return r
193
217
  a, trail2 = mine_words(r, trail, level: 2)
194
218
  a << [chptr_no, verse_no, e.text, 1]
195
-
219
+ puts 'a: ' + a.inspect
220
+ #return a
196
221
  h = a.group_by(&:first)
197
222
  a2 = h.sort_by {|x, _| x.to_i}
198
223
  @verses = a2.map do |chapter, verses|
@@ -266,9 +291,12 @@ module BibleTools
266
291
  def search(keyword, doc=@doc)
267
292
 
268
293
  verses = doc.root.xpath('chapter/verse')
294
+ puts 'verses: ' + verses.inspect
269
295
  a = verses.select {|x| x.text =~ /#{keyword}/i}
270
296
 
271
297
  a2 = a.map.with_index do |verse, i|
298
+
299
+ #puts 'verse: ' + verse.xml.inspect
272
300
  txt = verse.text
273
301
 
274
302
  puts 'txt: ' + txt.inspect if @debug
@@ -278,9 +306,11 @@ module BibleTools
278
306
 
279
307
  until txt.rstrip[/[\.\?!]\W*$/] or n > 2 do
280
308
  n +=1
309
+ puts 'n: ' + n.inspect
281
310
  nverse = read(chapter, verse.attributes[:no].to_i + n)[0]
311
+ puts 'nverse: ' + nverse.inspect
282
312
  puts 'nverse: ' + nverse&.text.inspect if @debug
283
- txt += nverse.text
313
+ txt += nverse.text if nverse
284
314
  end
285
315
 
286
316
  if @debug then
@@ -396,10 +426,11 @@ module BibleTools
396
426
  puts 'trail.length: ' + trail.length.inspect if @debug
397
427
  puts 'verses.length: ' + verses.length.inspect if @debug
398
428
 
399
- if verses.length < 30 or trail.length < 100
400
- mine_words(r, trail, verses, level: level+1)
401
- else
429
+ if verses.length > 30 or trail.length > 100
402
430
  [verses, trail]
431
+ else
432
+
433
+ mine_words(r, trail, verses, level: level+1)
403
434
  end
404
435
  end
405
436
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibletools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -36,7 +36,7 @@ cert_chain:
36
36
  hIlyeyH9vsaJLam1TYsSqh3KUBmRCIvc3XELg2MAlggTrHuCjBPdYXqjIOFvO6HZ
37
37
  Z1XDnMf4RhcEPF4AU3Q+Fefsw4qKRWH3YUw=
38
38
  -----END CERTIFICATE-----
39
- date: 2022-11-06 00:00:00.000000000 Z
39
+ date: 2023-01-19 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokorexi
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.3.7
147
+ rubygems_version: 3.4.4
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Performs a word count within a specified book. Returns the verses within
metadata.gz.sig CHANGED
Binary file