Class: Stamina::Command::AbbadingoSamples

Inherits:
Object
  • Object
show all
Defined in:
lib/stamina-induction/stamina/command/abbadingo_samples.rb

Overview

Generates samples following Abbadingo’s protocol

SYNOPSIS

#{program_name} #{command_name} target.adl

OPTIONS #summarized_options

Instance Method Summary collapse

Instance Method Details

#execute(args) ⇒ Object

Command execution

Raises:

  • (Quickl::Help)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stamina-induction/stamina/command/abbadingo_samples.rb', line 20

def execute(args)
  raise Quickl::Help unless args.size == 1

  # Loads the target automaton
  target_file = args.first
  basename = File.basename(target_file, '.adl')
  dirname = File.dirname(target_file)
  target = Stamina::ADL::parse_automaton_file(target_file)

  require 'stamina/abbadingo'
  training, test = Stamina::Abbadingo::RandomSample.execute(target)

  # Flush results aside the target automaton file
  Stamina::ADL::print_sample_in_file(training, File.join(dirname, "#{basename}-training.adl"))
  Stamina::ADL::print_sample_in_file(test,     File.join(dirname, "#{basename}-test.adl"))
end