Module: Translator::CatLang
Instance Method Summary collapse
- #cat_char_dict ⇒ Object
- #cat_to_human(name, cat_text) ⇒ Object
- #cat_to_number(cat_text) ⇒ Object
- #cat_tone_dict ⇒ Object
- #decompose(statement) ⇒ Object
- #human_to_cat(name, human_text) ⇒ Object
- #number_to_cat(number_text) ⇒ Object
Methods included from NumberLang
#human_to_number, #number_to_human
Instance Method Details
#cat_char_dict ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/catspeak/translator.rb', line 43 def cat_char_dict [ 'MEOW','MeOW','MEoW','MEOw','MEow','MeOw','MeoW','Meow', #8 'mEOW','meOW','mEoW','mEOw','mEow','meOw','meoW','meow', #16 'MEOU','MeOU','MEoU','MEOu','MEou','MeOu','MeoU','Meou', #24 'mEOU','meOU','mEoU','mEOu','mEou','meOu','meoU','meou', #32 'MEO' ,'MEo' ,'MeO' ,'Meo' ,'mEO' ,'mEo' ,'meO' ,'meo' , #40 'MAOW','MaOW','MAoW','MAOw','MAow','MaOw','MaoW','Maow', #48 'mAOW','maOW','mAoW','mAOw','mAow','maOw','maoW','maow', #56 'MAOU','MaOU','MAoU','MAOu','MAou','MaOu','MaoU','Maou', #64 'mAOU','maOU','mAoU','mAOu','mAou','maOu','maoU','maou', #72 'MAO' ,'MAo' ,'MaO' ,'Mao' ,'mAO' ,'mAo' ,'maO' ,'mao' , #80 'MIAO','MIaO','MIAo','MiAO','MiAo','MiaO','MIao','Miao', #88 'mIAO','mIaO','mIAo','miAO','miAo','miaO','mIao','miao', #96 'MIA' ,'MIa' ,'MiA' ,'Mia' ,'mIA' ,'mIa' ,'miA' ,'mia' , #104 'ME' ,'Me' ,'mE' ,'me' ,'MA' ,'Ma' ,'mA' ,'ma' , #112 'MW' ,'Mw' ,'mW' ,'mw' ,'MU' ,'Mu' ,'mU' ,'mu' , #120 'MI' ,'Mi' ,'mI' ,'mi' ,'MM' ,'Mm' ,'mM' ,'mm' , #128 'MEE' ,'MEe' ,'MeE' ,'Mee' ,'mEE' ,'mEe' ,'meE' ,'mee' , #136 'MAW' ,'MAw' ,'MaW' ,'Maw' ,'mAW' ,'mAw' ,'maW' ,'maw' , #144 'EE' ,'Ee' ,'eE' ,'ee' ,'II' ,'Ii' ,'iI' ,'ii' , #152 'I' ,'i' ,'E' ,'e' ,'M' ,'m' ,'A' ,'a' , #160 'MOW' ,'MoW' ,'MOw' ,'Mow' ,'mOW' ,'moW' ,'mOw' ,'mow' , #168 'MImi','Mimi','mImi','mimi','MIMi','MiMi','mIMi','miMi', #176 'MImI','MimI','mImI','mimI','MIMI','MiMI','mIMI','miMI', #184 'MEA' ,'MEa' ,'MeA' ,'Mea' ,'mEA' ,'mEa' ,'meA' ,'mea' , #192 'MIU' ,'MIu' ,'MiU' ,'Miu' ,'mIU' ,'mIu' ,'miU' ,'miu' , #200 'MAAO','MAAo','MaAO','MaAo','mAAO','mAAo','maAO','maAo', #208 'MAaO','MAao','MaaO','Maao','mAaO','mAao','maaO','maao', #216 'MEAO','MEaO','MEAo','MeAO','MeAo','MeaO','MEao','Meao', #224 'mEAO','mEaO','mEAo','meAO','meAo','meaO','mEao','meao', #232 'MOO' ,'MOo' ,'MoO' ,'Moo' ,'mOO' ,'mOo' ,'moO' ,'moo' , #240 'UM' ,'Um' ,'uM' ,'um' ,'MUM' ,'Mum' ,'mum' ,'MeeoW', #248 'MEU' ,'Meu' ,'meu' ,'MEW' ,'Mew' ,'mew' ,'Meeow','meeow' #256 ] end |
#cat_to_human(name, cat_text) ⇒ Object
150 151 152 153 |
# File 'lib/catspeak/translator.rb', line 150 def cat_to_human(name, cat_text) number_text = cat_to_number(cat_text) number_to_human(name, number_text) end |
#cat_to_number(cat_text) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/catspeak/translator.rb', line 133 def cat_to_number(cat_text) number_text = decompose(cat_text) number_text.each_index do |i| if (i.even?) number_text[i] = cat_char_dict.index(number_text[i]) else number_text[i] = cat_tone_dict.index(number_text[i]) end end number_text end |
#cat_tone_dict ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/catspeak/translator.rb', line 81 def cat_tone_dict [ ' ' ,' ' ,' ', '.' ,'. ' ,'...' ,'... ',' ...',' ... ', '??~','!!~' ,'~!!','~??','?~?','!~!',' ??~',' !!~' ,' ~!!',' ~??',' ?~?',' !~!', '^','^^','^ ','^^ ','~^','~^ ','~~^','~~^ ','~~?','~~? ','~~!','~~! ', ' ~~^',' ~~^ ',' ~~?',' ~~? ',' ~~!',' ~~! ',' ~^',' ~^ ', ',',', ', ':',': ', '! ','~ ','- ','? ','. ',', ',': ', ' !',' ~',' -',' ?',' .',' ,',' :', ' ! ',' ~ ',' - ',' ? ',' . ',' , ',' : ', ' !!',' ??',' ~~', "'"," '","' ", '!' ,'!!' ,'!!!' ,'!!!!','! ' ,'!! ' ,'!!! ' ,'!!!! ', '~' ,'~~' ,'~~~' ,'~~~~','~ ' ,'~~ ' ,'~~~ ' ,'~~~~ ', '-' ,'--' ,'---' ,'----','- ' ,'-- ' ,'--- ' ,'---- ', '?' ,'??' ,'???' ,'????','? ' ,'?? ' ,'??? ' ,'???? ', "!!!?", "!!?!", "!!??", "!?!!", "!?!?", "!??!", "!???", "?!!!", "?!!?", "?!?!", "?!??", "??!!", "??!?", "???!", "!!!? ", "!!?! ", "!!?? ", "!?!! ", "!?!? ", "!??! ", "!??? ", "?!!! ", "?!!? ", "?!?! ", "?!?? ", "??!! ", "??!? ", "???! ", "~~~?", "~~??", "~?~?", "~???", "?~~~", "?~~?", "?~?~", "?~??", "??~~", "??~?", "???~", "~~~? ", "~~?? ", "~?~? ", "~??? ", "?~~~ ", "?~~? ", "?~?~ ", "?~?? ", "??~~ ", "??~? ", "???~ ", "~~~!", "~~!!", "~!~!", "~!!!", "!~~~", "!~~!", "!~!~", "!~!!", "!!~~", "!!~!", "!!!~", "~~~! ", "~~!! ", "~!~! ", "~!!! ", "!~~~ ", "!~~! ", "!~!~ ", "!~!! ", "!!~~ ", "!!~! ", "!!!~ ", "---?", "--??", "-?-?", "-???", "?---", "?-?-", "?-??", "??-?", "???-", "---!", "--!!", "-!-!", "-!!!", "!---", "!-!-", "!-!!", "!!-!", "!!!-", "---? ", "--?? ", "-?-? ", "-??? ", "?--- ", "?-?- ", "?-?? ", "??-? ", "???- ", "---! ", "--!! ", "-!-! ", "-!!! ", "!--- ", "!-!- ", "!-!! ", "!!-! ", "!!!- ", '=(>.<)=', '-(>.<)-','=(".")=','-(".")-',"=('.')=","-('.')-", '\(>.<)/', '\(".")/','=(^.^)=','-(^.^)-','\(^.^)/','=(~.~)=', '-(~.~)-', '\(~.~)/', '=(*.*)=', '-(*.*)-', '\(*.*)/','=(`.`)=','-(`.`)-','\(`.`)/','=(-.-)=','\(-.-)/', '=(>.<)= ', '-(>.<)- ','=(".")= ','-(".")- ',"=('.')= ","-('.')- ", '\(>.<)/ ', '\(".")/ ','=(^.^)= ','-(^.^)- ','\(^.^)/ ','=(~.~)= ', '-(~.~)- ', '\(~.~)/ ', '=(*.*)= ', '-(*.*)- ', '\(*.*)/ ','=(`.`)= ','-(`.`)- ','\(`.`)/ ','=(-.-)= ','\(-.-)/ ' ] end |
#decompose(statement) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/catspeak/translator.rb', line 155 def decompose(statement) # TODO: should get the regular expression from the dictionary. Simply get all the characters from it and get the unique characters statement.scan(/(\w+)?(\W+)?/).flatten.compact #a1 = statement.split(/\W+/) #a2 = statement.split(/\w+/) #a2.delete_at(0) #a2.each_index do |i| # a1.insert(2*i+1,a2[i]) #end #a1 #a3 = [] #a1.each_index do |i| # a3 = a3+Array.new(1,a1[i]) # if (!a2[i].nil?) # a3 = a3+Array.new(1,a2[i]) # end #end #a3 end |
#human_to_cat(name, human_text) ⇒ Object
145 146 147 148 |
# File 'lib/catspeak/translator.rb', line 145 def human_to_cat(name, human_text) number_text = human_to_number(name, human_text) number_to_cat(number_text) end |
#number_to_cat(number_text) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/catspeak/translator.rb', line 121 def number_to_cat(number_text) cat_text = '' number_text.length.times do |i| if (i.even?) cat_text = cat_text + cat_char_dict[number_text[i]] else cat_text = cat_text + cat_tone_dict[number_text[i]] end end cat_text end |