Class: Bors
- Inherits:
-
Object
- Object
- Bors
- Defined in:
- lib/bors.rb,
lib/bors/math.rb,
lib/bors/result.rb,
lib/bors/example.rb,
lib/bors/exceptions.rb,
lib/bors/command_line.rb,
lib/bors/result/samples.rb,
lib/bors/example/feature.rb,
lib/bors/result/settings.rb,
lib/bors/result/statistics.rb
Defined Under Namespace
Modules: Exceptions, Math Classes: CommandLine, Example, Result
Instance Attribute Summary collapse
-
#examples ⇒ Object
readonly
returns the examples as a string in VW format.
Instance Method Summary collapse
- #add_example(details) ⇒ Object
-
#get_example(at) ⇒ Object
returns an example from the file.
-
#initialize(options) ⇒ Bors
constructor
A new instance of Bors.
-
#run!(run_options = {}) ⇒ Object
Runs vowpal wabbit with the loaded examples.
Constructor Details
#initialize(options) ⇒ Bors
Returns a new instance of Bors.
12 13 14 15 16 |
# File 'lib/bors.rb', line 12 def initialize() raise Exceptions::ArgumentError.new('You must specify an examples file') unless [:examples_file] @options = @examples_file = File.new([:examples_file], 'a') end |
Instance Attribute Details
#examples ⇒ Object (readonly)
returns the examples as a string in VW format
28 29 30 |
# File 'lib/bors.rb', line 28 def examples @examples end |
Instance Method Details
#add_example(details) ⇒ Object
18 19 20 |
# File 'lib/bors.rb', line 18 def add_example(details) @examples_file.write("#{Example.new(details).to_s}\n") end |
#get_example(at) ⇒ Object
returns an example from the file
23 24 25 |
# File 'lib/bors.rb', line 23 def get_example(at) get_line_from_file(@examples_file, at) # should convert to Example class instead of String end |
#run!(run_options = {}) ⇒ Object
Runs vowpal wabbit with the loaded examples
35 36 37 38 39 40 41 42 43 |
# File 'lib/bors.rb', line 35 def run!(={}) with_closed_examples_file do raise Exceptions::MissingExamples.new unless File.open(@examples_file.path, 'r').readlines.count > 0 .merge!({:examples => @examples_file.path}) out = CommandLine.new().run! FileUtils.rm(@examples_file.path) if @options[:temp_examples] == true return Result.new(out) end end |