Class: ImpUnit::ObjectColor

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

Overview

Bleeding edge

Class Method Summary collapse

Class Method Details

.what_actionObject



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/ImpUnit.rb', line 181

def self.what_action
  input = File.read("data/actions/action_chart.txt").split(" ")

  number = 0

  size_limit = input.size.to_i

  # Estimate each word in a sentence from a label.
  size_limit.times do
    require 'naive_bayes'

    action = NaiveBayes.new(:eat, :toss)

    # Trains on apple colors.
    action.train(:eat,     "eat", "word")
    action.train(:toss,   "toss", "word")

    b = input[number]

    puts "Results >> #{action.classify(*b)}"

    sleep(1)

    number = number + 1
  end
end

.what_colorObject



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/ImpUnit.rb', line 153

def self.what_color
  input = File.read("data/colors/color_chart.txt").split(" ")

  number = 0

  size_limit = input.size.to_i

  # Estimate each word in a sentence from a label.
  size_limit.times do
    require 'naive_bayes'

    color = NaiveBayes.new(:red, :green, :yellow)

    # Trains on apple colors.
    color.train(:red,       "red", "word")
    color.train(:green,   "green", "word")
    color.train(:yellow, "yellow", "word")

    b = input[number]

    puts "Results >> #{color.classify(*b)}"

    sleep(1)

    number = number + 1
  end
end

.what_objectObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/ImpUnit.rb', line 125

def self.what_object
  input = File.read("data/object/object_chart.txt").split(" ")

  number = 0

  size_limit = input.size.to_i

  # Estimate each word in a sentence from a label.
  size_limit.times do
    require 'naive_bayes'

    object = NaiveBayes.new(:person, :place, :thing)

    # Trains on apple colors.
    object.train(:person, "person", "word")
    object.train(:place,  "place",  "word")
    object.train(:thing,  "thing",  "word")

    b = input[number]

    puts "Results >> #{object.classify(*b)}"

    sleep(1)

    number = number + 1
  end
end