ESBI 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c3af73e01bbf52711497890749950a2e414d1c87d2d33117392be09b18b80d64
4
+ data.tar.gz: 070ac11a58ff16ba4b3044af6284417248cc8f457131c256ee71a5a91b7bbea5
5
+ SHA512:
6
+ metadata.gz: 751c7ccbe9eab188494edd28ba58289e371157e15ef5e939b19326832ce4ff1355d79f9bbbf18d9e179d62ca10277ac8f31a6989404f5ecd796e698c1927bada
7
+ data.tar.gz: 2280521cea227a186499cc2ff1ad8a3d99c49957dce9731d1d0b5bde0cdd0f48f6e3216559301adf8d523010e215f555f474c6b8a8590517a03d14ad01fc4445
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at gitea@fake.local. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/ESBI/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ESBI"
5
+ spec.version = ESBI::VERSION
6
+ spec.authors = ["Gitea"]
7
+ spec.email = ["gitea@fake.local"]
8
+
9
+ spec.summary = %q{Evolutionary-Symbolic-Baysian and Ruleset AI with smart translation.}
10
+ spec.description = %q{A hybrid model of different systems of AI and rules based programming for different purposes. This uses the rules_ai gem..}
11
+ spec.homepage = "https://lwflouisa.github.io/Weaver-AI"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+
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_runtime_dependency 'rules_ai', '~> 0.9.0'
26
+ spec.add_runtime_dependency 'naive_bayes', '~> 0.0.3'
27
+ end
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ESBI.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Gitea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # ESBI
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/ESBI`. 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 'ESBI'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ESBI
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]/ESBI. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ESBI/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the ESBI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ESBI/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ESBI"
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__)
@@ -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,690 @@
1
+ require "ESBI/version"
2
+
3
+ module ESBI
4
+ class Error < StandardError; end
5
+
6
+ ## Learning Model
7
+ class Naive_Bayes
8
+
9
+ def self.baysian_seed
10
+ old_greeting = File.read("data/baysian/archive/greeting_archive.txt")
11
+ old_agent = File.read("data/baysian/archive/agent_archive.txt")
12
+ old_request = File.read("data/baysian/archive/request_archive.txt")
13
+ old_gender = File.read("data/baysian/archive/gender_archive.txt")
14
+ old_object = File.read("data/baysian/archive/object_archive.txt")
15
+ old_for_from = File.read("data/baysian/archive/for_from_archive.txt")
16
+ old_direction = File.read("data/baysian/archive/direction_archive.txt")
17
+
18
+ print "Train greeting evaluator on >> "; greeting = gets.chomp
19
+ print "Train agent on evaluator >> "; agent = gets.chomp
20
+ print "Train request evaluator on >> "; request = gets.chomp
21
+ print "Train gender evaluator on >> "; gender = gets.chomp
22
+ print "Train object evaluator on >> "; object = gets.chomp
23
+ print "Train for_from evaluator on >> "; for_from = gets.chomp
24
+ print "Train direction evaluator on >> "; direction = gets.chomp
25
+
26
+ create_regimen = "def greeting_trainer
27
+ require 'naive_bayes'
28
+
29
+ a = NaiveBayes.new(:greeting,
30
+ :farewell)
31
+
32
+ a.db_filepath = 'data/baysian/greeting.nb'
33
+
34
+ #{old_greeting}
35
+ #{greeting}
36
+
37
+ a.save
38
+ end
39
+
40
+ def agent_trainer
41
+ require 'naive_bayes'
42
+
43
+ a = NaiveBayes.new(:inheritor,
44
+ :notinheritor)
45
+
46
+ a.db_filepath = 'data/baysian/agent.nb'
47
+
48
+ #{old_agent}
49
+ #{agent}
50
+
51
+ a.save
52
+ end
53
+
54
+ def request_trainer
55
+ require 'naive_bayes'
56
+
57
+ a = NaiveBayes.new(:request,
58
+ :demand)
59
+
60
+ a.db_filepath = 'data/baysian/request.nb'
61
+
62
+ #{old_request}
63
+ #{request}
64
+
65
+ a.save
66
+ end
67
+
68
+ def gender_trainer
69
+ require 'naive_bayes'
70
+
71
+ a = NaiveBayes.new(:masculine,
72
+ :feminine,
73
+ :neuter)
74
+
75
+ a.db_filepath = 'data/baysian/gender.nb'
76
+
77
+ #{old_gender}
78
+ #{gender}
79
+
80
+ a.save
81
+ end
82
+
83
+ def object_trainer
84
+ require 'naive_bayes'
85
+
86
+ a = NaiveBayes.new(:object,
87
+ :abstract)
88
+
89
+ a.db_filepath = 'data/baysian/object.nb'
90
+
91
+ #{old_object}
92
+ #{object}
93
+
94
+ a.save
95
+ end
96
+
97
+ def for_from_trainer
98
+ require 'naive_bayes'
99
+
100
+ a = NaiveBayes.new(:for,
101
+ :from)
102
+
103
+ a.db_filepath = 'data/baysian/for_from.nb'
104
+
105
+ #{old_for_from}
106
+ #{for_from}
107
+
108
+ a.save
109
+ end
110
+
111
+ def direction_trainer
112
+ require 'naive_bayes'
113
+
114
+ a = NaiveBayes.new(:standard,
115
+ :nonstandard)
116
+
117
+ a.db_filepath = 'data/baysian/directions.nb'
118
+
119
+ #{old_direction}
120
+ #{direction}
121
+
122
+ a.save
123
+ end
124
+
125
+ greeting_trainer
126
+ agent_trainer
127
+ request_trainer
128
+ gender_trainer
129
+ object_trainer
130
+ for_from_trainer
131
+ direction_trainer
132
+ "
133
+
134
+ open("script.rb", "w") { |f|
135
+ f.puts create_regimen
136
+ }
137
+
138
+ open("data/baysian/archive/greeting_archive.txt", "w") { |f|
139
+ f.puts " #{old_greeting}"
140
+ f.puts " #{greeting}"
141
+ }
142
+
143
+ open("data/baysian/archive/agent_archive.txt", "w") { |f|
144
+ f.puts " #{old_agent}"
145
+ f.puts " #{agent}"
146
+ }
147
+
148
+ open("data/baysian/archive/request_archive.txt", "w") { |f|
149
+ f.puts " #{old_request}"
150
+ f.puts " #{request}"
151
+ }
152
+
153
+ open("data/baysian/archive/gender_archive.txt", "w") { |f|
154
+ f.puts " #{old_gender}"
155
+ f.puts " #{gender}"
156
+ }
157
+
158
+ open("data/baysian/archive/object_archive.txt", "w") { |f|
159
+ f.puts " #{old_object}"
160
+ f.puts " #{object}"
161
+ }
162
+
163
+ open("data/baysian/archive/for_from_archive.txt", "w") { |f|
164
+ f.puts " #{old_for_from}"
165
+ f.puts " #{for_from}"
166
+ }
167
+
168
+ open("data/baysian/archive/direction_archive.txt", "w") { |f|
169
+ f.puts " #{old_direction}"
170
+ f.puts " #{direction}"
171
+ }
172
+
173
+ system("ruby script.rb")
174
+ end
175
+
176
+ def self.evaluate
177
+ def self.greeting
178
+ require "naive_bayes"
179
+
180
+ a = NaiveBayes.load('data/baysian/greeting.nb')
181
+
182
+ # b = File.read("data/input/document.txt").split(' ')
183
+
184
+ number = File.read("data/input/number.txt").strip.to_i
185
+ input = File.read("data/input/input.txt")
186
+
187
+ b = input[number].downcase.split(" ")
188
+
189
+ classification = a.classify(*b)
190
+
191
+ print classification[0]
192
+ end
193
+
194
+ def self.agent
195
+ require "naive_bayes"
196
+
197
+ a = NaiveBayes.load('data/baysian/agent.nb')
198
+
199
+ # b = File.read("data/input/document.txt").split(' ')
200
+
201
+ number = File.read("data/input/number.txt").strip.to_i
202
+ input = File.read("data/input/input.txt")
203
+
204
+ b = input[number].downcase.split(" ")
205
+
206
+ classification = a.classify(*b)
207
+
208
+ print classification[0]
209
+ end
210
+
211
+ def self.request
212
+ require "naive_bayes"
213
+
214
+ a = NaiveBayes.load('data/baysian/request.nb')
215
+
216
+ # b = File.read("data/input/document.txt").split(' ')
217
+
218
+ number = File.read("data/input/number.txt").strip.to_i
219
+ input = File.read("data/input/input.txt")
220
+
221
+ b = input[number].downcase.split(" ")
222
+
223
+ classification = a.classify(*b)
224
+
225
+ print classification[0]
226
+ end
227
+
228
+ def self.gender
229
+ require "naive_bayes"
230
+
231
+ a = NaiveBayes.load('data/baysian/gender.nb')
232
+
233
+ # b = File.read("data/input/document.txt").split(' ')
234
+
235
+ number = File.read("data/input/number.txt").strip.to_i
236
+ input = File.read("data/input/input.txt")
237
+
238
+ b = input[number].downcase.split(" ")
239
+
240
+ classification = a.classify(*b)
241
+
242
+ print classification[0]
243
+ end
244
+
245
+ def self.object
246
+ require "naive_bayes"
247
+
248
+ a = NaiveBayes.load('data/baysian/object.nb')
249
+
250
+ # b = File.read("data/input/document.txt").split(' ')
251
+
252
+ number = File.read("data/input/number.txt").strip.to_i
253
+ input = File.read("data/input/input.txt")
254
+
255
+ b = input[number].downcase.split(" ")
256
+
257
+ classification = a.classify(*b)
258
+
259
+ print classification[0]
260
+ end
261
+
262
+ def self.for_from
263
+ require "naive_bayes"
264
+
265
+ a = NaiveBayes.load('data/baysian/for_from.nb')
266
+
267
+ # b = File.read("data/input/document.txt").split(' ')
268
+
269
+ number = File.read("data/input/number.txt").strip.to_i
270
+ input = File.read("data/input/input.txt")
271
+
272
+ b = input[number].downcase.split(" ")
273
+
274
+ classification = a.classify(*b)
275
+
276
+ print classification[0]
277
+ end
278
+
279
+ def self.direction
280
+ require "naive_bayes"
281
+
282
+ a = NaiveBayes.load('data/baysian/direction.nb')
283
+
284
+ # b = File.read("data/input/document.txt").split(' ')
285
+
286
+ number = File.read("data/input/number.txt").strip.to_i
287
+ input = File.read("data/input/input.txt")
288
+
289
+ b = input[number].downcase.split(" ")
290
+
291
+ classification = a.classify(*b)
292
+
293
+ print classification[0]
294
+ puts "."
295
+ end
296
+
297
+ ESBI::Naive_Bayes.evaluate.greeting
298
+ ESBI::Naive_Bayes.evaluate.agent
299
+ ESBI::Naive_Bayes.evaluate.request
300
+ ESBI::Naive_Bayes.evaluate.gender
301
+ ESBI::Naive_Bayes.evaluate.object
302
+ ESBI::Naive_Bayes.evaluate.for_from
303
+ ESBI::Naive_Bayes.evaluate.direction
304
+ end
305
+
306
+ end
307
+
308
+ ## Visual Cues
309
+ class Eyes
310
+ def self.camera
311
+ system("cd images; streamer -f jpeg -o image.jpeg")
312
+ end
313
+ end
314
+
315
+ ## Dynamic Decision Tree
316
+ class Dynamic
317
+
318
+ def self.dTree
319
+ require "dynamicTree"
320
+
321
+ number = File.read("data/number/input.txt").strip.to_i
322
+
323
+ DynamicTree::Sprout.initialize_tree
324
+
325
+ print "Move forward? (Y/N) >> "; yn = gets.chomp
326
+
327
+ if yn == "Y"; open("data/number/input.txt", "w") { |f| f.puts number = number + 1 }
328
+ elsif yn == "y"; open("data/number/input.txt", "w") { |f| f.puts number = number + 1 }
329
+ elsif yn == "N"; puts "Leaving input as is."
330
+ elsif yn == "n"; puts "Leaving input as is."
331
+ elsif yn == "Yes"; open("data/number/input.txt", "w") { |f| f.puts number = number + 1 }
332
+ elsif yn == "yes"; open("data/number/input.txt", "w") { |f| f.puts number = number + 1 }
333
+ elsif yn == "No"; puts "Leaving input as is."
334
+ elsif yn == "no"; puts "Leaving input as is."
335
+ end
336
+ end
337
+
338
+ end
339
+
340
+ ## Symbolic Representation Of Shapes
341
+ class Symbolic
342
+
343
+ def self.line
344
+ require "rules_ai"
345
+
346
+ RulesAi::Rules_Set.line
347
+ end
348
+
349
+ def self.square
350
+ require "rules_ai"
351
+
352
+ RulesAi::Rules_Set.square
353
+ end
354
+
355
+ def self.cube
356
+ require "rules_ai"
357
+
358
+ RulesAi::Rules_Set.cube
359
+ end
360
+
361
+ def self.hyper
362
+ require "rules_ai"
363
+
364
+ RulesAi::Rules_Set.hyper
365
+ end
366
+
367
+ end
368
+
369
+ class Creativity
370
+
371
+ def self.write_poetry
372
+ require "rules_ai"
373
+
374
+ RulesAi::Rules_Set.write_poetry
375
+ end
376
+
377
+ def self.write_poetry
378
+ require "rules_ai"
379
+
380
+ RulesAi::Rules_Set.write_renpy_script
381
+ end
382
+
383
+ end
384
+
385
+ ## Evolutionary Algorithm
386
+ class Evolutionary
387
+ def self.reset_evo
388
+ # Gets the bot shape.
389
+ bot_shape = File.readlines("evo_data/bot_shape/wings.txt")
390
+
391
+ # Create a new input vector based on bot data size.
392
+ bot_input = bot_shape.size.to_i
393
+
394
+ # Reset user input to zero.
395
+ reset_usr_input = 0
396
+
397
+ open("evo_data/number/input.txt", "w") { |f|
398
+ f.puts reset_usr_input
399
+ }
400
+
401
+ # Get random bot_input from bot reset.
402
+ bot_reset = rand(bot_input)
403
+
404
+ open("evo_data/bot_input/input.txt", "w") { |f|
405
+ f.puts bot_reset
406
+ }
407
+ end
408
+
409
+ def self.use_form
410
+ model_type = File.read("evo_data/model/model_type.txt").strip
411
+
412
+ puts 'Form status: Suitable...'
413
+
414
+ sleep(3)
415
+
416
+ number = File.read("evo_data/number/input.txt").strip.to_i
417
+ usr_wings = File.readlines("evo_data/usr_shape/wings.txt")
418
+ current_wingset = usr_wings[number].strip
419
+
420
+ puts "\nModel Type: #{model_type}\nAction: #{current_wingset}\n"
421
+
422
+ sleep(3)
423
+
424
+ # system("ruby #{current_wingset}.rb")
425
+
426
+ if current_wingset == "write_poetry"; ESBI::Creativity.write_poetry
427
+ elsif current_wingset == "line"; ESBI::Symbolic.line
428
+ elsif current_wingset == "square"; ESBI::Symbolic.square
429
+ elsif current_wingset == "cube"; ESBI::Symbolic.cube
430
+ elsif current_wingset == "hyper"; ESBI::Symbolic.hyper
431
+ elsif current_wingset == "dTree"; ESBI::Dynamic.dTree
432
+ elsif current_wingset == "eyes"; ESBI::Eyes.camera
433
+ elsif current_wingset == "evaluate"; ESBI::Naive_Bayes.evaluate
434
+ end
435
+
436
+ reset_evo
437
+
438
+ abort
439
+ end
440
+
441
+ def self.reshape
442
+ system("clear")
443
+
444
+ model_type = File.read("evo_data/model/model_type.txt").strip
445
+
446
+ bot_choice = File.read("evo_data/bot_input/input.txt").strip.to_i
447
+ number = File.read("evo_data/number/input.txt").strip.to_i
448
+
449
+ usr_wings = File.readlines("evo_data/usr_shape/wings.txt")
450
+ bot_wings = File.readlines("evo_data/bot_shape/wings.txt")
451
+
452
+ current_wingset = usr_wings[number]
453
+ current_botwings = bot_wings[bot_choice]
454
+
455
+ puts "The user #{model_type} model is: #{current_wingset}"
456
+
457
+ puts "The bot #{model_type} model is: #{current_botwings}"
458
+
459
+ if current_wingset == current_botwings
460
+ use_form
461
+ else
462
+ puts "Form status: Changing form..."
463
+
464
+ sleep(3)
465
+
466
+ new_value = number + 1
467
+
468
+ open("evo_data/number/input.txt", "w") { |f|
469
+ f.puts new_value
470
+ }
471
+ end
472
+
473
+ ESBI::Evolutionary.reshape
474
+ end
475
+ end
476
+
477
+ # Smart Translation
478
+ class Translate
479
+
480
+ def self.translate
481
+ number = File.read("data/input/number.txt").strip.to_i
482
+ input = File.readlines("data/input/input.txt")
483
+
484
+ active_input = input[number].downcase.split(" ")
485
+
486
+ translate = {
487
+ 'ruh' => "the-masculine",
488
+ 'rah' => "the-feminine",
489
+ 'roh' => "the-neuter",
490
+ 'yona' => "a",
491
+ 'yonei' => "an",
492
+ 'yonas' => "a-neuter",
493
+ 'eneru' => "black",
494
+ 'berena' => "white",
495
+ 'erudi' => "red",
496
+ 'eviyette' => "purple",
497
+ 'beru' => "red",
498
+ 'evene' => "green",
499
+ 'yeru' => "yellow",
500
+ 'eranige' => "orange",
501
+ 'enesu' => "North",
502
+ 'wesi' => "West",
503
+ 'easi' => "East",
504
+ 'siuha' => "South",
505
+ 'upe' => "up",
506
+ 'dio' => "down",
507
+ 'feru' => "dorward",
508
+ 'biosi' => "backward",
509
+ 'iniwa' => "inward",
510
+ 'utiwa' => "outward",
511
+ 'esakeru' => "sneakers",
512
+ 'deruesu' => "dress-shoes",
513
+ 'eheru' => "heels",
514
+ 'siabi' => "clogs",
515
+ 'siabi-biesa' => "wooden-clogs",
516
+ 'berukiesiti' => "birkenstocks",
517
+ 'esiadi' => "sandals",
518
+ 'tero' => "trousers",
519
+ 'sikeru' => "skirt",
520
+ 'deresi' => "dress",
521
+ 'sehiere' => "shirt",
522
+ 'sioki' => "stocking",
523
+ 'sitaka' => "socks",
524
+ 'sitaki' => "steak",
525
+ 'siho-sitaki' => "chop-steak",
526
+ 'befi' => "beef",
527
+ 'shikini' => "chicken",
528
+ 'tieru' => "turkey",
529
+ 'liam' => "lamb",
530
+ 'ehaki' => "elk",
531
+ 'deru' => "deer",
532
+ 'pirosi' => "porc",
533
+ 'bieru' => "bear",
534
+ 'siaro' => "carrot",
535
+ 'pitat' => "potato",
536
+ 'siaba' => "cabbage",
537
+ 'sipinas' => "spinach",
538
+ 'eretuce' => "lettuce",
539
+ 'siwa-pitat' => "sweet-potato",
540
+ 'ginie' => "ginger",
541
+ 'siquasi' => "squash",
542
+ 'piemaki' => "pumpkin",
543
+ 'tea' => "tea",
544
+ 'siofee' => "coffee",
545
+ 'eribos' => "herbs",
546
+ 'givimio' => 'give-me',
547
+ 'ehieru' => 'hour',
548
+ 'vieruti' => 'vortex',
549
+ 'perumipito' => 'promptor',
550
+ 'esipier' => 'cipher',
551
+ 'digisi-esitimi' => 'digest estimate',
552
+ 'ehypier-sierusutio' => 'hyper calculation',
553
+ }
554
+
555
+ word_01 = translate[active_input[0]]
556
+ word_02 = translate[active_input[1]]
557
+ word_03 = translate[active_input[2]]
558
+ word_04 = translate[active_input[3]]
559
+ word_05 = translate[active_input[4]]
560
+ word_06 = translate[active_input[5]]
561
+ word_07 = translate[active_input[6]]
562
+ word_08 = translate[active_input[7]]
563
+ word_09 = translate[active_input[8]]
564
+ word_10 = translate[active_input[9]]
565
+
566
+ translated = "Translated: #{word_01} #{word_02} #{word_03} #{word_04} #{word_05} #{word_06} #{word_07} #{word_08} #{word_09} #{word_10}"
567
+
568
+ open("output/translator/translation.txt", "w") { |f|
569
+ f.puts translated
570
+ }
571
+ end
572
+
573
+ def self.classify
574
+ def self.download_data
575
+ system("cd data/baysian; w3m /home/sarah/public_sync/downloads/shared_dataset/language.nb")
576
+ end
577
+
578
+ def self.naive_bayes
579
+ require "naive_bayes"
580
+
581
+ a = NaiveBayes.load('data/baysian/language.nb')
582
+
583
+ # b = File.read("data/input/document.txt").split(' ')
584
+
585
+ number = File.read("data/input/number.txt").strip.to_i
586
+ input = File.read("data/input/input.txt")
587
+
588
+ b = input[number].downcase.split(" ")
589
+
590
+ word_one = a.classify(*b[0])
591
+ word_two = a.classify(*b[1])
592
+ word_tre = a.classify(*b[2])
593
+ word_fro = a.classify(*b[3])
594
+ word_fiv = a.classify(*b[4])
595
+ word_six = a.classify(*b[5])
596
+ word_sev = a.classify(*b[6])
597
+
598
+ ## Labels
599
+ first_label = word_one[0]
600
+ second_label = word_two[0]
601
+ third_label = word_tre[0]
602
+ fourth_label = word_fro[0]
603
+ fifth_label = word_fiv[0]
604
+ sixth_label = word_six[0]
605
+ seven_label = word_sev[0]
606
+
607
+ ## Probabilities
608
+ first_prob = word_one[1]
609
+ second_prob = word_two[1]
610
+ third_prob = word_tre[1]
611
+ fourth_prob = word_fro[1]
612
+ fifth_prob = word_fiv[1]
613
+ sixth_prob = word_six[1]
614
+ seven_prob = word_sev[1]
615
+
616
+ open("output/baysian/labels.txt", "w") { |f|
617
+ f.puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}"
618
+ }
619
+
620
+ open("output/baysian/probabilities.txt", "w") { |f|
621
+ f.puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}"
622
+ }
623
+
624
+ puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}\n"
625
+ puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}\n\n"
626
+ end
627
+
628
+ def self.remove_data
629
+ system("cd data/baysian; shred --remove language.nb")
630
+ end
631
+
632
+ SmartTranslator::Translate.classify.download_data
633
+ SmartTranslator::Translate.classify.naive_bayes
634
+ SmartTranslator::Translate.classify.remove_data
635
+ end
636
+
637
+ def self.rules_ai
638
+ number = File.read("data/input/number.txt").strip.to_i
639
+ command = File.readlines("data/input/input.txt")
640
+
641
+ input = command[number]
642
+
643
+ case input
644
+
645
+ when "Givimio ruh ehieru"
646
+ require "rules_ai"; RulesAi::Rules_Set.hours_passed
647
+ when "Givimio ruh vieruti"
648
+ require "rules_ai"; RulesAi::Rules_Set.tesla_multiplication
649
+ when "Givimio ruh perumipito"
650
+ require "rules_ai"; RulesAi::Rules_Set.autonomous_prompting
651
+ when "Givimio ruh esipier"
652
+ require "rules_ai"; RulesAi::Rules_Set.mixed_13
653
+ when "Givimio yona digisi esitimi"
654
+ require "rules_ai"; RulesAi::Rules_Set.estimate_digest
655
+ when "Givimio yona ehypier sierusutio"
656
+ require "rules_ai"; RulesAi::Rules_Set.calculate_hyper
657
+ when "Givimio yona ehini"
658
+ require "rules_ai"; RulesAi::Rules_Set.line
659
+ when "Givimio yona esiqieru"
660
+ require "rules_ai"; RulesAi::Rules_Set.square
661
+ when "Givimio yona esibu"
662
+ require "rules_ai"; RulesAi::Rules_Set.cube
663
+ when "Givimio yona ehypier esibu"
664
+ require "rules_ai"; RulesAi::Rules_Set.hyper
665
+ when "Givimio yona epieru"
666
+ require "rules_ai"; RulesAi::Rules_Set.write_poetry
667
+ when "Givimio yona enu eheru"
668
+ require "rules_ai"; RulesAi::New_Routine.generate_ruleset
669
+ else
670
+ puts "#{bot_name}: No rule for this specific sentence."
671
+ end
672
+ end
673
+
674
+ def self.down_index
675
+ number = File.read("data/input/number.txt").to_i
676
+
677
+ open("data/input/number.txt", "w") { |f|
678
+ f.puts number = number + 1
679
+ }
680
+ end
681
+
682
+ def self.up_index
683
+ number = File.read("data/input/number.txt").to_i
684
+
685
+ open("data/input/number.txt", "w") { |f|
686
+ f.puts number = number - 1
687
+ }
688
+ end
689
+ end
690
+ end
@@ -0,0 +1,3 @@
1
+ module ESBI
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ESBI
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gitea
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rules_ai
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: naive_bayes
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
41
+ description: A hybrid model of different systems of AI and rules based programming
42
+ for different purposes. This uses the rules_ai gem..
43
+ email:
44
+ - gitea@fake.local
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - ESBI.gemspec
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/ESBI.rb
59
+ - lib/ESBI/version.rb
60
+ homepage: https://lwflouisa.github.io/Weaver-AI
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.3.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.1.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Evolutionary-Symbolic-Baysian and Ruleset AI with smart translation.
83
+ test_files: []