class RequestXml::InputGenerator

Public Class Methods

baysian_input() click to toggle source

This allows use to generate natural language output with natural language input.

# File lib/request_xml.rb, line 9
def self.baysian_input
  require "naive_bayes"

  ## To study the baysian used by Red Davis, check out: https://github.com/reddavis/Naive-Bayes
  in_generate = NaiveBayes.new(:input_small, :input_medium, :input_large)

  in_generate.train(:input_small,  'small',  'word')
  in_generate.train(:input_medium, 'medium', 'word')
  in_generate.train(:input_large,  'large',  'word')

  input_file = File.read("text/document/input.txt").split(' ')

  data = in_generate.classify(*input_file)

  # Used to generate an input.
  label  = data[0]
  gInput = data[1].to_i

  open("data/number/input.txt", "w") { |f|
    f.puts gInput
  }
end