Class: CorrectHorseBatteryStaple::Writer::Csv
- Inherits:
-
File
- Object
- CorrectHorseBatteryStaple::Writer
- Base
- File
- CorrectHorseBatteryStaple::Writer::Csv
- Defined in:
- lib/correct_horse_battery_staple/writer/csv.rb
Instance Attribute Summary
Attributes inherited from File
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(dest, options = {}) ⇒ Csv
constructor
A new instance of Csv.
- #write_corpus(corpus) ⇒ Object
Methods inherited from File
Methods inherited from Base
Methods included from Common
#array_sample, #logger, #random_in_range, #random_number, #set_sample
Methods inherited from CorrectHorseBatteryStaple::Writer
Constructor Details
#initialize(dest, options = {}) ⇒ Csv
Returns a new instance of Csv.
3 4 5 |
# File 'lib/correct_horse_battery_staple/writer/csv.rb', line 3 def initialize(dest, ={}) super end |
Instance Method Details
#write_corpus(corpus) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/correct_horse_battery_staple/writer/csv.rb', line 7 def write_corpus(corpus) puts "index,rank,word,frequency,percentile,distance,probability,distance_probability" corpus.each_with_index do |w, index| puts sprintf("%d,%d,\"%s\",%d,%.4f,%.6f,%.8f,%.8f\n", index || -1, w.rank || -1, w.word, w.frequency || -1, w.percentile || -1, w.distance || -1, w.probability || -1, w.distance_probability || -1) end end |