class ESBI::Translate
Smart Translation
Public Class Methods
classify()
click to toggle source
# File lib/ESBI.rb, line 573 def self.classify def self.download_data system("cd data/baysian; w3m /home/sarah/public_sync/downloads/shared_dataset/language.nb") end def self.naive_bayes require "naive_bayes" a = NaiveBayes.load('data/baysian/language.nb') # b = File.read("data/input/document.txt").split(' ') number = File.read("data/input/number.txt").strip.to_i input = File.read("data/input/input.txt") b = input[number].downcase.split(" ") word_one = a.classify(*b[0]) word_two = a.classify(*b[1]) word_tre = a.classify(*b[2]) word_fro = a.classify(*b[3]) word_fiv = a.classify(*b[4]) word_six = a.classify(*b[5]) word_sev = a.classify(*b[6]) ## Labels first_label = word_one[0] second_label = word_two[0] third_label = word_tre[0] fourth_label = word_fro[0] fifth_label = word_fiv[0] sixth_label = word_six[0] seven_label = word_sev[0] ## Probabilities first_prob = word_one[1] second_prob = word_two[1] third_prob = word_tre[1] fourth_prob = word_fro[1] fifth_prob = word_fiv[1] sixth_prob = word_six[1] seven_prob = word_sev[1] open("output/baysian/labels.txt", "w") { |f| f.puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}" } open("output/baysian/probabilities.txt", "w") { |f| f.puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}" } puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}\n" 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" end def self.remove_data system("cd data/baysian; shred --remove language.nb") end SmartTranslator::Translate.classify.download_data SmartTranslator::Translate.classify.naive_bayes SmartTranslator::Translate.classify.remove_data end
down_index()
click to toggle source
# File lib/ESBI.rb, line 674 def self.down_index number = File.read("data/input/number.txt").to_i open("data/input/number.txt", "w") { |f| f.puts number = number + 1 } end
download_data()
click to toggle source
# File lib/ESBI.rb, line 574 def self.download_data system("cd data/baysian; w3m /home/sarah/public_sync/downloads/shared_dataset/language.nb") end
naive_bayes()
click to toggle source
# File lib/ESBI.rb, line 578 def self.naive_bayes require "naive_bayes" a = NaiveBayes.load('data/baysian/language.nb') # b = File.read("data/input/document.txt").split(' ') number = File.read("data/input/number.txt").strip.to_i input = File.read("data/input/input.txt") b = input[number].downcase.split(" ") word_one = a.classify(*b[0]) word_two = a.classify(*b[1]) word_tre = a.classify(*b[2]) word_fro = a.classify(*b[3]) word_fiv = a.classify(*b[4]) word_six = a.classify(*b[5]) word_sev = a.classify(*b[6]) ## Labels first_label = word_one[0] second_label = word_two[0] third_label = word_tre[0] fourth_label = word_fro[0] fifth_label = word_fiv[0] sixth_label = word_six[0] seven_label = word_sev[0] ## Probabilities first_prob = word_one[1] second_prob = word_two[1] third_prob = word_tre[1] fourth_prob = word_fro[1] fifth_prob = word_fiv[1] sixth_prob = word_six[1] seven_prob = word_sev[1] open("output/baysian/labels.txt", "w") { |f| f.puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}" } open("output/baysian/probabilities.txt", "w") { |f| f.puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}" } puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}\n" 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" end
remove_data()
click to toggle source
# File lib/ESBI.rb, line 628 def self.remove_data system("cd data/baysian; shred --remove language.nb") end
rules_ai()
click to toggle source
# File lib/ESBI.rb, line 637 def self.rules_ai number = File.read("data/input/number.txt").strip.to_i command = File.readlines("data/input/input.txt") input = command[number] case input when "Givimio ruh ehieru" require "rules_ai"; RulesAi::Rules_Set.hours_passed when "Givimio ruh vieruti" require "rules_ai"; RulesAi::Rules_Set.tesla_multiplication when "Givimio ruh perumipito" require "rules_ai"; RulesAi::Rules_Set.autonomous_prompting when "Givimio ruh esipier" require "rules_ai"; RulesAi::Rules_Set.mixed_13 when "Givimio yona digisi esitimi" require "rules_ai"; RulesAi::Rules_Set.estimate_digest when "Givimio yona ehypier sierusutio" require "rules_ai"; RulesAi::Rules_Set.calculate_hyper when "Givimio yona ehini" require "rules_ai"; RulesAi::Rules_Set.line when "Givimio yona esiqieru" require "rules_ai"; RulesAi::Rules_Set.square when "Givimio yona esibu" require "rules_ai"; RulesAi::Rules_Set.cube when "Givimio yona ehypier esibu" require "rules_ai"; RulesAi::Rules_Set.hyper when "Givimio yona epieru" require "rules_ai"; RulesAi::Rules_Set.write_poetry when "Givimio yona enu eheru" require "rules_ai"; RulesAi::New_Routine.generate_ruleset else puts "#{bot_name}: No rule for this specific sentence." end end
translate()
click to toggle source
# File lib/ESBI.rb, line 480 def self.translate number = File.read("data/input/number.txt").strip.to_i input = File.readlines("data/input/input.txt") active_input = input[number].downcase.split(" ") translate = { 'ruh' => "the-masculine", 'rah' => "the-feminine", 'roh' => "the-neuter", 'yona' => "a", 'yonei' => "an", 'yonas' => "a-neuter", 'eneru' => "black", 'berena' => "white", 'erudi' => "red", 'eviyette' => "purple", 'beru' => "red", 'evene' => "green", 'yeru' => "yellow", 'eranige' => "orange", 'enesu' => "North", 'wesi' => "West", 'easi' => "East", 'siuha' => "South", 'upe' => "up", 'dio' => "down", 'feru' => "dorward", 'biosi' => "backward", 'iniwa' => "inward", 'utiwa' => "outward", 'esakeru' => "sneakers", 'deruesu' => "dress-shoes", 'eheru' => "heels", 'siabi' => "clogs", 'siabi-biesa' => "wooden-clogs", 'berukiesiti' => "birkenstocks", 'esiadi' => "sandals", 'tero' => "trousers", 'sikeru' => "skirt", 'deresi' => "dress", 'sehiere' => "shirt", 'sioki' => "stocking", 'sitaka' => "socks", 'sitaki' => "steak", 'siho-sitaki' => "chop-steak", 'befi' => "beef", 'shikini' => "chicken", 'tieru' => "turkey", 'liam' => "lamb", 'ehaki' => "elk", 'deru' => "deer", 'pirosi' => "porc", 'bieru' => "bear", 'siaro' => "carrot", 'pitat' => "potato", 'siaba' => "cabbage", 'sipinas' => "spinach", 'eretuce' => "lettuce", 'siwa-pitat' => "sweet-potato", 'ginie' => "ginger", 'siquasi' => "squash", 'piemaki' => "pumpkin", 'tea' => "tea", 'siofee' => "coffee", 'eribos' => "herbs", 'givimio' => 'give-me', 'ehieru' => 'hour', 'vieruti' => 'vortex', 'perumipito' => 'promptor', 'esipier' => 'cipher', 'digisi-esitimi' => 'digest estimate', 'ehypier-sierusutio' => 'hyper calculation', } word_01 = translate[active_input[0]] word_02 = translate[active_input[1]] word_03 = translate[active_input[2]] word_04 = translate[active_input[3]] word_05 = translate[active_input[4]] word_06 = translate[active_input[5]] word_07 = translate[active_input[6]] word_08 = translate[active_input[7]] word_09 = translate[active_input[8]] word_10 = translate[active_input[9]] translated = "Translated: #{word_01} #{word_02} #{word_03} #{word_04} #{word_05} #{word_06} #{word_07} #{word_08} #{word_09} #{word_10}" open("output/translator/translation.txt", "w") { |f| f.puts translated } end
up_index()
click to toggle source
# File lib/ESBI.rb, line 682 def self.up_index number = File.read("data/input/number.txt").to_i open("data/input/number.txt", "w") { |f| f.puts number = number - 1 } end