Class: Stamina::Command::Metrics
- Inherits:
-
Object
- Object
- Stamina::Command::Metrics
- Includes:
- Robustness
- Defined in:
- lib/stamina-induction/stamina/command/metrics.rb
Overview
Prints metrics about an automaton or sample
SYNOPSIS
#{program_name} #{command_name} [file.adl]
OPTIONS #summarized_options
Instance Method Summary collapse
-
#execute(args) ⇒ Object
Command execution.
Instance Method Details
#execute(args) ⇒ Object
Command execution
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/stamina-induction/stamina/command/metrics.rb', line 21 def execute(args) raise Quickl::Help unless args.size <= 1 # Loads the target automaton input = if args.size == 1 File.read assert_readable_file(args.first) else $stdin.readlines.join("\n") end # Flush metrics begin target = Stamina::ADL::parse_automaton(input) puts "Alphabet size: #{target.alphabet_size}" puts "State count: #{target.state_count}" puts "Edge count: #{target.edge_count}" puts "Degree (avg): #{target.avg_degree}" puts "Accepting ratio: #{target.accepting_ratio}" puts "Depth: #{target.depth}" rescue ADL::ParseError sample = Stamina::ADL::parse_sample(input) puts "Size: #{sample.size}" puts "Positive: #{sample.positive_count} (#{sample.positive_count.to_f / sample.size})" puts "Negative: #{sample.negative_count} (#{sample.negative_count.to_f / sample.size})" end end |