Module: See5

Defined in:
lib/see5.rb,
lib/see5/rule.rb,
lib/see5/model.rb,
lib/see5/schema.rb,
lib/see5/version.rb,
lib/see5/input_file_writer.rb,
lib/see5/rules_output_parser.rb,
lib/see5/gritbot_output_parser.rb

Defined Under Namespace

Classes: GritbotOutputParser, InputFileWriter, Model, Rule, RulesOutputParser, Schema

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.audit(data, class_attribute:) ⇒ Object



22
23
24
25
26
27
# File 'lib/see5.rb', line 22

def self.audit(data, class_attribute:)
  prepare_tmp_files(data, class_attribute: class_attribute)
  run_gritbot

  See5::GritbotOutputParser.parse_file("/tmp/ruby-see5.gritbot_output")
end

.prepare_tmp_files(data, class_attribute:) ⇒ Object



29
30
31
32
# File 'lib/see5.rb', line 29

def self.prepare_tmp_files(data, class_attribute:)
  schema = See5::Schema.from_dataset(data, class_attribute: class_attribute)
  See5::InputFileWriter.write_files(data: data, schema: schema)
end

.run_gritbotObject



38
39
40
# File 'lib/see5.rb', line 38

def self.run_gritbot
  system("#{gritbot_executable} -s -f /tmp/ruby-see5 -r > /tmp/ruby-see5.gritbot_output")
end

.run_see5Object



34
35
36
# File 'lib/see5.rb', line 34

def self.run_see5
  system("#{see5_executable} -f /tmp/ruby-see5 -r > /tmp/ruby-see5.rules_output")
end

.train(data, class_attribute:) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/see5.rb', line 13

def self.train(data, class_attribute:)
  prepare_tmp_files(data, class_attribute: class_attribute)
  run_see5

  output = See5::RulesOutputParser.parse_file("/tmp/ruby-see5.rules_output")

  See5::Model.new(**output)
end