Class: RequestXml::InputGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/request_xml.rb

Class Method Summary collapse

Class Method Details

.baysian_inputObject

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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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