Class: CorrectHorseBatteryStaple::Writer::Sqlite

Inherits:
Base show all
Defined in:
lib/correct_horse_battery_staple/writer/sqlite.rb

Instance Attribute Summary

Attributes inherited from Base

#dest, #options

Instance Method Summary collapse

Methods inherited from Base

#close

Methods included from Common

#array_sample, #logger, #random_in_range, #random_number, #set_sample

Methods inherited from CorrectHorseBatteryStaple::Writer

make_writer, write

Constructor Details

#initialize(dest, options = {}) ⇒ Sqlite

Returns a new instance of Sqlite.



6
7
8
# File 'lib/correct_horse_battery_staple/writer/sqlite.rb', line 6

def initialize(dest, options={})
  super
end

Instance Method Details

#write_corpus(corpus) ⇒ Object

select * from entries where percentile < 30 and percentile > 20 and wordlength >= 9 and wordlength <= 12 order by RANDOM() limit 6;



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/correct_horse_battery_staple/writer/sqlite.rb', line 11

def write_corpus(corpus)
  create_database

  @db.transaction do
    save_entries(@db, corpus)
    save_stats(@db, corpus.stats)
  end

rescue
  logger.error "error in SQLite write_corpus: #{$!.inspect}"
  raise
ensure
  close_database
end