ImpUnit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c5ffb7af9280ad094acc05522ba386112183fc3a129c9bd240641c086cb5707e
4
+ data.tar.gz: ba139aa4a9241110d9f11548f0fc234250441d74154948f6711cbea18f7667ba
5
+ SHA512:
6
+ metadata.gz: 00d11274c2a06928a5271b19f6878d94d2e127d0622d22bb7e25f3f4273dea1e3e605a82daa50fc1eec1c19c1c642078de3bffe926793851cc6c971e1e7e6dc1
7
+ data.tar.gz: 73e405b0c545d593274c0e9c0ad9be9de1e8036381874928a4b5d5e4cc07c5c457247e5c45d07142f786d5eaccad2999986e8a3352f81ba8300ee7a3490fd2d5
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ImpUnit.gemspec
6
+ gemspec
data/ImpUnit.gemspec ADDED
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ImpUnit/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ImpUnit"
8
+ spec.version = ImpUnit::VERSION
9
+ spec.authors = ["LWFlouisa"]
10
+ spec.email = ["lwflouisa@gmail.com"]
11
+
12
+ spec.summary = %q{ImpUnit engine. The intent is a human like intelligence small enough to fit into a thumb drive.}
13
+ spec.description = %q{Implementing the main engine and subroutines into a gem so I don't have to continuously recreate the wheel.}
14
+ spec.homepage = "https://lwflouisa.github.io/ImpUnitGem"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ImpUnit
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ImpUnit`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ImpUnit'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ImpUnit
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ImpUnit.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ImpUnit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module ImpUnit
2
+ VERSION = "0.1.0"
3
+ end
data/lib/ImpUnit.rb ADDED
@@ -0,0 +1,385 @@
1
+ require "ImpUnit/version"
2
+
3
+ module ImpUnit
4
+
5
+ class MainAI
6
+ def self.seed
7
+ number = 0
8
+
9
+ options_list = File.read("options/option_list.txt").to_s.split(" ").shuffle
10
+
11
+ # Candidate files
12
+ candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
13
+
14
+ # Bases iteration limit on options list size.
15
+ size_limit = options_list.size.to_i
16
+
17
+ # Iterate size limit times comparing option with candidate.
18
+ size_limit.times do
19
+ option = options_list[number]
20
+
21
+ print "Candidate: #{candidate} Option: #{option} >>"
22
+
23
+ if option == candidate
24
+ puts " #{option} matches the candidate #{candidate}."
25
+
26
+ # From matching candidate choose this script to write.
27
+ open("exec.sh", "w") { |f|
28
+ f.puts option #.tr "_", " "
29
+ }
30
+
31
+ # Exit script
32
+ abort
33
+ else
34
+ puts " #{option} does not match the candidate #{candidate}."
35
+ end
36
+
37
+ sleep(3)
38
+
39
+ number = number + 1
40
+ end
41
+ end
42
+ end
43
+
44
+ # Caution: Highly Experimental. This treats naive similarly to a dynamic website.
45
+ class Language
46
+ def self.fraponic_standard
47
+ end
48
+
49
+ def self.fraponic_request
50
+ end
51
+
52
+ def self.loader
53
+ end
54
+ end
55
+
56
+ # Points to specific subroutines.
57
+ class Subroutines
58
+ def self.apple_color
59
+ def self.what_color
60
+ input = File.read("data/apple/colors/color_chart.txt").split(" ")
61
+
62
+ number = 0
63
+
64
+ size_limit = input.size.to_i
65
+
66
+ # Estimate each word in a sentence from a label.
67
+ size_limit.times do
68
+ require 'naive_bayes'
69
+
70
+ color = NaiveBayes.new(:red, :green, :yellow)
71
+
72
+ # Trains on apple colors.
73
+ color.train(:red, "red", "word")
74
+ color.train(:green, "green", "word")
75
+ color.train(:yellow, "yellow", "word")
76
+
77
+ b = input[number]
78
+
79
+ puts "Results >> #{color.classify(*b)}"
80
+
81
+ sleep(1)
82
+
83
+ number = number + 1
84
+ end
85
+ end
86
+
87
+ def self.what_color
88
+ input = File.read("data/apple/actions/action_chart.txt").split(" ")
89
+
90
+ number = 0
91
+
92
+ size_limit = input.size.to_i
93
+
94
+ # Estimate each word in a sentence from a label.
95
+ size_limit.times do
96
+ require 'naive_bayes'
97
+
98
+ action = NaiveBayes.new(:eat, :toss)
99
+
100
+ # Trains on apple colors.
101
+ action.train(:eat, "eat", "word")
102
+ action.train(:toss, "toss", "word")
103
+
104
+ b = input[number]
105
+
106
+ puts "Results >> #{action.classify(*b)}"
107
+
108
+ sleep(1)
109
+
110
+ number = number + 1
111
+ end
112
+ end
113
+
114
+ print "Deciding on color...\n\n"; sleep(3)
115
+
116
+ ImpUnit::Subroutines.apple_color.what_color
117
+
118
+ print "Deciding on action...\n\n"; sleep(3)
119
+
120
+ ImpUnit::Subroutines.apple_color.what_action
121
+ end
122
+
123
+ def self.simple_search
124
+ def self.standard
125
+ number = 0
126
+
127
+ options_list = File.read("options/option_list.txt").to_s.split(" ") #.shuffle
128
+
129
+ # Candidate files
130
+ candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
131
+
132
+ # Bases iteration limit on options list size.
133
+ size_limit = options_list.size.to_i
134
+
135
+ # Iterate size limit times comparing option with candidate.
136
+ size_limit.times do
137
+ option = options_list[number]
138
+
139
+ print "Candidate: #{candidate} Option: #{option} >> "
140
+
141
+ if option == candidate
142
+ puts " #{option} matches the candidate #{candidate}."
143
+
144
+ abort
145
+ else
146
+ puts " #{option} does not match the candidate #{candidate}."
147
+ end
148
+
149
+ sleep(3)
150
+
151
+ number = number + 1
152
+ end
153
+ end
154
+
155
+ def self.random
156
+ number = 0
157
+
158
+ options_list = File.read("options/option_list.txt").to_s.split(" ").shuffle
159
+
160
+ # Candidate files
161
+ candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
162
+
163
+ # Bases iteration limit on options list size.
164
+ size_limit = options_list.size.to_i
165
+
166
+ # Iterate size limit times comparing option with candidate.
167
+ size_limit.times do
168
+ option = options_list[number]
169
+
170
+ print "Candidate: #{candidate} Option: #{option} >> "
171
+
172
+ if option == candidate
173
+ puts " #{option} matches the candidate #{candidate}."
174
+
175
+ abort
176
+ else
177
+ puts " #{option} does not match the candidate #{candidate}."
178
+ end
179
+
180
+ sleep(3)
181
+
182
+ number = number + 1
183
+ end
184
+ end
185
+ end
186
+
187
+ def self.rikusuto
188
+ def self.rikusuto
189
+ require "decisiontree"
190
+
191
+ # Continuous Dice
192
+ dice = [10.50, 10.75, 21.25,
193
+ 21.50, 21.75, 82.25,
194
+ 82.50, 82.75, 73.25,
195
+ 73.50, 73.75, 54.25,
196
+ 54.50, 54.75, 10.50]
197
+
198
+ input = dice.sample.to_i
199
+
200
+ attributes = ['Rikusuto']
201
+
202
+ training = [
203
+ [ 0.5, "will you get"],
204
+ [ 50.0, "will you obtain"],
205
+ [100.0, "may I have"],
206
+ ]
207
+
208
+ # Instantiate the tree, and train it based on the data (set default to '1')
209
+ dec_tree = DecisionTree::ID3Tree.new(attributes, training, 1, :continuous)
210
+ dec_tree.train
211
+
212
+ test = [input, "may I have"]
213
+
214
+ decision = dec_tree.predict(test)
215
+
216
+ # puts "Desired Result: #{decision} ... True Result: #{test.last}"
217
+
218
+ open("data/rikusuto/request.txt", "w") { |f|
219
+ f.puts decision
220
+ }
221
+ end
222
+
223
+ def self.atemu
224
+ require "decisiontree"
225
+
226
+ # Continuous Dice
227
+ dice = [10.50, 10.75, 21.25,
228
+ 21.50, 21.75, 82.25,
229
+ 82.50, 82.75, 73.25,
230
+ 73.50, 73.75, 54.25,
231
+ 54.50, 54.75, 10.50]
232
+
233
+ input = dice.sample.to_i
234
+
235
+ attributes = ['Atemu']
236
+
237
+ training = [
238
+ [ 0.5, "a banana"],
239
+ [ 50.0, "an orange"],
240
+ [100.0, "a kiwi"],
241
+ ]
242
+
243
+ # Instantiate the tree, and train it based on the data (set default to '1')
244
+ dec_tree = DecisionTree::ID3Tree.new(attributes, training, 1, :continuous)
245
+ dec_tree.train
246
+
247
+ test = [input, "an orange"]
248
+
249
+ decision = dec_tree.predict(test)
250
+
251
+ # puts "Desired Result: #{decision} ... True Result: #{test.last}"
252
+ open("data/items/items.txt", "w") { |f|
253
+ f.puts decision
254
+ }
255
+ end
256
+
257
+ def self.create
258
+
259
+ xml_header = '<?xml version="1.0" encoding="UTF-8"?>
260
+ <?xml-stylesheet type="text/css" href="stylesheet.css"?>'
261
+
262
+ topic_header = "<topic>"
263
+ topic_bottom = "</topic>"
264
+
265
+ def self.salut
266
+ " <salut>Hello</salut>"
267
+ end
268
+
269
+ def self.ejento
270
+ agent_name = File.read("data/usr_identity/name.txt").strip.to_s
271
+
272
+ " <ejento>#{agent_name}</ejento>"
273
+ end
274
+
275
+ def self.rikusuto
276
+ request_type = File.read("data/requests/request.txt").strip.to_s
277
+
278
+ " <rikusuto>#{request_type}</rikusuto>"
279
+ end
280
+
281
+ def self.atemu
282
+ item = File.read("data/items/items.txt").strip.to_s
283
+
284
+ " <atemu>#{item}</atemu>"
285
+ end
286
+
287
+ def self.nitote
288
+ " <nitote>for</nitote>"
289
+ end
290
+
291
+ def self.kara
292
+ " <kara>from</kara>"
293
+ end
294
+
295
+ def self.yuza
296
+ user_name = File.read("data/usr_identity/user_name.txt").strip.to_s
297
+
298
+ " <yuza>#{user_name}</yuza>"
299
+ end
300
+
301
+ def self.lieu
302
+ local_name = File.read("data/usr_identity/local_name.txt").strip.to_s
303
+
304
+ " <lieu>#{local_name}</lieu>"
305
+ end
306
+
307
+ conjucate = [nitote, kara]
308
+ consign = conjucate.sample
309
+
310
+ user_location = [yuza, lieu]
311
+ usign = user_location[0]
312
+
313
+ open("index.xml", "w") { |f|
314
+ f.puts xml_header
315
+ f.puts topic_header
316
+ f.puts salut
317
+ f.puts ejento
318
+ f.puts rikusuto
319
+ f.puts atemu
320
+ f.puts consign
321
+ f.puts usign
322
+ f.puts topic_bottom
323
+ }
324
+ end
325
+ end
326
+
327
+ def self.unfictionWP
328
+ # Loop limit based on configured screen settings.
329
+ number = File.read("data/config/line_num.txt").strip.to_i
330
+ do_size = ["tiny", "small", "medium"]
331
+ size_chosen = do_size[number]
332
+ size_limit = size_chosen.size.to_i
333
+
334
+ # Character name chosen from number
335
+ name_number = File.read("data/identity/number.txt").strip.to_i
336
+
337
+ character_count = 2 # name_list[name_number].size.to_s
338
+ # name_limit = 0
339
+
340
+ # Base dialogue sequence on size limit.
341
+ size_limit.times do
342
+
343
+ # Username logistics
344
+ name_list = File.read("data/identity/name_list.txt").split(", ")
345
+ name = name_list[name_number].to_s
346
+ name_limit = name_list[name_number].size
347
+
348
+ if name_limit > character_count
349
+ name_limit = name_limit % 2
350
+ else
351
+ name_limit = name_limit + 1
352
+ end
353
+
354
+ old_dialogue = File.read("archive/dialogue.txt").strip.to_s
355
+
356
+ # Write date to file.
357
+ system("date > data/date/date.txt")
358
+
359
+ date = File.read("data/date/date.txt").strip
360
+
361
+ # Print character dialogue to screen.
362
+ print "[#{date} #{name.strip}] "; new_dialogue = gets.chomp
363
+
364
+ # If writer specifies exit then aborts
365
+ if new_dialogue == "exit"
366
+ abort
367
+ end
368
+
369
+ # Autosaves dialogue archive. Auto appends old dialogue above new dialogue.
370
+ open("archive/dialogue.txt", "w") { |f|
371
+ f.puts old_dialogue
372
+ f.print "[#{date} #{name.strip}] "
373
+ f.puts new_dialogue
374
+ }
375
+
376
+ # Changes name as if in a chatroom.
377
+ if name_number == name_limit
378
+ name_number = 0
379
+ else
380
+ name_number = name_number + 1
381
+ end
382
+ end
383
+ end
384
+ end
385
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ImpUnit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - LWFlouisa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Implementing the main engine and subroutines into a gem so I don't have
42
+ to continuously recreate the wheel.
43
+ email:
44
+ - lwflouisa@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - ImpUnit.gemspec
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - lib/ImpUnit.rb
57
+ - lib/ImpUnit/version.rb
58
+ homepage: https://lwflouisa.github.io/ImpUnitGem
59
+ licenses: []
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.7.8
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: ImpUnit engine. The intent is a human like intelligence small enough to fit
81
+ into a thumb drive.
82
+ test_files: []