Best JavaScript code snippet using taiko
CTF-Tools.py
Source:CTF-Tools.py
...29 # self.setFixedSize(self.width(), self.height()) ##设置宽é«ä¸å¯å30 self.setWindowIcon(QtGui.QIcon('./logo.ico'))31 self.Ui.Source_clear_Button.clicked.connect(lambda:self.Ui.Source_text.clear()) # clear_source32 self.Ui.Result_clear_Button.clicked.connect(lambda:self.Ui.Result_text.clear()) # clear_result33 self.Ui.Source_Copy_Button.clicked.connect(lambda:self.Copy_text('Source')) # copy_source34 self.Ui.Result_Copy_Button.clicked.connect(lambda:self.Copy_text('result')) # copy_result35 self.Ui.Source_tihuan_Button.clicked.connect(lambda:self.tihuan('Source')) # tihuan_source36 self.Ui.Result_tihuan_Button.clicked.connect(lambda:self.tihuan('result')) # tihuan_result37 self.Ui.Source_Paste_Button.clicked.connect(lambda: self.paste('Source')) # paste_Source38 self.Ui.Result_Paste_Button.clicked.connect(lambda: self.paste('result')) # paste_result39 #encode40 self.Ui.actionURL_UTF8_encode.triggered.connect(lambda:self.encode(self.Ui.actionURL_UTF8_encode.text()))41 self.Ui.actionURL_GB2312_encode.triggered.connect(lambda: self.encode(self.Ui.actionURL_GB2312_encode.text()))42 self.Ui.actionUnicode_encode.triggered.connect(lambda: self.encode(self.Ui.actionUnicode_encode.text()))43 self.Ui.actionEscape_U_encode.triggered.connect(lambda: self.encode(self.Ui.actionEscape_U_encode.text()))44 self.Ui.actionHtmlEncode_encode.triggered.connect(lambda: self.encode(self.Ui.actionHtmlEncode_encode.text()))45 self.Ui.actionASCII_encode.triggered.connect(lambda: self.encode(self.Ui.actionASCII_encode.text()))46 self.Ui.actionBase16_encode.triggered.connect(lambda: self.encode(self.Ui.actionBase16_encode.text()))47 self.Ui.actionBase32_encode.triggered.connect(lambda: self.encode(self.Ui.actionBase32_encode.text()))48 self.Ui.actionBase64_encode.triggered.connect(lambda: self.encode(self.Ui.actionBase64_encode.text()))49 self.Ui.actionStr_Hex_encode.triggered.connect(lambda: self.encode(self.Ui.actionStr_Hex_encode.text()))50 self.Ui.actionShellcode_encode.triggered.connect(lambda: self.encode(self.Ui.actionShellcode_encode.text()))51 self.Ui.actionQwerty_encode.triggered.connect(lambda: self.encode(self.Ui.actionQwerty_encode.text()))52 self.Ui.actiontupian_base64_encode.triggered.connect(lambda: self.encode(self.Ui.actiontupian_base64_encode.text()))53 #decode54 self.Ui.actionURL_UTF8_decode.triggered.connect(lambda:self.decode(self.Ui.actionURL_UTF8_decode.text()))55 self.Ui.actionURL_GB2312_decode.triggered.connect(lambda: self.decode(self.Ui.actionURL_GB2312_decode.text()))56 self.Ui.actionUnicode_decode.triggered.connect(lambda: self.decode(self.Ui.actionUnicode_decode.text()))57 self.Ui.actionEscape_U_decode.triggered.connect(lambda: self.decode(self.Ui.actionEscape_U_decode.text()))58 self.Ui.actionHtmlEncode_decode.triggered.connect(lambda: self.decode(self.Ui.actionHtmlEncode_decode.text()))59 self.Ui.actionASCII_decode.triggered.connect(lambda: self.decode(self.Ui.actionASCII_decode.text()))60 self.Ui.actionBase16_decode.triggered.connect(lambda: self.decode(self.Ui.actionBase16_decode.text()))61 self.Ui.actionBase32_decode.triggered.connect(lambda: self.decode(self.Ui.actionBase32_decode.text()))62 self.Ui.actionBase64_decode.triggered.connect(lambda: self.decode(self.Ui.actionBase64_decode.text()))63 self.Ui.actionHex_Str_decode.triggered.connect(lambda: self.decode(self.Ui.actionHex_Str_decode.text()))64 self.Ui.actionShellcode_decode.triggered.connect(lambda: self.decode(self.Ui.actionShellcode_decode.text()))65 self.Ui.actionQwerty_decode.triggered.connect(lambda: self.decode(self.Ui.actionQwerty_decode.text()))66 self.Ui.actionbase64_tupian_decode.triggered.connect(lambda: self.decode(self.Ui.actionbase64_tupian_decode.text()))67 #encrypt68 self.Ui.actionRot13_encrypt.triggered.connect(lambda:self.encrypt(self.Ui.actionRot13_encrypt.text()))69 self.Ui.action_kaisa_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_kaisa_encrypt.text()))70 self.Ui.action_zhalan_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_zhalan_encrypt.text()))71 self.Ui.action_peigen_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_peigen_encrypt.text()))72 self.Ui.action_mosi_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_mosi_encrypt.text()))73 self.Ui.action_yunying_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_yunying_encrypt.text()))74 self.Ui.action_dangpu_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_dangpu_encrypt.text()))75 self.Ui.action_sifang_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_sifang_encrypt.text()))76 self.Ui.action_weinijiya_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_weinijiya_encrypt.text()))77 self.Ui.action_Atbash_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_Atbash_encrypt.text()))78 self.Ui.action_fangshe_encrypt.triggered.connect(lambda: self.encrypt(self.Ui.action_fangshe_encrypt.text()))79 #decrypt80 self.Ui.actionRot13_decrypt.triggered.connect(lambda:self.decrypt(self.Ui.actionRot13_decrypt.text()))81 self.Ui.action_kaisa_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_kaisa_decrypt.text()))82 self.Ui.action_zhalan_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_zhalan_decrypt.text()))83 self.Ui.action_peihen_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_peihen_decrypt.text()))84 self.Ui.action_mosi_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_mosi_decrypt.text()))85 self.Ui.action_yiwei_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_yiwei_decrypt.text()))86 self.Ui.action_yunxing_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_yunxing_decrypt.text()))87 self.Ui.action_dangpu_decry.triggered.connect(lambda: self.decrypt(self.Ui.action_dangpu_decry.text()))88 self.Ui.action_sifang_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_sifang_decrypt.text()))89 self.Ui.action_weinijiya_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_weinijiya_decrypt.text()))90 self.Ui.action_Atbash_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_Atbash_decrypt.text()))91 self.Ui.action_fangshe_decrypt.triggered.connect(lambda: self.decrypt(self.Ui.action_fangshe_decrypt.text()))92 #è¿å¶è½¬æ¢93 self.Ui.action2_8.triggered.connect(lambda:self.Binary(self.Ui.action2_8.text()))94 self.Ui.action2_10.triggered.connect(lambda: self.Binary(self.Ui.action2_10.text()))95 self.Ui.action2_16.triggered.connect(lambda: self.Binary(self.Ui.action2_16.text()))96 self.Ui.action8_2.triggered.connect(lambda: self.Binary(self.Ui.action8_2.text()))97 self.Ui.action8_10.triggered.connect(lambda: self.Binary(self.Ui.action8_10.text()))98 self.Ui.action8_16.triggered.connect(lambda: self.Binary(self.Ui.action8_16.text()))99 self.Ui.action10_2.triggered.connect(lambda: self.Binary(self.Ui.action10_2.text()))100 self.Ui.action10_8.triggered.connect(lambda: self.Binary(self.Ui.action10_8.text()))101 self.Ui.action10_16.triggered.connect(lambda: self.Binary(self.Ui.action10_16.text()))102 self.Ui.action16_2.triggered.connect(lambda: self.Binary(self.Ui.action16_2.text()))103 self.Ui.action16_8.triggered.connect(lambda: self.Binary(self.Ui.action16_8.text()))104 self.Ui.action16_10.triggered.connect(lambda: self.Binary(self.Ui.action16_10.text()))105 self.Ui.action_others.triggered.connect(lambda: self.Binary(self.Ui.action_others.text()))106 self.Ui.actionAbout.triggered.connect(self.about)107 self.Ui.actionAuthor.triggered.connect(self.author)108 self.Ui.actionUpdate_2.triggered.connect(self.Update)109 self.readfile()110 #Website111 websitemenubar = self.menuBar() # è·åçªä½çèåæ 112 Website = websitemenubar.addMenu("Website")113 for i in json_data:114 impMenu = QMenu(i, self)115 url_list = json_data[i].split('\n')116 for j in url_list:117 sub_action = QAction(QIcon(''), j, self)118 impMenu.addAction(sub_action)119 Website.addMenu(impMenu)120 Website.triggered[QAction].connect(self.show_json)121 #Plugins122 Pluginsmenubar = self.menuBar() # è·åçªä½çèåæ 123 plugins = Pluginsmenubar.addMenu("Plugins")124 for k in plugins_data:125 # print(k)126 sub_action = QAction(QIcon(''), k, self)127 plugins.addAction(sub_action)128 plugins.triggered[QAction].connect(self.show_plugins)129 #Others130 othersmenubar = self.menuBar() # è·åçªä½çèåæ 131 others = othersmenubar.addMenu("Others")132 for j in ["About",'Author','Update']:133 sub_action = QAction(QIcon(''), j, self)134 others.addAction(sub_action)135 impMenu = QMenu("Style", self)136 for z in json_qss:137 sub_action = QAction(QIcon(''), z, self)138 impMenu.addAction(sub_action)139 others.addMenu(impMenu)140 others.triggered[QAction].connect(self.show_others)141 def show_others(self,q):142 if q.text() =="About":143 self.about()144 return145 if q.text() =="Author":146 self.author()147 return148 if q.text() =="Update":149 self.Update()150 return151 else:152 try:153 with open("QSS/" + json_qss[q.text()], 'r', encoding='utf-8') as f:154 qss_style = f.read()155 f.close()156 MainWindows.setStyleSheet(self, qss_style)157 f = open('QSS/Setup.txt', 'w', encoding='utf-8')158 f.write('{"QSS": "%s"}'%json_qss[q.text()])159 f.close()160 python = sys.executable161 os.execl(python, python, *sys.argv)162 except Exception as e:163 QMessageBox.critical(self, 'Error', str(e))164 pass165 def show_plugins(self,q):166 try:167 plugins_methods = "Plugins/" + plugins_data[q.text()][:-3]168 filename = "Plugins/" + plugins_data[q.text()]169 text = self.Ui.Source_text.toPlainText()170 if text=='':171 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼')172 return 0173 nnnnnnnnnnnn1 = importlib.machinery.SourceFileLoader(plugins_methods, filename).load_module()174 result = nnnnnnnnnnnn1.run(text)175 self.Ui.Result_text.setText(str(result))176 except Exception as e:177 QMessageBox.critical(self, 'Error', str(e))178 pass179 def show_json(self,q):180 # print(q.text())181 wincld.OpenClipboard()182 wincld.EmptyClipboard()183 wincld.SetClipboardData(win32con.CF_UNICODETEXT, q.text())184 wincld.CloseClipboard()185 reply = QMessageBox.question(self, 'Message', "é¾æ¥å·²å¤å¶å°åªåæ¿ï¼æ¯å¦å¨æµè§å¨ä¸æå¼é¾æ¥?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)186 if reply == QMessageBox.Yes:187 webbrowser.open(q.text())188 else:189 pass190 def readfile(self):191 try:192 global json_data193 f=open('data.json','r',encoding='utf-8')194 json_data=json.load(f)195 # print(json_data)196 f.close()197 global json_qss198 f=open('QSS/list.txt','r',encoding='utf-8')199 json_qss=json.load(f)200 # print(json_data)201 f.close()202 f=open('QSS/Setup.txt','r',encoding='utf-8')203 qss_Setup=json.load(f)204 with open("QSS/"+qss_Setup["QSS"], 'r', encoding='utf-8') as f:205 qss_style = f.read()206 f.close()207 MainWindows.setStyleSheet(self,qss_style)208 # print(json_data)209 f.close()210 global plugins_data211 f = open('Plugins/Plugins.json', 'r', encoding='utf-8')212 plugins_data = json.load(f)213 # print(plugins_data)214 f.close()215 except Exception as e :216 QMessageBox.critical(self,'Error',str(e))217 pass218 #ç¼ç 219 def encode(self,encode_type):220 try:221 result_text=''222 # print(encode_type)223 if encode_type == 'å¾ç->base64':224 try:225 filename = self.file_open(r"Text Files (*.jpg);;All files(*.*)")226 with open(filename, 'rb') as f:227 base64_data = base64.b64encode(f.read())228 s = base64_data.decode()229 self.Ui.Result_text.setText(str('data:image/%s;base64,%s' % (filename[-3:],s)))230 return231 except:232 self.Ui.Result_text.setText('转æ¢å¤±è´¥ï¼')233 return234 text = self.Ui.Source_text.toPlainText()235 if text=='':236 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼')237 return 0238 # print(encode_type)239 if encode_type=='URL-UTF8':240 text = text.encode('utf-8')241 result_text = urllib.parse.quote(text)242 elif encode_type == 'URL-GB2312':243 text = text.encode('gb2312')244 result_text = urllib.parse.quote(text)245 elif encode_type=='Unicode':246 text = text.encode('unicode_escape')247 result_text = str(text, encoding='utf-8')248 elif encode_type=='Escape(%U)':249 text = text.encode('unicode_escape')250 result_text = str(text, encoding='utf-8').replace('\\u', '%u')251 elif encode_type=='HtmlEncode':252 result_text = html.escape(text)253 elif encode_type=='ASCII':254 result = ''255 for i in text:256 result = str(result) + str(ord(str(i))) + ' '257 result_text=str(result)[:-1]258 elif encode_type=='Base16':259 text = base64.b16encode(text.encode("utf-8"))260 result_text=str(text, encoding='utf-8')261 elif encode_type=='Base32':262 text = base64.b32encode(text.encode("utf-8"))263 result_text=str(text, encoding='utf-8')264 elif encode_type=='Base64':265 text = base64.b64encode(text.encode("utf-8"))266 result_text=str(text, encoding='utf-8')267 elif encode_type=='Str->Hex':268 result = ''269 for i in text:270 single = str(hex(ord(str(i))))271 result = result + single272 result_text='0x' + (str(result)).replace('0x', '')273 elif encode_type=='Shellcode':274 result = ''275 for i in text:276 single = str(hex(ord(str(i))))277 result = result + single278 result_text=(str(result)).replace('0x', '\\x')279 elif encode_type=='Qwerty':280 str1 = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"281 str2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"282 result_text = ""283 for s in text:284 if s in str1:285 if s !=' ':286 result_text = result_text + str1[str2.index(s)]287 else:288 result_text = result_text+' '289 else:290 result_text ='Qwertyåªè½å¯¹åæ¯å å¯!'291 if result_text!="":292 self.Ui.Result_text.setText(str(result_text))293 else:294 self.Ui.Result_text.setText("ç¼ç 失败ï¼")295 except Exception as e :296 self.Ui.Result_text.setText(str(e))297 pass298 # print(str(e))299 #解ç 300 def decode(self,decode_type):301 try:302 result_text=''303 # print(decode_type)304 text = self.Ui.Source_text.toPlainText()305 if text=='':306 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼') 307 return 0308 if decode_type=='URL-UTF8':309 result_text = str(urllib.parse.unquote(text))310 elif decode_type == 'URL-GB2312':311 result_text = str(urllib.parse.unquote(text, 'gb2312'))312 elif decode_type=='Unicode':313 result_text = bytes(text, encoding="utf8").decode('unicode_escape')314 elif decode_type=='Escape(%U)':315 text = text.replace('%u', '\\u').replace('%U', '\\u')316 result_text = bytes(text, encoding="utf8").decode('unicode_escape')317 elif decode_type=='HtmlEncode':318 result_text = html.unescape(text)319 elif decode_type=='ASCII':320 if ':' in text:321 text = text.split(":")322 elif ' ' in text:323 text = text.split(" ")324 elif ';' in text:325 text = text.split(";")326 elif ',' in text:327 text = text.split(",")328 else: 329 list22 = []330 list22.append(text)331 text=list22332 # print(text)333 result = ''334 for i in text:335 if i != '':336 # print(i)337 # print(chr(int(i)))338 result = result + chr(int(i))339 result_text =result340 elif decode_type=='Base16':341 text = base64.b16decode(text.encode("utf-8"))342 result_text=str(text, encoding='utf-8')343 elif decode_type=='Base32':344 text = base64.b32decode(text.encode("utf-8"))345 result_text=str(text, encoding='utf-8')346 elif decode_type=='Base64':347 text = base64.b64decode(text.encode("utf-8"))348 result_text=str(text, encoding='utf-8')349 elif decode_type=='Hex->Str':350 text = text.replace('0x', '').replace('0X', '')351 result_text = str(bytes.fromhex(text), encoding="utf-8")352 elif decode_type=='Shellcode':353 result = ''354 text = text.split('\\x')355 for i in text:356 single = str(bytes.fromhex(i), encoding="utf-8")357 result = result + single358 result_text =str(result)359 elif decode_type=='Qwerty':360 letter = {361 'q': 'a', 'w': 'b', 'e': 'c', 'r': 'd', 't': 'e', 'y': 'f', 'u': 'g',362 'i': 'h', 'o': 'i', 'p': 'j', 'a': 'k', 's': 'l', 'd': 'm', 'f': 'n',363 'g': 'o', 'h': 'p', 'j': 'q', 'k': 'r', 'l': 's', 'z': 't',364 'x': 'u', 'c': 'v', 'v': 'w', 'b': 'x', 'n': 'y', 'm': 'z',365 'Q': 'A', 'W': 'B', 'E': 'C', 'R': 'D', 'T': 'E', 'Y': 'F', 'U': 'G',366 'I': 'H', 'O': 'I', 'P': 'J', 'A': 'K', 'S': 'L', 'D': 'M', 'F': 'N',367 'G': 'O', 'H': 'P', 'J': 'Q', 'K': 'R', 'L': 'S', 'Z': 'T',368 'X': 'U', 'C': 'V', 'V': 'W', 'B': 'X', 'N': 'Y', 'M': 'Z',369 }370 result_text = ''371 for i in range(0, len(text)):372 if text[i] != ' ':373 result_text = result_text + letter.get(text[i])374 else:375 result_text = result_text + ' '376 elif decode_type == 'base64->å¾ç':377 try:378 file_name = self.file_save('tupian.jpg')379 # print(file_name)380 str2 = base64.b64decode(text.replace('data:image/jpg;base64,','').replace('data:image/jpeg;base64,','').replace('data:image/png;base64,','').replace('data:image/gif;base64,',''))381 file1 = open(file_name, 'wb')382 file1.write(str2)383 file1.close()384 QMessageBox.information(self,'Success','转æ¢æåï¼æ件ä½ç½®:%s'%file_name)385 result_text='转æ¢æåï¼æ件ä½ç½®:\n%s'%file_name386 except:387 pass388 if result_text!="":389 self.Ui.Result_text.setText(str(result_text))390 else:391 self.Ui.Result_text.setText('解ç 失败!')392 except Exception as e :393 self.Ui.Result_text.setText(str(e)) 394 # print(e)395 pass396 #encrypt397 def encrypt(self,encrypt_type):398 try:399 result_text=''400 # print(encrypt_type)401 text = self.Ui.Source_text.toPlainText()402 if text=='':403 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼')404 return 0405 if encrypt_type=='Rot13':406 d = {chr(i + c): chr((i + 13) % 26 + c) for i in range(26) for c in (65, 97)}407 result_text = ''.join([d.get(c, c) for c in text])408 elif encrypt_type=='å¯æå¯ç ':409 t = ""410 for c in text:411 if 'a' <= c <= 'z': # stræ¯å¯ä»¥ç´æ¥æ¯è¾ç412 t += chr(ord('a') + ((ord(c) - ord('a')) + 3) % 26)413 elif 'A' <= c <= 'Z':414 t += chr(ord('A') + ((ord(c) - ord('A')) + 3) % 26)415 else:416 t += c417 result_text=t418 elif encrypt_type=='æ
æ å¯ç ':419 self.WChild_zhalan = Ui_KEY1()420 self.dialog = QtWidgets.QDialog(self)421 self.WChild_zhalan.setupUi(self.dialog)422 self.dialog.show()423 self.WChild_zhalan.keyenter.clicked.connect(self.zhalanEncrypto)424 return 0425 elif encrypt_type=='å¹æ ¹å¯ç ':426 CODE_TABLE = { # å¹æ ¹åå
¸427 'aaaaa': 'a', 'aaaab': 'b', 'aaaba': 'c', 'aaabb': 'd', 'aabaa': 'e', 'aabab': 'f', 'aabba': 'g',428 'aabbb': 'h', 'abaaa': 'i', 'abaab': 'j', 'ababa': 'k', 'ababb': 'l', 'abbaa': 'm', 'abbab': 'n',429 'abbba': 'o', 'abbbb': 'p', 'baaaa': 'q', 'baaab': 'r', 'baaba': 's', 'baabb': 't', 'babaa': 'u',430 'babab': 'v', 'babba': 'w', 'babbb': 'x', 'bbaaa': 'y', 'bbaab': 'z'431 }432 str = text.lower()433 listStr = ''434 for i in str:435 if i in CODE_TABLE.values():436 # å°é®ãå¼åå为ä¸ä¸ªå表ï¼ååºiå¨valueçä½ç½®åæ ¹æ®ä¸æ æ¾å°å¯¹åºçé®437 listStr += list(CODE_TABLE.keys())[list(CODE_TABLE.values()).index(i)]438 result_text = listStr.upper() # 大åè¾åº439 elif encrypt_type=='æ©æ¯å¯ç ':440 CODE = {'A': '.-', 'B': '-...', 'C': '-.-.',441 'D': '-..', 'E': '.', 'F': '..-.',442 'G': '--.', 'H': '....', 'I': '..',443 'J': '.---', 'K': '-.-', 'L': '.-..',444 'M': '--', 'N': '-.', 'O': '---',445 'P': '.--.', 'Q': '--.-', 'R': '.-.',446 'S': '...', 'T': '-', 'U': '..-',447 'V': '...-', 'W': '.--', 'X': '-..-',448 'Y': '-.--', 'Z': '--..',449 '0': '-----', '1': '.----', '2': '..---',450 '3': '...--', '4': '....-', '5': '.....',451 '6': '-....', '7': '--...', '8': '---..',452 '9': '----.', '?': '..--..','/': '-..-.',453 '()': '-.--.-','-': '-....-','.': '.-.-.-'454 }455 msg = ''456 for char in text:457 if char in CODE:458 if char == ' ':459 pass460 else:461 msg+=(CODE[char.upper()] + ' ')462 else:463 msg = 'ææ¬ä¸å«æä¸è½è¯å«çå符ï¼'464 result_text =msg465 elif encrypt_type=='äºå½±å¯ç ':466 charList = [chr(i) for i in range(ord('A'), ord('Z') + 1)]467 cipher = [i for i in text.upper()]468 tmp = []469 ret = []470 for i in range(len(cipher)):471 for j in range(len(charList)):472 if charList[j] == cipher[i]:473 tmp.append(j + 1)474 for i in tmp:475 res = ''476 if i >= 8:477 for j in range(0,int(i/8)):478 res+= '8'479 if i % 8 >= 4:480 for j in range(0,int(i % 8 / 4)):481 res+= '4'482 if i % 4 >= 2:483 for j in range(0,int(i % 4 / 2)):484 res+= '2'485 if i % 2 >= 1:486 for j in range(0,int(i % 2 / 1)):487 res+= '1'488 ret.append(res + '0')489 result_text= ''.join(ret)[:-1]490 # print(result_text)491 elif encrypt_type == 'åæ¹å¯ç ':492 self.WChild = Ui_KEY2()493 self.dialog = QtWidgets.QDialog(self)494 self.WChild.setupUi(self.dialog)495 self.dialog.show()496 self.WChild.enter.clicked.connect(self.sifang_encrypt)497 return498 elif encrypt_type == 'å½éºå¯ç ':499 mapping_data =[['ç°'], ['ç±'], ['ä¸'], ['人'], ['å·¥'], ['大'], ['ç'], ['夫'], ['äº'], ['ç¾']]500 try:501 result = []502 for c in text:503 c_list = mapping_data[int(c)]504 c_index = random.randint(0, len(c_list) - 1)505 result.append(c_list[c_index])506 result_text = ''.join(result)507 except:508 result_text='æªæ¾å°è¯¥å符串对åºçä¸æï¼'509 elif encrypt_type == '仿å°å¯ç ':510 self.WChild = Ui_KEY2()511 self.dialog = QtWidgets.QDialog(self)512 self.WChild.setupUi(self.dialog)513 self.dialog.show()514 self.WChild.enter.clicked.connect(self.fangshe_encrypt)515 return516 elif encrypt_type=='ç»´åå°¼äºå¯ç ':517 self.WChild = Ui_KEY1()518 self.dialog = QtWidgets.QDialog(self)519 self.WChild.setupUi(self.dialog)520 self.dialog.show()521 self.WChild.keyenter.clicked.connect(self.VigenereEncrypto)522 return 0523 elif encrypt_type=='åç¹å·´ä»ç ':524 str1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"525 str2 = "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA"526 result_text = ""527 for s in text:528 if s in str1:529 if s != ' ':530 result_text = result_text + str2[str1.index(s)]531 else:532 result_text = result_text + ' '533 else:534 result_text = 'åç¹å·´ä»ç åªè½å¯¹è±æåæ¯å å¯ï¼'535 if result_text!="":536 self.Ui.Result_text.setText(result_text)537 else:538 self.Ui.Result_text.setText('å å¯å¤±è´¥!')539 except Exception as e :540 self.Ui.Result_text.setText(str(e)) 541 # QMessageBox.critical(self,'Error',str(e))542 # print(str(e))543 pass544 def VigenereEncrypto(self):545 try:546 self.dialog.close()547 text = self.Ui.Source_text.toPlainText()548 key = self.WChild.key.text()549 ptLen = len(text)550 keyLen = len(key)551 if keyLen==0:552 self.Ui.Result_text.setText(str('请è¾å
¥ä¸ä¸ªåæ³çkeyï¼')) 553 return 0554 quotient = ptLen // keyLen #å555 remainder = ptLen % keyLen #ä½556 out = ""557 for i in range (0 , quotient) :558 for j in range (0 , keyLen) :559 c = int((ord(text[i*keyLen+j]) - ord('a') + ord(key[j]) - ord('a')) % 26 + ord('a'))560 #global output561 out += chr (c)562 for i in range (0 , remainder) :563 c = int((ord(text[quotient*keyLen+i]) - ord('a') + ord(key[i]) - ord('a')) % 26 + ord('a'))564 #global output565 out += chr (c)566 if out!='':567 self.Ui.Result_text.setText(out)568 else:569 self.Ui.Result_text.setText('å å¯å¤±è´¥ï¼')570 except Exception as e :571 self.Ui.Result_text.setText(str(e)) 572 def sifang_encrypt(self):573 self.dialog.close()574 try:575 text = (self.Ui.Source_text.toPlainText()).lower()576 key1 = self.WChild.Key1.text().upper()577 key2 = self.WChild.Key2.text().upper()578 matrix = "ABCDEFGHIJKLMNOPRSTUVWXYZ"579 pla = "abcdefghijklmnoprstuvwxyz"580 key1 = '['+key1+"]"581 key2 = '['+key2+"]"582 key1 = ''.join(collections.OrderedDict.fromkeys(key1))583 key2 = ''.join(collections.OrderedDict.fromkeys(key2))584 matrix1 = re.sub('[\[\]]', '', key1) + re.sub(key1, '', matrix)585 matrix2 = re.sub('[\[\]]', '', key2) + re.sub(key2, '', matrix)586 matrix_list1 = []587 matrix_list2 = []588 pla_list = []589 for i in range(0, len(matrix1), 5):590 matrix_list1.append(list(matrix1[i:i + 5]))591 for i in range(0, len(matrix2), 5):592 matrix_list2.append(list(matrix2[i:i + 5]))593 for i in range(0, len(pla), 5):594 pla_list.append(list(pla[i:i + 5]))595 pla = text.replace(' ', '')596 if len(pla) % 2 != 0:597 pla += 'x'598 cip = ""599 for i in range(0, len(pla), 2):600 data = pla[i:i + 2]601 # 两个åæ¯ä¸ç¬¬ä¸ä¸ªåæ¯ä½ç½®602 first = self.find_index(data[0],pla_list)603 # 两个åæ¯ä¸ç¬¬äºä¸ªåæ¯ä½ç½®604 second = self.find_index(data[1],pla_list)605 return_cip = ""606 return_cip += matrix_list1[first[0]][second[1]]607 return_cip += matrix_list2[second[0]][first[1]]608 cip += return_cip609 if cip != '':610 self.Ui.Result_text.setText(cip)611 else:612 self.Ui.Result_text.setText('å å¯å¤±è´¥ï¼')613 except Exception as e:614 # print(str(e))615 pass616 def gcd(self,a, b):617 if (a < b):618 t = a619 a = b620 b = t621 while (0 != b):622 t = a623 a = b624 b = t % b625 return a626 def fangshe_encrypt(self):627 self.dialog.close()628 try:629 letter_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" # åæ¯è¡¨630 text = (self.Ui.Source_text.toPlainText())631 key1 = self.WChild.Key1.text()632 key2 = self.WChild.Key2.text()633 # print(text,key2,key1)634 try:635 if (0 == int(key1.isdigit()) or 0 == int(key2.isdigit())):636 self.Ui.Result_text.setText('è¾å
¥æ误! å¯é¥ä¸ºæ°åã')637 if (self.gcd(int(key1),26)!=1):638 self.Ui.Result_text.setText('è¾å
¥æ误! key1å26å¿
é¡»äºç´ ã')639 return 0640 except:641 self.Ui.Result_text.setText('è¾å
¥æ误!')642 else:643 ciphertext = ""644 for ch in text: # éåææ645 if ch.isalpha(): # æææ¯å¦ä¸ºåæ¯,å¦ææ¯,åå¤æ大å°å,åå«è¿è¡å å¯646 if ch.isupper():647 ciphertext += letter_list[(int(key1) * (ord(ch) - 65) + int(key2)) % 26]648 else:649 ciphertext += letter_list[(int(key1) * (ord(ch) - 97) + int(key2)) % 26].lower()650 else: # å¦æå¯æä¸ä¸ºåæ¯,ç´æ¥æ·»å å°å¯æå符串é651 ciphertext += ch652 self.Ui.Result_text.setText(ciphertext)653 except Exception as e:654 self.Ui.Result_text.setText('å å¯å¤±è´¥!')655 # print(str(e))656 pass657 # æ¥è¯¢ææåæ¯ä½ç½®658 def find_index(self,x,pla_list):659 for i in range(len(pla_list)):660 for j in range(len(pla_list[i])):661 if pla_list[i][j] == x:662 return i, j663 def zhalanEncrypto(self):664 self.dialog.close()665 plain = self.Ui.Source_text.toPlainText()666 try:667 n = int(self.WChild_zhalan.key.text())668 ans = ''669 for i in range(n):670 for j in range(int(plain.__len__() / n + 0.5)):671 try:672 ans += plain[j * n + i]673 except:674 pass675 except:676 ans = "请è¾å
¥æ£ç¡®çåç»ï¼"677 if ans != '':678 self.Ui.Result_text.setText(ans)679 else:680 self.Ui.Result_text.setText('å å¯å¤±è´¥ï¼')681 #decrypt682 def decrypt(self,decrypt_type):683 try:684 result_text=''685 # print(decrypt_type)686 text = self.Ui.Source_text.toPlainText()687 if text=='':688 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼')689 return 0690 if decrypt_type == 'Rot13':691 PAIRS= {692 "a": "n", "b": "o", "c": "p", "d": "q", "e": "r",693 "f": "s", "g": "t", "h": "u", "i": "v", "j": "w",694 "k": "x", "l": "y", "m": "z", "n": "a", "o": "b",695 "p": "c", "q": "d", "r": "e", "s": "f", "t": "g",696 "u": "h", "v": "i", "w": "j", "x": "k", "y": "l",697 "z": "m", "A": "N", "B": "O", "C": "P", "D": "Q",698 "E": "R", "F": "S", "G": "T", "H": "U", "I": "V",699 "J": "W", "K": "X", "L": "Y", "M": "Z", "N": "A",700 "O": "B", "P": "C", "Q": "D", "R": "E", "S": "F",701 "T": "G", "U": "H", "V": "I", "W": "J", "X": "K",702 "Y": "L", "Z": "M"703 }704 result_text = "".join(PAIRS.get(c, c) for c in text)705 elif decrypt_type == 'å¯æå¯ç ':706 t = ""707 for c in text:708 if 'a' <= c <= 'z': # stræ¯å¯ä»¥ç´æ¥æ¯è¾ç709 t += chr(ord('a') + ((ord(c) - ord('a')) -3) % 26)710 elif 'A' <= c <= 'Z':711 t += chr(ord('A') + ((ord(c) - ord('A')) - 3) % 26)712 else:713 t += c714 result_text=t715 elif decrypt_type == 'æ
æ å¯ç ':716 for n in range(2, text.__len__() - 1):717 ans = ''718 for i in range(n):719 for j in range(int(text.__len__() / n + 0.5)):720 try:721 ans += text[j * n + i]722 except:723 pass724 result_text+="å为%sæ ï¼è§£å¯ç»æ为:%s\n"%(n,ans)725 elif decrypt_type == 'å¹æ ¹å¯ç ':726 return_str=''727 dicts = {'aabbb': 'H', 'aabba': 'G', 'baaab': 'R', 'baaaa': 'Q', 'bbaab': 'Z', 'bbaaa': 'Y', 'abbab': 'N',728 'abbaa': 'M', 'babaa': 'U', 'babab': 'V', 'abaaa': 'I', 'abaab': 'J', 'aabab': 'F', 'aabaa': 'E',729 'aaaaa': 'A', 'aaaab': 'B', 'baabb': 'T', 'baaba': 'S', 'aaaba': 'C', 'aaabb': 'D', 'abbbb': 'P',730 'abbba': 'O', 'ababa': 'K', 'ababb': 'L', 'babba': 'W', 'babbb': 'X'}731 sums = len(text)732 j = 5 ##æ¯5个为ä¸ç»733 for i in range(int(sums / j)):734 result = text[j * i:j * (i + 1)].lower()735 return_str+=str(dicts[result],)736 result_text=return_str737 elif decrypt_type == 'æ©æ¯å¯ç ':738 dict = {'.-': 'A','-...': 'B','-.-.': 'C','-..': 'D',739 '.': 'E','..-.': 'F','--.': 'G','....': 'H',740 '..': 'I','.---': 'J','-.-': 'K','.-..': 'L',741 '--': 'M','-.': 'N','---': 'O','.--.': 'P',742 '--.-': 'Q','.-.': 'R','...': 'S','-': 'T',743 '..-': 'U','...-': 'V', '.--': 'W','-..-': 'X',744 '-.--': 'Y','--..': 'Z','.----': '1','..---': '2',745 '...--': '3','....-': '4','.....': '5', '-....': '6',746 '--...': '7', '---..': '8','----.': '9','-----': '0',747 '..--..': '?','-..-.': '/', '-.--.-': '()','-....-': '-',748 '.-.-.-': '.'749 }750 msg = ''751 s= text.split(' ')752 for item in s:753 if item!=''and item!=' ':754 msg += (dict[item])755 result_text = msg756 elif decrypt_type == '移ä½å¯ç ':757 inputStr = text758 #759 result=''760 for j in range(26):761 result_list = []762 for i, num in zip(inputStr, range(len(inputStr))):763 #print(i)764 if i.islower:765 caseS1 = string.ascii_lowercase * 2766 if i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":767 caseS1 = string.ascii_uppercase * 2768 status = caseS1.find(i)769 if status != -1:770 result_list.append(caseS1[status + j])771 else:772 result_list.append(inputStr[num])773 text2=("".join(result_list), "åå³å移äº{}ä½".format(j))774 result+= text2[0]+' '+text2[1]+'\n'775 result_text =result776 elif decrypt_type == 'äºå½±å¯ç ':777 other_letters = []778 for s in text:779 if not ['0','1','2','4','8'].count(s):780 other_letters.append(s)781 if other_letters:782 result_text='å å¯å符串å
åªè½å
å«0ã1ã2ã4ã8'783 else:784 charList = [chr(i) for i in range(ord('A'), ord('Z') + 1)]785 ret = []786 plaintext = [i for i in text.split('0')]787 for i in plaintext:788 tmp = 0789 for j in range(len(i)):790 tmp += int(i[j])791 ret.append(charList[tmp - 1])792 result_text= ''.join(ret)793 elif decrypt_type == 'å½éºå¯ç ':794 mapping_data ={'ç°': 0, 'ç±': 1, 'ä¸': 2, '人': 3, 'å·¥': 4, '大': 5, 'ç': 6, '夫': 7, 'äº': 8, 'ç¾': 9}795 result_text = ''.join(map(lambda x: str(mapping_data[x]), text))796 elif decrypt_type == 'åæ¹å¯ç ':797 self.WChild = Ui_KEY2()798 self.dialog = QtWidgets.QDialog(self)799 self.WChild.setupUi(self.dialog)800 self.dialog.show()801 self.WChild.enter.clicked.connect(self.sifang_decrypt)802 return 0803 elif decrypt_type == '仿å°å¯ç ':804 self.WChild = Ui_KEY2()805 self.dialog = QtWidgets.QDialog(self)806 self.WChild.setupUi(self.dialog)807 self.dialog.show()808 self.WChild.enter.clicked.connect(self.fangshe_decrypt)809 return 0810 elif decrypt_type == 'ç»´åå°¼äºå¯ç ':811 self.WChild = Ui_KEY1()812 self.dialog = QtWidgets.QDialog(self)813 self.WChild.setupUi(self.dialog)814 self.dialog.show()815 self.WChild.keyenter.clicked.connect(self.VigenereDecrypto)816 return 0817 elif decrypt_type=='åç¹å·´ä»ç ':818 str1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"819 str2 = "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA"820 result_text = ""821 for s in text:822 if s != ' ':823 result_text = result_text + str1[str2.index(s)]824 else:825 result_text = result_text + ' '826 if result_text!="":827 self.Ui.Result_text.setText(result_text)828 else:829 self.Ui.Result_text.setText('解å¯å¤±è´¥ï¼')830 except Exception as e :831 self.Ui.Result_text.setText(str(e)) 832 # QMessageBox.critical(self,'Error',str(e))833 pass834 # print(str(e))835 def VigenereDecrypto(self):836 try:837 self.dialog.close()838 letter_list = string.ascii_uppercase839 letter_list2 = string.ascii_lowercase840 message = self.Ui.Source_text.toPlainText()841 key = self.WChild.key.text()842 if len(key)==0:843 self.Ui.Result_text.setText(str('请è¾å
¥ä¸ä¸ªåæ³çkeyï¼')) 844 return 0845 key_list = []846 for i in key:847 key_list.append(ord(i.upper()) - 65)848 plaintext = ""849 flag = 0850 for cipher in message:851 if flag % len(key_list) == 0:852 flag = 0853 if cipher.isalpha():854 if cipher.isupper():855 plaintext += letter_list[(ord(cipher) - 65 - key_list[flag]) % 26]856 flag += 1857 if cipher.islower():858 plaintext += letter_list2[(ord(cipher) - 97 - key_list[flag]) % 26]859 flag += 1860 else:861 plaintext += cipher862 if plaintext!='':863 self.Ui.Result_text.setText(plaintext)864 else:865 self.Ui.Result_text.setText('解å¯å¤±è´¥!')866 except Exception as e:867 self.Ui.Result_text.setText(str(e)) 868 def sifang_decrypt(self):869 self.dialog.close()870 try:871 # print(1)872 text = (self.Ui.Source_text.toPlainText()).upper()873 key1 = self.WChild.Key1.text().upper()874 key2 = self.WChild.Key2.text().upper()875 matrix = "ABCDEFGHIJKLMNOPRSTUVWXYZ"876 pla = "abcdefghijklmnoprstuvwxyz"877 key1 = '[' + key1 + "]"878 key2 = '[' + key2 + "]"879 key1 = ''.join(collections.OrderedDict.fromkeys(key1))880 key2 = ''.join(collections.OrderedDict.fromkeys(key2))881 matrix1 = re.sub('[\[\]]', '', key1) + re.sub(key1, '', matrix)882 matrix2 = re.sub('[\[\]]', '', key2) + re.sub(key2, '', matrix)883 matrix_list1 = []884 matrix_list2 = []885 pla_list = []886 # print(matrix1)887 for i in range(0, len(matrix1), 5):888 matrix_list1.append(list(matrix1[i:i + 5]))889 for i in range(0, len(matrix2), 5):890 matrix_list2.append(list(matrix2[i:i + 5]))891 for i in range(0, len(pla), 5):892 pla_list.append(list(pla[i:i + 5]))893 cip = text.replace(' ', '')894 result = ''895 for i in range(0, len(cip), 2):896 letter = cip[i:i + 2]897 # 两个åæ¯ä¸ç¬¬ä¸ä¸ªåæ¯ä½ç½®898 first = self.find_index1(letter[0],matrix_list1)899 # 两个åæ¯ä¸ç¬¬äºä¸ªåæ¯ä½ç½®900 second = self.find_index2(letter[1],matrix_list2)901 return_pla = ""902 return_pla += pla_list[first[0]][second[1]]903 return_pla += pla_list[second[0]][first[1]]904 result += return_pla905 if result != '':906 self.Ui.Result_text.setText(result)907 else:908 self.Ui.Result_text.setText('解å¯å¤±è´¥ï¼')909 except Exception as e:910 # print(str(e))911 pass912 # æ±éå
å½æ°913 def GetInverse(self,a, m):914 for i in range(m):915 if (1 == (a * i) % m):916 return i917 return a918 def fangshe_decrypt(self):919 self.dialog.close()920 try:921 key1 = self.WChild.Key1.text()922 key2 = self.WChild.Key2.text()923 try:924 if (0 == int(key1.isdigit()) or 0 == int(key2.isdigit())):925 self.Ui.Result_text.setText('è¾å
¥æ误! å¯é¥ä¸ºæ°åã')926 return927 if (self.gcd(int(key1),26)!=1):928 key1_list = []929 result = ''930 for i in range(0,int(key1)):931 if self.gcd(i,26)==1:932 key1_list.append(i)933 for z in key1_list:934 result+= 'key1:%s'%z+' ææ:'+self.fangshe_getdecrypt(int(z), int(key2))+'\n'935 self.Ui.Result_text.setText('è¾å
¥æ误! key1å26å¿
é¡»äºç´ ã以ä¸ä¸ºçç ´key1çç»æ\n'+result)936 return 0937 except:938 self.Ui.Result_text.setText('è¾å
¥æ误!')939 else:940 self.Ui.Result_text.setText(self.fangshe_getdecrypt(int(key1),int(key2)))941 except Exception as e:942 self.Ui.Result_text.setText('解å¯å¤±è´¥ã')943 # print(str(e))944 pass945 def fangshe_getdecrypt(self,key1,key2):946 try:947 text = (self.Ui.Source_text.toPlainText())948 letter_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" # åæ¯è¡¨949 plaintext = ""950 for ch in text: # éåå¯æ951 if ch.isalpha(): # å¯æ为å¦ä¸ºåæ¯,å¦ææ¯,åå¤æ大å°å,åå«è¿è¡è§£å¯952 if ch.isupper():953 plaintext += letter_list[self.GetInverse(key1, 26) * (ord(ch) - 65 - key2) % 26]954 else:955 plaintext += letter_list[self.GetInverse(key1, 26) * (ord(ch) - 97 - key2) % 26].lower()956 else: # å¦æå¯æä¸ä¸ºåæ¯,ç´æ¥æ·»å å°ææå符串é957 plaintext += ch958 return plaintext959 except:960 return961 # æ¥è¯¢ä¸¤ä¸ªå¯æåæ¯ä½ç½®962 def find_index1(self,x,matrix_list1):963 for i in range(len(matrix_list1)):964 for j in range(len(matrix_list1[i])):965 if matrix_list1[i][j] == x:966 return i, j967 def find_index2(self,y,matrix_list2):968 for k in range(len(matrix_list2)):969 for l in range(len(matrix_list2[k])):970 if matrix_list2[k][l] == y:971 return k, l972 #Binary973 def Binary(self,Binary_type):974 try:975 result_text=''976 text = self.Ui.Source_text.toPlainText()977 if text == '':978 self.Ui.Result_text.setText('请è¾å
¥ä¸ä¸ªæºå符串ï¼')979 return 0980 all_text = text.split(" ")981 all_result = ''982 for text in all_text:983 if text =="":984 break985 if Binary_type == '2->8':986 result = int(text, 2)987 result_text = str(oct(result))988 elif Binary_type == '2->10':989 result = int(text, 2)990 result_text=str(result)991 elif Binary_type == '2->16':992 result_text=str(hex(int(text,2)))993 elif Binary_type == '8->2':994 result = int(text, 8)995 result_text = str(bin(result))996 elif Binary_type == '8->10':997 result = int(text, 8)998 result_text = str(result)999 elif Binary_type == '8->16':1000 result = int(text, 8)1001 result_text=str(hex(result))1002 elif Binary_type == '10->2':1003 s = int(text)1004 result_text = str(bin(s))1005 elif Binary_type == '10->8':1006 s = int(text)1007 result_text = str(oct(s))1008 elif Binary_type == '10->16':1009 s = int(text)1010 result_text =str(hex(s))1011 elif Binary_type == '16->2':1012 result_text=str(bin(int(text,16)))1013 elif Binary_type == '16->8':1014 result = int(text, 16)1015 result_text = str(oct(result))1016 elif Binary_type == '16->10':1017 result = int(text, 16)1018 result_text = str(result)1019 elif Binary_type == 'èªå®ä¹':1020 self.Binary_dialog = Ui_Binary()1021 self.dialog = QtWidgets.QDialog(self)1022 self.Binary_dialog.setupUi(self.dialog)1023 self.dialog.show()1024 self.Binary_dialog.enter.clicked.connect(self.Binary_conversion)1025 return 01026 all_result=all_result+result_text+' '1027 all_result=str(all_result).replace('0o','').replace('0x','').replace('0b','')1028 self.Ui.Result_text.setText(all_result)1029 except Exception as e :1030 self.Ui.Result_text.setText(str(e)) 1031 pass1032 def Binary_conversion(self):1033 try:1034 return_Data = ''1035 self.dialog.close()1036 if self.Binary_dialog.Source.text()!='' and self.Binary_dialog.result.text()!='':1037 text = self.Ui.Source_text.toPlainText()1038 # print(text)1039 from_ = int(self.Binary_dialog.Source.text())1040 to_ = int(self.Binary_dialog.result.text())1041 #from_è¿å¶è½¬æ¢ä¸ºåè¿å¶1042 ten_num = sum([int(i) * from_ ** n for n, i in enumerate(text[::-1])])1043 # print(ten_num)1044 #åè¿å¶è½¬æ¢ä¸ºto_è¿å¶1045 a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'b', 'C', 'D', 'E', 'F']1046 b = []1047 while True:1048 s = ten_num // to_ # å1049 y = ten_num % to_ # ä½æ°1050 b = b + [y]1051 if s == 0:1052 break1053 ten_num = s1054 b.reverse()1055 for i in b:1056 return_Data+=str(a[i])1057 self.Ui.Result_text.setText(return_Data)1058 except Exception as e :1059 pass1060 def Copy_text(self,text):1061 try:1062 if text=='Source':1063 data = self.Ui.Source_text.toPlainText()1064 if text=='result':1065 data = self.Ui.Result_text.toPlainText()1066 # 访é®åªåæ¿ï¼åå
¥å¼1067 wincld.OpenClipboard()1068 wincld.EmptyClipboard()1069 wincld.SetClipboardData(win32con.CF_UNICODETEXT, data)1070 wincld.CloseClipboard()1071 except Exception as e :1072 pass1073 def tihuan(self,text):1074 try:1075 if text=='Source':1076 data = self.Ui.Source_text.toPlainText()1077 source_text = self.Ui.Source_tihuan_source.text()1078 result_text = self.Ui.Source_tihuan_result.text()1079 text = self.Ui.Source_text.toPlainText()1080 text = text.replace(source_text, result_text)1081 self.Ui.Source_text.setText(str(text))1082 if text=='result':1083 data = self.Ui.Result_text.toPlainText()1084 source_text = self.Ui.Result_tihuan_source.text()1085 result_text = self.Ui.Result_tihuan_result.text()1086 text = self.Ui.Result_text.toPlainText()1087 text = text.replace(source_text, result_text)1088 self.Ui.Result_text.setText(str(text))1089 except Exception as e :1090 pass1091 def paste(self,text):1092 try:1093 wincld.OpenClipboard()1094 data = wincld.GetClipboardData(win32con.CF_UNICODETEXT)1095 wincld.CloseClipboard()1096 if text=='Source':1097 # print(text)1098 source_text = self.Ui.Source_text.toPlainText() #1099 data=source_text+data...
featurize.py
Source:featurize.py
1# -*- coding: utf-8 -*-2'''3**************** PLEASE READ ***************4Script that reads in spam and ham messages and converts each training example5into a feature vector6Code intended for UC Berkeley course CS 189/289A: Machine Learning7Requirements:8-scipy ('pip install scipy')9To add your own features, create a function that takes in the raw text and10word frequency dictionary and outputs a int or float. Then add your feature11in the function 'def generate_feature_vector'12The output of your file will be a .mat file. The data will be accessible using13the following keys:14 -'training_data'15 -'training_labels'16 -'test_data'17Please direct any bugs to kevintee@berkeley.edu18'''19from collections import defaultdict20import glob21import re22import scipy.io23NUM_TRAINING_EXAMPLES = 517224NUM_TEST_EXAMPLES = 585725BASE_DIR = './'26SPAM_DIR = 'spam/'27HAM_DIR = 'ham/'28TEST_DIR = 'test/'29# ************* Features *************30# Features that look for certain words31def freq_pain_feature(text, freq):32 return float(freq['pain'])33def freq_private_feature(text, freq):34 return float(freq['private'])35def freq_bank_feature(text, freq):36 return float(freq['bank'])37def freq_money_feature(text, freq):38 return float(freq['money'])39def freq_drug_feature(text, freq):40 return float(freq['drug'])41def freq_spam_feature(text, freq):42 return float(freq['spam'])43def freq_prescription_feature(text, freq):44 return float(freq['prescription'])45def freq_creative_feature(text, freq):46 return float(freq['creative'])47def freq_height_feature(text, freq):48 return float(freq['height'])49def freq_featured_feature(text, freq):50 return float(freq['featured'])51def freq_differ_feature(text, freq):52 return float(freq['differ'])53def freq_energy_feature(text, freq):54 return float(freq['energy'])55def freq_message_feature(text, freq):56 return float(freq['message'])57def freq_volumes_feature(text, freq):58 return float(freq['volumes'])59def freq_revision_feature(text, freq):60 return float(freq['revision'])61def freq_memo_feature(text, freq):62 return float(freq['memo'])63def freq_planning_feature(text, freq):64 return float(freq['planning'])65def freq_out_feature(text, freq):66 return float(freq['out'])67# Features that look for certain characters68def freq_semicolon_feature(text, freq):69 return text.count(';')70def freq_dollar_feature(text, freq):71 return text.count('$')72def freq_sharp_feature(text, freq):73 return text.count('#')74def freq_exclamation_feature(text, freq):75 return text.count('!')76def freq_para_feature(text, freq):77 return text.count('(')78def freq_and_feature(text, freq):79 return text.count('&')80def freq_colon_feature(text, freq):81 return text.count(':')82def freq_double_quotes_feature(text, freq):83 return text.count('"')84def freq_single_quote_feature(text, freq):85 return text.count('\'')86def freq_front_slash_feature(text, freq):87 return text.count('/')88def freq_closing_paren_feature(text, freq):89 return text.count(')')90def freq_pipe_feature(text, freq):91 return text.count('|')92def freq_dash_feature(text, freq):93 return text.count('-')94def freq_caret_feature(text, freq):95 return text.count('^')96def freq_at_feature(text, freq):97 return text.count('@')98def freq_greater_than_feature(text, freq):99 return text.count('>')100# Misc features101def freq_digit_feature(text, freq):102 return sum(c.isdigit() for c in text)103def freq_online_feature(text, freq):104 return float(freq['online'])105def freq_enlarge_feature(text, freq):106 return float(freq['enlarge'])107def freq_click_feature(text, freq):108 return float(freq['click'])109def freq_here_feature(text, freq):110 return float(freq['here'])111def freq_guaranteed_feature(text, freq):112 return float(freq['guaranteed'])113def freq_free_feature(text, freq):114 return float(freq['free'])115def freq_please_feature(text, freq):116 return float(freq['please'])117# --------- Spam features ----------118def freq_td_feature(text, freq):119 return float(freq['td'])120def freq_nbsp_feature(text, freq):121 return float(freq['nbsp'])122def freq_pills_feature(text, freq):123 return float(freq['pills'])124def freq_width_feature(text, freq):125 return float(freq['width'])126def freq_computron_feature(text, freq):127 return float(freq['computron'])128def freq_href_feature(text, freq):129 return float(freq['href'])130def freq_viagra_feature(text, freq):131 return float(freq['viagra'])132def freq_xp_feature(text, freq):133 return float(freq['xp'])134def freq_src_feature(text, freq):135 return float(freq['src'])136def freq_cialis_feature(text, freq):137 return float(freq['cialis'])138def freq_soft_feature(text, freq):139 return float(freq['soft'])140def freq_meds_feature(text, freq):141 return float(freq['meds'])142def freq_paliourg_feature(text, freq):143 return float(freq['paliourg'])144def freq_voip_feature(text, freq):145 return float(freq['voip'])146def freq_oo_feature(text, freq):147 return float(freq['oo'])148def freq_php_feature(text, freq):149 return float(freq['php'])150def freq_bgcolor_feature(text, freq):151 return float(freq['bgcolor'])152def freq_drugs_feature(text, freq):153 return float(freq['drugs'])154def freq_biz_feature(text, freq):155 return float(freq['biz'])156def freq_mx_feature(text, freq):157 return float(freq['mx'])158def freq_img_feature(text, freq):159 return float(freq['img'])160def freq_photoshop_feature(text, freq):161 return float(freq['photoshop'])162def freq_valign_feature(text, freq):163 return float(freq['valign'])164def freq_uncertainties_feature(text, freq):165 return float(freq['uncertainties'])166def freq_000000_feature(text, freq):167 return float(freq['000000'])168def freq_div_feature(text, freq):169 return float(freq['div'])170def freq_hotlist_feature(text, freq):171 return float(freq['hotlist'])172def freq_moopid_feature(text, freq):173 return float(freq['moopid'])174def freq_pharmacy_feature(text, freq):175 return float(freq['pharmacy'])176def freq_projections_feature(text, freq):177 return float(freq['projections'])178def freq_gr_feature(text, freq):179 return float(freq['gr'])180def freq_xanax_feature(text, freq):181 return float(freq['xanax'])182def freq_htmlimg_feature(text, freq):183 return float(freq['htmlimg'])184def freq_colspan_feature(text, freq):185 return float(freq['colspan'])186def freq_corel_feature(text, freq):187 return float(freq['corel'])188def freq_readers_feature(text, freq):189 return float(freq['readers'])190def freq_macromedia_feature(text, freq):191 return float(freq['macromedia'])192def freq_dealer_feature(text, freq):193 return float(freq['dealer'])194def freq_knle_feature(text, freq):195 return float(freq['knle'])196def freq_valium_feature(text, freq):197 return float(freq['valium'])198def freq_demokritos_feature(text, freq):199 return float(freq['demokritos'])200def freq_iit_feature(text, freq):201 return float(freq['iit'])202def freq_rolex_feature(text, freq):203 return float(freq['rolex'])204def freq_intel_feature(text, freq):205 return float(freq['intel'])206def freq_speculative_feature(text, freq):207 return float(freq['speculative'])208def freq_1933_feature(text, freq):209 return float(freq['1933'])210def freq_rnd_feature(text, freq):211 return float(freq['rnd'])212def freq_rx_feature(text, freq):213 return float(freq['rx'])214def freq_jebel_feature(text, freq):215 return float(freq['jebel'])216def freq_lots_feature(text, freq):217 return float(freq['lots'])218def freq_half_feature(text, freq):219 return float(freq['½'])220def freq_alt_feature(text, freq):221 return float(freq['alt'])222def freq_ooking_feature(text, freq):223 return float(freq['ooking'])224def freq_darial_feature(text, freq):225 return float(freq['darial'])226def freq_yap_feature(text, freq):227 return float(freq['yap'])228def freq_gra_feature(text, freq):229 return float(freq['gra'])230def freq_0310041_feature(text, freq):231 return float(freq['0310041'])232def freq_canon_feature(text, freq):233 return float(freq['canon'])234def freq_export_feature(text, freq):235 return float(freq['export'])236def freq_1934_feature(text, freq):237 return float(freq['1934'])238def freq_0424040_feature(text, freq):239 return float(freq['0424040'])240def freq_pill_feature(text, freq):241 return float(freq['pill'])242def freq_ftar_feature(text, freq):243 return float(freq['ftar'])244def freq_logos_feature(text, freq):245 return float(freq['logos'])246def freq_toshiba_feature(text, freq):247 return float(freq['toshiba'])248def freq_soma_feature(text, freq):249 return float(freq['soma'])250def freq_fontfont_feature(text, freq):251 return float(freq['fontfont'])252def freq_materially_feature(text, freq):253 return float(freq['materially'])254def freq_vicodin_feature(text, freq):255 return float(freq['vicodin'])256def freq_resellers_feature(text, freq):257 return float(freq['resellers'])258def freq_viewsonic_feature(text, freq):259 return float(freq['viewsonic'])260def freq_cellpadding_feature(text, freq):261 return float(freq['cellpadding'])262def freq_1618_feature(text, freq):263 return float(freq['1618'])264def freq_robotics_feature(text, freq):265 return float(freq['robotics'])266def freq_8834464_feature(text, freq):267 return float(freq['8834464'])268def freq_hewlett_feature(text, freq):269 return float(freq['hewlett'])270def freq_8834454_feature(text, freq):271 return float(freq['8834454'])272def freq_4176_feature(text, freq):273 return float(freq['4176'])274def freq_materia_feature(text, freq):275 return float(freq['materia'])276def freq_1226030_feature(text, freq):277 return float(freq['1226030'])278def freq_apc_feature(text, freq):279 return float(freq['apc'])280def freq_iomega_feature(text, freq):281 return float(freq['iomega'])282def freq_targus_feature(text, freq):283 return float(freq['targus'])284def freq_aopen_feature(text, freq):285 return float(freq['aopen'])286def freq_customerservice_feature(text, freq):287 return float(freq['customerservice'])288def freq_nomad_feature(text, freq):289 return float(freq['nomad'])290def freq_packard_feature(text, freq):291 return float(freq['packard'])292def freq_intellinet_feature(text, freq):293 return float(freq['intellinet'])294def freq_enquiries_feature(text, freq):295 return float(freq['enquiries'])296def freq_construed_feature(text, freq):297 return float(freq['construed'])298def freq_drug_feature(text, freq):299 return float(freq['drug'])300def freq_uae_feature(text, freq):301 return float(freq['uae'])302def freq_itoy_feature(text, freq):303 return float(freq['itoy'])304def freq_predictions_feature(text, freq):305 return float(freq['predictions'])306def freq_muscle_feature(text, freq):307 return float(freq['muscle'])308def freq_zonedubai_feature(text, freq):309 return float(freq['zonedubai'])310def freq_emirates_feature(text, freq):311 return float(freq['emirates'])312def freq_leth_feature(text, freq):313 return float(freq['leth'])314def freq_anticipates_feature(text, freq):315 return float(freq['anticipates'])316def freq_aeor_feature(text, freq):317 return float(freq['aeor'])318def freq_oem_feature(text, freq):319 return float(freq['oem'])320def freq_otcbb_feature(text, freq):321 return float(freq['otcbb'])322def freq_assurance_feature(text, freq):323 return float(freq['assurance'])324def freq_internationa_feature(text, freq):325 return float(freq['internationa'])326def freq_female_feature(text, freq):327 return float(freq['female'])328def freq_resuits_feature(text, freq):329 return float(freq['resuits'])330def freq_studio_feature(text, freq):331 return float(freq['studio'])332def freq_spain_feature(text, freq):333 return float(freq['spain'])334def freq_palestinian_feature(text, freq):335 return float(freq['palestinian'])336def freq_illustrator_feature(text, freq):337 return float(freq['illustrator'])338def freq_verdana_feature(text, freq):339 return float(freq['verdana'])340def freq_aerofoam_feature(text, freq):341 return float(freq['aerofoam'])342def freq_mining_feature(text, freq):343 return float(freq['mining'])344def freq_arial_feature(text, freq):345 return float(freq['arial'])346def freq_graphics_feature(text, freq):347 return float(freq['graphics'])348def freq_vi_feature(text, freq):349 return float(freq['vi'])350def freq_abdv_feature(text, freq):351 return float(freq['abdv'])352def freq_wysak_feature(text, freq):353 return float(freq['wysak'])354def freq_sofftwaares_feature(text, freq):355 return float(freq['sofftwaares'])356def freq_apple_feature(text, freq):357 return float(freq['apple'])358def freq_eogi_feature(text, freq):359 return float(freq['eogi'])360def freq_erections_feature(text, freq):361 return float(freq['erections'])362def freq_three_feature(text, freq):363 return float(freq['³'])364def freq_pubiisher_feature(text, freq):365 return float(freq['pubiisher'])366def freq_wiil_feature(text, freq):367 return float(freq['wiil'])368def freq_gains_feature(text, freq):369 return float(freq['gains'])370def freq_ffffff_feature(text, freq):371 return float(freq['ffffff'])372def freq_phentermine_feature(text, freq):373 return float(freq['phentermine'])374def freq_hottlist_feature(text, freq):375 return float(freq['hottlist'])376def freq_cellspacing_feature(text, freq):377 return float(freq['cellspacing'])378def freq_male_feature(text, freq):379 return float(freq['male'])380def freq_atleast_feature(text, freq):381 return float(freq['atleast'])382def freq_dosage_feature(text, freq):383 return float(freq['dosage'])384def freq_netherlands_feature(text, freq):385 return float(freq['netherlands'])386def freq_ail_feature(text, freq):387 return float(freq['ail'])388def freq_prescriptions_feature(text, freq):389 return float(freq['prescriptions'])390def freq_undervalued_feature(text, freq):391 return float(freq['undervalued'])392def freq_cia_feature(text, freq):393 return float(freq['cia'])394def freq_couid_feature(text, freq):395 return float(freq['couid'])396def freq_technoiogies_feature(text, freq):397 return float(freq['technoiogies'])398def freq_dose_feature(text, freq):399 return float(freq['dose'])400def freq_opinions_feature(text, freq):401 return float(freq['opinions'])402def freq_sir_feature(text, freq):403 return float(freq['sir'])404def freq_ur_feature(text, freq):405 return float(freq['ur'])406def freq_kin_feature(text, freq):407 return float(freq['kin'])408def freq_discreet_feature(text, freq):409 return float(freq['discreet'])410def freq_prozac_feature(text, freq):411 return float(freq['prozac'])412def freq_brbr_feature(text, freq):413 return float(freq['brbr'])414def freq_tirr_feature(text, freq):415 return float(freq['tirr'])416def freq_serial_feature(text, freq):417 return float(freq['serial'])418def freq_tadalafil_feature(text, freq):419 return float(freq['tadalafil'])420def freq_pinnacle_feature(text, freq):421 return float(freq['pinnacle'])422def freq_distributorjebel_feature(text, freq):423 return float(freq['distributorjebel'])424def freq_mai_feature(text, freq):425 return float(freq['mai'])426def freq_artprice_feature(text, freq):427 return float(freq['artprice'])428def freq_iso_feature(text, freq):429 return float(freq['iso'])430def freq_ambien_feature(text, freq):431 return float(freq['ambien'])432def freq_cheapest_feature(text, freq):433 return float(freq['cheapest'])434def freq_vlagra_feature(text, freq):435 return float(freq['vlagra'])436def freq_lasts_feature(text, freq):437 return float(freq['lasts'])438def freq_microcap_feature(text, freq):439 return float(freq['microcap'])440def freq_techlite_feature(text, freq):441 return float(freq['techlite'])442def freq_accessories_feature(text, freq):443 return float(freq['accessories'])444def freq_indicative_feature(text, freq):445 return float(freq['indicative'])446def freq_impotence_feature(text, freq):447 return float(freq['impotence'])448def freq_levitra_feature(text, freq):449 return float(freq['levitra'])450def freq_alcohol_feature(text, freq):451 return float(freq['alcohol'])452def freq_lls_feature(text, freq):453 return float(freq['lls'])454def freq_manufacturer_feature(text, freq):455 return float(freq['manufacturer'])456def freq_nigeria_feature(text, freq):457 return float(freq['nigeria'])458def freq_imited_feature(text, freq):459 return float(freq['imited'])460def freq_pr_feature(text, freq):461 return float(freq['pr'])462def freq_emerson_feature(text, freq):463 return float(freq['emerson'])464def freq_erection_feature(text, freq):465 return float(freq['erection'])466def freq_der_feature(text, freq):467 return float(freq['der'])468def freq_es_feature(text, freq):469 return float(freq['es'])470def freq_israeli_feature(text, freq):471 return float(freq['israeli'])472def freq_constitutes_feature(text, freq):473 return float(freq['constitutes'])474def freq_ooo_feature(text, freq):475 return float(freq['ooo'])476def freq_spacer_feature(text, freq):477 return float(freq['spacer'])478def freq_piease_feature(text, freq):479 return float(freq['piease'])480def freq_porn_feature(text, freq):481 return float(freq['porn'])482def freq_bingo_feature(text, freq):483 return float(freq['bingo'])484def freq_paypal_feature(text, freq):485 return float(freq['paypal'])486def freq_reform_feature(text, freq):487 return float(freq['reform'])488def freq_verge_feature(text, freq):489 return float(freq['verge'])490def freq_vl_feature(text, freq):491 return float(freq['vl'])492def freq_fontbr_feature(text, freq):493 return float(freq['fontbr'])494def freq_ffffffstrongfont_feature(text, freq):495 return float(freq['ffffffstrongfont'])496def freq_sans_feature(text, freq):497 return float(freq['sans'])498def freq_macintosh_feature(text, freq):499 return float(freq['macintosh'])500def freq_newsietter_feature(text, freq):501 return float(freq['newsietter'])502def freq_bias_feature(text, freq):503 return float(freq['bias'])504def freq_omit_feature(text, freq):505 return float(freq['omit'])506def freq_packaging_feature(text, freq):507 return float(freq['packaging'])508def freq_replica_feature(text, freq):509 return float(freq['replica'])510def freq_genuine_feature(text, freq):511 return float(freq['genuine'])512def freq_cum_feature(text, freq):513 return float(freq['cum'])514def freq_ion_feature(text, freq):515 return float(freq['ion'])516def freq_biosphere_feature(text, freq):517 return float(freq['biosphere'])518# --------- Ham features ----------519def freq_enron_feature(text, freq):520 return float(freq['enron'])521def freq_meter_feature(text, freq):522 return float(freq['meter'])523def freq_hpl_feature(text, freq):524 return float(freq['hpl'])525def freq_daren_feature(text, freq):526 return float(freq['daren'])527def freq_mmbtu_feature(text, freq):528 return float(freq['mmbtu'])529def freq_xls_feature(text, freq):530 return float(freq['xls'])531def freq_sitara_feature(text, freq):532 return float(freq['sitara'])533def freq_volumes_feature(text, freq):534 return float(freq['volumes'])535def freq_pec_feature(text, freq):536 return float(freq['pec'])537def freq_ena_feature(text, freq):538 return float(freq['ena'])539def freq_melissa_feature(text, freq):540 return float(freq['melissa'])541def freq_teco_feature(text, freq):542 return float(freq['teco'])543def freq_tenaska_feature(text, freq):544 return float(freq['tenaska'])545def freq_pat_feature(text, freq):546 return float(freq['pat'])547def freq_aimee_feature(text, freq):548 return float(freq['aimee'])549def freq_noms_feature(text, freq):550 return float(freq['noms'])551def freq_actuals_feature(text, freq):552 return float(freq['actuals'])553def freq_hsc_feature(text, freq):554 return float(freq['hsc'])555def freq_cotten_feature(text, freq):556 return float(freq['cotten'])557def freq_chokshi_feature(text, freq):558 return float(freq['chokshi'])559def freq_fyi_feature(text, freq):560 return float(freq['fyi'])561def freq_hplc_feature(text, freq):562 return float(freq['hplc'])563def freq_wellhead_feature(text, freq):564 return float(freq['wellhead'])565def freq_clynes_feature(text, freq):566 return float(freq['clynes'])567def freq_eastrans_feature(text, freq):568 return float(freq['eastrans'])569def freq_counterparty_feature(text, freq):570 return float(freq['counterparty'])571def freq_txu_feature(text, freq):572 return float(freq['txu'])573def freq_hplno_feature(text, freq):574 return float(freq['hplno'])575def freq_rita_feature(text, freq):576 return float(freq['rita'])577def freq_lannou_feature(text, freq):578 return float(freq['lannou'])579def freq_nominations_feature(text, freq):580 return float(freq['nominations'])581def freq_pefs_feature(text, freq):582 return float(freq['pefs'])583def freq_enronxgate_feature(text, freq):584 return float(freq['enronxgate'])585def freq_weissman_feature(text, freq):586 return float(freq['weissman'])587def freq_gcs_feature(text, freq):588 return float(freq['gcs'])589def freq_cec_feature(text, freq):590 return float(freq['cec'])591def freq_wynne_feature(text, freq):592 return float(freq['wynne'])593def freq_hplo_feature(text, freq):594 return float(freq['hplo'])595def freq_allocated_feature(text, freq):596 return float(freq['allocated'])597def freq_iferc_feature(text, freq):598 return float(freq['iferc'])599def freq_path_feature(text, freq):600 return float(freq['path'])601def freq_spreadsheet_feature(text, freq):602 return float(freq['spreadsheet'])603def freq_anita_feature(text, freq):604 return float(freq['anita'])605def freq_buyback_feature(text, freq):606 return float(freq['buyback'])607def freq_equistar_feature(text, freq):608 return float(freq['equistar'])609def freq_sherlyn_feature(text, freq):610 return float(freq['sherlyn'])611def freq_flowed_feature(text, freq):612 return float(freq['flowed'])613def freq_pops_feature(text, freq):614 return float(freq['pops'])615def freq_scheduling_feature(text, freq):616 return float(freq['scheduling'])617def freq_entex_feature(text, freq):618 return float(freq['entex'])619def freq_katy_feature(text, freq):620 return float(freq['katy'])621def freq_ees_feature(text, freq):622 return float(freq['ees'])623def freq_clem_feature(text, freq):624 return float(freq['clem'])625def freq_darren_feature(text, freq):626 return float(freq['darren'])627def freq_calpine_feature(text, freq):628 return float(freq['calpine'])629def freq_gco_feature(text, freq):630 return float(freq['gco'])631def freq_aep_feature(text, freq):632 return float(freq['aep'])633def freq_midcon_feature(text, freq):634 return float(freq['midcon'])635def freq_cornhusker_feature(text, freq):636 return float(freq['cornhusker'])637def freq_redeliveries_feature(text, freq):638 return float(freq['redeliveries'])639def freq_victor_feature(text, freq):640 return float(freq['victor'])641def freq_schumack_feature(text, freq):642 return float(freq['schumack'])643def freq_reinhardt_feature(text, freq):644 return float(freq['reinhardt'])645def freq_luong_feature(text, freq):646 return float(freq['luong'])647def freq_lsk_feature(text, freq):648 return float(freq['lsk'])649def freq_herod_feature(text, freq):650 return float(freq['herod'])651def freq_hplnl_feature(text, freq):652 return float(freq['hplnl'])653def freq_methanol_feature(text, freq):654 return float(freq['methanol'])655def freq_revision_feature(text, freq):656 return float(freq['revision'])657def freq_6353_feature(text, freq):658 return float(freq['6353'])659def freq_papayoti_feature(text, freq):660 return float(freq['papayoti'])661def freq_dfarmer_feature(text, freq):662 return float(freq['dfarmer'])663def freq_bryan_feature(text, freq):664 return float(freq['bryan'])665def freq_lamphier_feature(text, freq):666 return float(freq['lamphier'])667def freq_valero_feature(text, freq):668 return float(freq['valero'])669def freq_cleburne_feature(text, freq):670 return float(freq['cleburne'])671def freq_baumbach_feature(text, freq):672 return float(freq['baumbach'])673def freq_poorman_feature(text, freq):674 return float(freq['poorman'])675def freq_liz_feature(text, freq):676 return float(freq['liz'])677def freq_eol_feature(text, freq):678 return float(freq['eol'])679def freq_lsp_feature(text, freq):680 return float(freq['lsp'])681def freq_waha_feature(text, freq):682 return float(freq['waha'])683def freq_riley_feature(text, freq):684 return float(freq['riley'])685def freq_enrononline_feature(text, freq):686 return float(freq['enrononline'])687def freq_enserch_feature(text, freq):688 return float(freq['enserch'])689def freq_outage_feature(text, freq):690 return float(freq['outage'])691def freq_employee_feature(text, freq):692 return float(freq['employee'])693def freq_098_feature(text, freq):694 return float(freq['098'])695def freq_cernosek_feature(text, freq):696 return float(freq['cernosek'])697def freq_pathed_feature(text, freq):698 return float(freq['pathed'])699def freq_853_feature(text, freq):700 return float(freq['853'])701def freq_aepin_feature(text, freq):702 return float(freq['aepin'])703def freq_tejas_feature(text, freq):704 return float(freq['tejas'])705def freq_saturday_feature(text, freq):706 return float(freq['saturday'])707def freq_withers_feature(text, freq):708 return float(freq['withers'])709def freq_boas_feature(text, freq):710 return float(freq['boas'])711def freq_superty_feature(text, freq):712 return float(freq['superty'])713def freq_avila_feature(text, freq):714 return float(freq['avila'])715def freq_easttexas_feature(text, freq):716 return float(freq['easttexas'])717def freq_hesco_feature(text, freq):718 return float(freq['hesco'])719def freq_lamadrid_feature(text, freq):720 return float(freq['lamadrid'])721def freq_cdnow_feature(text, freq):722 return float(freq['cdnow'])723def freq_herrera_feature(text, freq):724 return float(freq['herrera'])725def freq_gpgfin_feature(text, freq):726 return float(freq['gpgfin'])727def freq_hakemack_feature(text, freq):728 return float(freq['hakemack'])729def freq_sandi_feature(text, freq):730 return float(freq['sandi'])731def freq_paso_feature(text, freq):732 return float(freq['paso'])733def freq_cp_feature(text, freq):734 return float(freq['cp'])735def freq_kcs_feature(text, freq):736 return float(freq['kcs'])737def freq_eileen_feature(text, freq):738 return float(freq['eileen'])739def freq_reliantenergy_feature(text, freq):740 return float(freq['reliantenergy'])741def freq_4179_feature(text, freq):742 return float(freq['4179'])743def freq_comments_feature(text, freq):744 return float(freq['comments'])745def freq_9497_feature(text, freq):746 return float(freq['9497'])747def freq_345_feature(text, freq):748 return float(freq['345'])749def freq_gomes_feature(text, freq):750 return float(freq['gomes'])751def freq_ponton_feature(text, freq):752 return float(freq['ponton'])753def freq_enw_feature(text, freq):754 return float(freq['enw'])755def freq_1266_feature(text, freq):756 return float(freq['1266'])757def freq_enerfin_feature(text, freq):758 return float(freq['enerfin'])759def freq_neon_feature(text, freq):760 return float(freq['neon'])761def freq_tisdale_feature(text, freq):762 return float(freq['tisdale'])763def freq_dynegy_feature(text, freq):764 return float(freq['dynegy'])765def freq_strangers_feature(text, freq):766 return float(freq['strangers'])767def freq_tetco_feature(text, freq):768 return float(freq['tetco'])769def freq_mckay_feature(text, freq):770 return float(freq['mckay'])771def freq_invoices_feature(text, freq):772 return float(freq['invoices'])773def freq_neuweiler_feature(text, freq):774 return float(freq['neuweiler'])775def freq_intrastate_feature(text, freq):776 return float(freq['intrastate'])777def freq_mops_feature(text, freq):778 return float(freq['mops'])779def freq_charlene_feature(text, freq):780 return float(freq['charlene'])781def freq_trader_feature(text, freq):782 return float(freq['trader'])783def freq_interconnect_feature(text, freq):784 return float(freq['interconnect'])785def freq_0435_feature(text, freq):786 return float(freq['0435'])787def freq_gtc_feature(text, freq):788 return float(freq['gtc'])789def freq_olsen_feature(text, freq):790 return float(freq['olsen'])791def freq_availabilities_feature(text, freq):792 return float(freq['availabilities'])793def freq_tufco_feature(text, freq):794 return float(freq['tufco'])795def freq_panenergy_feature(text, freq):796 return float(freq['panenergy'])797def freq_heidi_feature(text, freq):798 return float(freq['heidi'])799def freq_valadez_feature(text, freq):800 return float(freq['valadez'])801def freq_billed_feature(text, freq):802 return float(freq['billed'])803def freq_77002_feature(text, freq):804 return float(freq['77002'])805def freq_cass_feature(text, freq):806 return float(freq['cass'])807def freq_revisions_feature(text, freq):808 return float(freq['revisions'])809def freq_unaccounted_feature(text, freq):810 return float(freq['unaccounted'])811def freq_brazos_feature(text, freq):812 return float(freq['brazos'])813def freq_copano_feature(text, freq):814 return float(freq['copano'])815def freq_origination_feature(text, freq):816 return float(freq['origination'])817def freq_winfree_feature(text, freq):818 return float(freq['winfree'])819def freq_epgt_feature(text, freq):820 return float(freq['epgt'])821def freq_christy_feature(text, freq):822 return float(freq['christy'])823def freq_reveffo_feature(text, freq):824 return float(freq['reveffo'])825def freq_crosstex_feature(text, freq):826 return float(freq['crosstex'])827def freq_troy_feature(text, freq):828 return float(freq['troy'])829def freq_dth_feature(text, freq):830 return float(freq['dth'])831def freq_lonestar_feature(text, freq):832 return float(freq['lonestar'])833def freq_rick_feature(text, freq):834 return float(freq['rick'])835def freq_encina_feature(text, freq):836 return float(freq['encina'])837def freq_kelly_feature(text, freq):838 return float(freq['kelly'])839def freq_ews_feature(text, freq):840 return float(freq['ews'])841def freq_mmbtus_feature(text, freq):842 return float(freq['mmbtus'])843def freq_cpr_feature(text, freq):844 return float(freq['cpr'])845def freq_mtr_feature(text, freq):846 return float(freq['mtr'])847def freq_csikos_feature(text, freq):848 return float(freq['csikos'])849def freq_goliad_feature(text, freq):850 return float(freq['goliad'])851def freq_pager_feature(text, freq):852 return float(freq['pager'])853def freq_assigned_feature(text, freq):854 return float(freq['assigned'])855def freq_vols_feature(text, freq):856 return float(freq['vols'])857def freq_mcmills_feature(text, freq):858 return float(freq['mcmills'])859def freq_beaty_feature(text, freq):860 return float(freq['beaty'])861def freq_marta_feature(text, freq):862 return float(freq['marta'])863def freq_kristen_feature(text, freq):864 return float(freq['kristen'])865def freq_gdp_feature(text, freq):866 return float(freq['gdp'])867def freq_gisb_feature(text, freq):868 return float(freq['gisb'])869def freq_henderson_feature(text, freq):870 return float(freq['henderson'])871def freq_463_feature(text, freq):872 return float(freq['463'])873def freq_sweeney_feature(text, freq):874 return float(freq['sweeney'])875def freq_texoma_feature(text, freq):876 return float(freq['texoma'])877def freq_hernandez_feature(text, freq):878 return float(freq['hernandez'])879def freq_ebs_feature(text, freq):880 return float(freq['ebs'])881def freq_hillary_feature(text, freq):882 return float(freq['hillary'])883def freq_seaman_feature(text, freq):884 return float(freq['seaman'])885def freq_schedulers_feature(text, freq):886 return float(freq['schedulers'])887def freq_patti_feature(text, freq):888 return float(freq['patti'])889def freq_lindley_feature(text, freq):890 return float(freq['lindley'])891def freq_memo_feature(text, freq):892 return float(freq['memo'])893def freq_mazowita_feature(text, freq):894 return float(freq['mazowita'])895def freq_pathing_feature(text, freq):896 return float(freq['pathing'])897def freq_984132_feature(text, freq):898 return float(freq['984132'])899def freq_pgev_feature(text, freq):900 return float(freq['pgev'])901def freq_027_feature(text, freq):902 return float(freq['027'])903def freq_suzanne_feature(text, freq):904 return float(freq['suzanne'])905def freq_eb_feature(text, freq):906 return float(freq['eb'])907def freq_kinsey_feature(text, freq):908 return float(freq['kinsey'])909def freq_centana_feature(text, freq):910 return float(freq['centana'])911def freq_5192_feature(text, freq):912 return float(freq['5192'])913def freq_allocations_feature(text, freq):914 return float(freq['allocations'])915def freq_2700_feature(text, freq):916 return float(freq['2700'])917def freq_pena_feature(text, freq):918 return float(freq['pena'])919# Generates a feature vector920def generate_feature_vector(text, freq):921 feature = []922 feature.append(freq_pain_feature(text, freq))923 feature.append(freq_private_feature(text, freq))924 feature.append(freq_bank_feature(text, freq))925 feature.append(freq_money_feature(text, freq))926 feature.append(freq_drug_feature(text, freq))927 feature.append(freq_spam_feature(text, freq))928 feature.append(freq_prescription_feature(text, freq))929 feature.append(freq_creative_feature(text, freq))930 feature.append(freq_height_feature(text, freq))931 feature.append(freq_featured_feature(text, freq))932 feature.append(freq_differ_feature(text, freq))933 feature.append(freq_energy_feature(text, freq))934 feature.append(freq_message_feature(text, freq))935 feature.append(freq_volumes_feature(text, freq))936 feature.append(freq_revision_feature(text, freq))937 feature.append(freq_memo_feature(text, freq))938 feature.append(freq_planning_feature(text, freq))939 feature.append(freq_out_feature(text, freq))940 # Punctuation941 feature.append(freq_semicolon_feature(text, freq))942 feature.append(freq_dollar_feature(text, freq))943 feature.append(freq_sharp_feature(text, freq))944 feature.append(freq_exclamation_feature(text, freq))945 feature.append(freq_para_feature(text, freq))946 feature.append(freq_and_feature(text, freq))947 feature.append(freq_colon_feature(text, freq))948 feature.append(freq_double_quotes_feature(text, freq))949 feature.append(freq_single_quote_feature(text, freq))950 feature.append(freq_front_slash_feature(text, freq))951 feature.append(freq_closing_paren_feature(text, freq))952 feature.append(freq_pipe_feature(text, freq))953 feature.append(freq_dash_feature(text, freq))954 feature.append(freq_caret_feature(text, freq))955 feature.append(freq_at_feature(text, freq))956 feature.append(freq_greater_than_feature(text, freq))957 # Misc958 feature.append(freq_digit_feature(text, freq))959 # --------- Spam features ---------960 feature.append(freq_online_feature(text, freq))961 feature.append(freq_enlarge_feature(text, freq))962 feature.append(freq_click_feature(text, freq))963 feature.append(freq_here_feature(text, freq))964 feature.append(freq_guaranteed_feature(text, freq))965 feature.append(freq_free_feature(text, freq))966 feature.append(freq_please_feature(text, freq))967 # Start here968 feature.append(freq_td_feature(text, freq))969 feature.append(freq_nbsp_feature(text, freq))970 feature.append(freq_pills_feature(text, freq))971 feature.append(freq_width_feature(text, freq))972 feature.append(freq_computron_feature(text, freq))973 feature.append(freq_href_feature(text, freq))974 feature.append(freq_viagra_feature(text, freq))975 feature.append(freq_xp_feature(text, freq))976 feature.append(freq_src_feature(text, freq))977 feature.append(freq_cialis_feature(text, freq))978 feature.append(freq_soft_feature(text, freq))979 feature.append(freq_meds_feature(text, freq))980 feature.append(freq_paliourg_feature(text, freq))981 feature.append(freq_voip_feature(text, freq))982 feature.append(freq_oo_feature(text, freq))983 feature.append(freq_php_feature(text, freq))984 feature.append(freq_bgcolor_feature(text, freq))985 feature.append(freq_drugs_feature(text, freq))986 feature.append(freq_biz_feature(text, freq))987 feature.append(freq_mx_feature(text, freq))988 feature.append(freq_img_feature(text, freq))989 feature.append(freq_photoshop_feature(text, freq))990 feature.append(freq_valign_feature(text, freq))991 feature.append(freq_uncertainties_feature(text, freq))992 feature.append(freq_000000_feature(text, freq))993 feature.append(freq_div_feature(text, freq))994 feature.append(freq_hotlist_feature(text, freq))995 feature.append(freq_moopid_feature(text, freq))996 feature.append(freq_pharmacy_feature(text, freq))997 feature.append(freq_projections_feature(text, freq))998 feature.append(freq_gr_feature(text, freq))999 feature.append(freq_xanax_feature(text, freq))1000 feature.append(freq_htmlimg_feature(text, freq))1001 feature.append(freq_colspan_feature(text, freq))1002 feature.append(freq_corel_feature(text, freq))1003 feature.append(freq_readers_feature(text, freq))1004 feature.append(freq_macromedia_feature(text, freq))1005 feature.append(freq_dealer_feature(text, freq))1006 feature.append(freq_knle_feature(text, freq))1007 feature.append(freq_valium_feature(text, freq))1008 feature.append(freq_demokritos_feature(text, freq))1009 feature.append(freq_iit_feature(text, freq))1010 feature.append(freq_rolex_feature(text, freq))1011 feature.append(freq_intel_feature(text, freq))1012 feature.append(freq_speculative_feature(text, freq))1013 feature.append(freq_1933_feature(text, freq))1014 feature.append(freq_rnd_feature(text, freq))1015 feature.append(freq_rx_feature(text, freq))1016 feature.append(freq_jebel_feature(text, freq))1017 feature.append(freq_lots_feature(text, freq))1018 feature.append(freq_half_feature(text, freq))1019 feature.append(freq_alt_feature(text, freq))1020 feature.append(freq_ooking_feature(text, freq))1021 feature.append(freq_darial_feature(text, freq))1022 feature.append(freq_yap_feature(text, freq))1023 feature.append(freq_gra_feature(text, freq))1024 feature.append(freq_0310041_feature(text, freq))1025 feature.append(freq_canon_feature(text, freq))1026 feature.append(freq_export_feature(text, freq))1027 feature.append(freq_1934_feature(text, freq))1028 feature.append(freq_0424040_feature(text, freq))1029 feature.append(freq_pill_feature(text, freq))1030 feature.append(freq_ftar_feature(text, freq))1031 feature.append(freq_logos_feature(text, freq))1032 feature.append(freq_toshiba_feature(text, freq))1033 feature.append(freq_soma_feature(text, freq))1034 feature.append(freq_fontfont_feature(text, freq))1035 feature.append(freq_materially_feature(text, freq))1036 feature.append(freq_vicodin_feature(text, freq))1037 feature.append(freq_resellers_feature(text, freq))1038 feature.append(freq_viewsonic_feature(text, freq))1039 feature.append(freq_cellpadding_feature(text, freq))1040 feature.append(freq_1618_feature(text, freq))1041 feature.append(freq_robotics_feature(text, freq))1042 feature.append(freq_8834464_feature(text, freq))1043 feature.append(freq_hewlett_feature(text, freq))1044 feature.append(freq_8834454_feature(text, freq))1045 feature.append(freq_4176_feature(text, freq))1046 feature.append(freq_materia_feature(text, freq))1047 feature.append(freq_1226030_feature(text, freq))1048 feature.append(freq_apc_feature(text, freq))1049 feature.append(freq_iomega_feature(text, freq))1050 feature.append(freq_targus_feature(text, freq))1051 feature.append(freq_aopen_feature(text, freq))1052 feature.append(freq_customerservice_feature(text, freq))1053 feature.append(freq_nomad_feature(text, freq))1054 feature.append(freq_packard_feature(text, freq))1055 feature.append(freq_intellinet_feature(text, freq))1056 feature.append(freq_enquiries_feature(text, freq))1057 feature.append(freq_construed_feature(text, freq))1058 feature.append(freq_drug_feature(text, freq))1059 feature.append(freq_uae_feature(text, freq))1060 feature.append(freq_itoy_feature(text, freq))1061 feature.append(freq_predictions_feature(text, freq))1062 feature.append(freq_muscle_feature(text, freq))1063 feature.append(freq_zonedubai_feature(text, freq))1064 feature.append(freq_emirates_feature(text, freq))1065 feature.append(freq_leth_feature(text, freq))1066 feature.append(freq_anticipates_feature(text, freq))1067 feature.append(freq_aeor_feature(text, freq))1068 feature.append(freq_oem_feature(text, freq))1069 feature.append(freq_otcbb_feature(text, freq))1070 feature.append(freq_assurance_feature(text, freq))1071 feature.append(freq_internationa_feature(text, freq))1072 feature.append(freq_female_feature(text, freq))1073 feature.append(freq_resuits_feature(text, freq))1074 feature.append(freq_studio_feature(text, freq))1075 feature.append(freq_spain_feature(text, freq))1076 feature.append(freq_palestinian_feature(text, freq))1077 feature.append(freq_illustrator_feature(text, freq))1078 feature.append(freq_verdana_feature(text, freq))1079 feature.append(freq_aerofoam_feature(text, freq))1080 feature.append(freq_mining_feature(text, freq))1081 feature.append(freq_arial_feature(text, freq))1082 feature.append(freq_graphics_feature(text, freq))1083 feature.append(freq_vi_feature(text, freq))1084 feature.append(freq_abdv_feature(text, freq))1085 feature.append(freq_wysak_feature(text, freq))1086 feature.append(freq_sofftwaares_feature(text, freq))1087 feature.append(freq_apple_feature(text, freq))1088 feature.append(freq_eogi_feature(text, freq))1089 feature.append(freq_erections_feature(text, freq))1090 feature.append(freq_three_feature(text, freq))1091 feature.append(freq_pubiisher_feature(text, freq))1092 feature.append(freq_wiil_feature(text, freq))1093 feature.append(freq_gains_feature(text, freq))1094 feature.append(freq_ffffff_feature(text, freq))1095 feature.append(freq_phentermine_feature(text, freq))1096 feature.append(freq_hottlist_feature(text, freq))1097 feature.append(freq_cellspacing_feature(text, freq))1098 feature.append(freq_male_feature(text, freq))1099 feature.append(freq_atleast_feature(text, freq))1100 feature.append(freq_dosage_feature(text, freq))1101 feature.append(freq_netherlands_feature(text, freq))1102 feature.append(freq_ail_feature(text, freq))1103 feature.append(freq_prescriptions_feature(text, freq))1104 feature.append(freq_undervalued_feature(text, freq))1105 feature.append(freq_cia_feature(text, freq))1106 feature.append(freq_couid_feature(text, freq))1107 feature.append(freq_technoiogies_feature(text, freq))1108 feature.append(freq_dose_feature(text, freq))1109 feature.append(freq_opinions_feature(text, freq))1110 feature.append(freq_sir_feature(text, freq))1111 feature.append(freq_ur_feature(text, freq))1112 feature.append(freq_kin_feature(text, freq))1113 feature.append(freq_discreet_feature(text, freq))1114 feature.append(freq_prozac_feature(text, freq))1115 feature.append(freq_brbr_feature(text, freq))1116 feature.append(freq_tirr_feature(text, freq))1117 feature.append(freq_serial_feature(text, freq))1118 feature.append(freq_tadalafil_feature(text, freq))1119 feature.append(freq_pinnacle_feature(text, freq))1120 feature.append(freq_distributorjebel_feature(text, freq))1121 feature.append(freq_mai_feature(text, freq))1122 feature.append(freq_artprice_feature(text, freq))1123 feature.append(freq_iso_feature(text, freq))1124 feature.append(freq_ambien_feature(text, freq))1125 feature.append(freq_cheapest_feature(text, freq))1126 feature.append(freq_vlagra_feature(text, freq))1127 feature.append(freq_lasts_feature(text, freq))1128 feature.append(freq_microcap_feature(text, freq))1129 feature.append(freq_techlite_feature(text, freq))1130 feature.append(freq_accessories_feature(text, freq))1131 feature.append(freq_indicative_feature(text, freq))1132 feature.append(freq_impotence_feature(text, freq))1133 feature.append(freq_levitra_feature(text, freq))1134 feature.append(freq_alcohol_feature(text, freq))1135 feature.append(freq_lls_feature(text, freq))1136 feature.append(freq_manufacturer_feature(text, freq))1137 feature.append(freq_nigeria_feature(text, freq))1138 feature.append(freq_imited_feature(text, freq))1139 feature.append(freq_pr_feature(text, freq))1140 feature.append(freq_emerson_feature(text, freq))1141 feature.append(freq_erection_feature(text, freq))1142 feature.append(freq_der_feature(text, freq))1143 feature.append(freq_es_feature(text, freq))1144 feature.append(freq_israeli_feature(text, freq))1145 feature.append(freq_constitutes_feature(text, freq))1146 feature.append(freq_ooo_feature(text, freq))1147 feature.append(freq_spacer_feature(text, freq))1148 feature.append(freq_piease_feature(text, freq))1149 feature.append(freq_porn_feature(text, freq))1150 feature.append(freq_bingo_feature(text, freq))1151 feature.append(freq_paypal_feature(text, freq))1152 feature.append(freq_reform_feature(text, freq))1153 feature.append(freq_verge_feature(text, freq))1154 feature.append(freq_vl_feature(text, freq))1155 feature.append(freq_fontbr_feature(text, freq))1156 feature.append(freq_ffffffstrongfont_feature(text, freq))1157 feature.append(freq_sans_feature(text, freq))1158 feature.append(freq_macintosh_feature(text, freq))1159 feature.append(freq_newsietter_feature(text, freq))1160 feature.append(freq_bias_feature(text, freq))1161 feature.append(freq_omit_feature(text, freq))1162 feature.append(freq_packaging_feature(text, freq))1163 feature.append(freq_replica_feature(text, freq))1164 feature.append(freq_genuine_feature(text, freq))1165 feature.append(freq_cum_feature(text, freq))1166 feature.append(freq_ion_feature(text, freq))1167 feature.append(freq_biosphere_feature(text, freq))1168 # --------- Ham features ---------1169 feature.append(freq_enron_feature(text, freq))1170 feature.append(freq_meter_feature(text, freq))1171 feature.append(freq_hpl_feature(text, freq))1172 feature.append(freq_daren_feature(text, freq))1173 feature.append(freq_mmbtu_feature(text, freq))1174 feature.append(freq_xls_feature(text, freq))1175 feature.append(freq_sitara_feature(text, freq))1176 feature.append(freq_volumes_feature(text, freq))1177 feature.append(freq_pec_feature(text, freq))1178 feature.append(freq_ena_feature(text, freq))1179 feature.append(freq_melissa_feature(text, freq))1180 feature.append(freq_teco_feature(text, freq))1181 feature.append(freq_tenaska_feature(text, freq))1182 feature.append(freq_pat_feature(text, freq))1183 feature.append(freq_aimee_feature(text, freq))1184 feature.append(freq_noms_feature(text, freq))1185 feature.append(freq_actuals_feature(text, freq))1186 feature.append(freq_hsc_feature(text, freq))1187 feature.append(freq_cotten_feature(text, freq))1188 feature.append(freq_chokshi_feature(text, freq))1189 feature.append(freq_fyi_feature(text, freq))1190 feature.append(freq_hplc_feature(text, freq))1191 feature.append(freq_wellhead_feature(text, freq))1192 feature.append(freq_clynes_feature(text, freq))1193 feature.append(freq_eastrans_feature(text, freq))1194 feature.append(freq_counterparty_feature(text, freq))1195 feature.append(freq_txu_feature(text, freq))1196 feature.append(freq_hplno_feature(text, freq))1197 feature.append(freq_rita_feature(text, freq))1198 feature.append(freq_lannou_feature(text, freq))1199 feature.append(freq_nominations_feature(text, freq))1200 feature.append(freq_pefs_feature(text, freq))1201 feature.append(freq_enronxgate_feature(text, freq))1202 feature.append(freq_weissman_feature(text, freq))1203 feature.append(freq_gcs_feature(text, freq))1204 feature.append(freq_cec_feature(text, freq))1205 feature.append(freq_wynne_feature(text, freq))1206 feature.append(freq_hplo_feature(text, freq))1207 feature.append(freq_allocated_feature(text, freq))1208 feature.append(freq_iferc_feature(text, freq))1209 feature.append(freq_path_feature(text, freq))1210 feature.append(freq_spreadsheet_feature(text, freq))1211 feature.append(freq_anita_feature(text, freq))1212 feature.append(freq_buyback_feature(text, freq))1213 feature.append(freq_equistar_feature(text, freq))1214 feature.append(freq_sherlyn_feature(text, freq))1215 feature.append(freq_flowed_feature(text, freq))1216 feature.append(freq_pops_feature(text, freq))1217 feature.append(freq_scheduling_feature(text, freq))1218 feature.append(freq_entex_feature(text, freq))1219 feature.append(freq_katy_feature(text, freq))1220 feature.append(freq_ees_feature(text, freq))1221 feature.append(freq_clem_feature(text, freq))1222 feature.append(freq_darren_feature(text, freq))1223 feature.append(freq_calpine_feature(text, freq))1224 feature.append(freq_gco_feature(text, freq))1225 feature.append(freq_aep_feature(text, freq))1226 feature.append(freq_midcon_feature(text, freq))1227 feature.append(freq_cornhusker_feature(text, freq))1228 feature.append(freq_redeliveries_feature(text, freq))1229 feature.append(freq_victor_feature(text, freq))1230 feature.append(freq_schumack_feature(text, freq))1231 feature.append(freq_reinhardt_feature(text, freq))1232 feature.append(freq_luong_feature(text, freq))1233 feature.append(freq_lsk_feature(text, freq))1234 feature.append(freq_herod_feature(text, freq))1235 feature.append(freq_hplnl_feature(text, freq))1236 feature.append(freq_methanol_feature(text, freq))1237 feature.append(freq_revision_feature(text, freq))1238 feature.append(freq_6353_feature(text, freq))1239 feature.append(freq_papayoti_feature(text, freq))1240 feature.append(freq_dfarmer_feature(text, freq))1241 feature.append(freq_bryan_feature(text, freq))1242 feature.append(freq_lamphier_feature(text, freq))1243 feature.append(freq_valero_feature(text, freq))1244 feature.append(freq_cleburne_feature(text, freq))1245 feature.append(freq_baumbach_feature(text, freq))1246 feature.append(freq_poorman_feature(text, freq))1247 feature.append(freq_liz_feature(text, freq))1248 feature.append(freq_eol_feature(text, freq))1249 feature.append(freq_lsp_feature(text, freq))1250 feature.append(freq_waha_feature(text, freq))1251 feature.append(freq_riley_feature(text, freq))1252 feature.append(freq_enrononline_feature(text, freq))1253 feature.append(freq_enserch_feature(text, freq))1254 feature.append(freq_outage_feature(text, freq))1255 feature.append(freq_employee_feature(text, freq))1256 feature.append(freq_098_feature(text, freq))1257 feature.append(freq_cernosek_feature(text, freq))1258 feature.append(freq_pathed_feature(text, freq))1259 feature.append(freq_853_feature(text, freq))1260 feature.append(freq_aepin_feature(text, freq))1261 feature.append(freq_tejas_feature(text, freq))1262 feature.append(freq_saturday_feature(text, freq))1263 feature.append(freq_withers_feature(text, freq))1264 feature.append(freq_boas_feature(text, freq))1265 feature.append(freq_superty_feature(text, freq))1266 feature.append(freq_avila_feature(text, freq))1267 feature.append(freq_easttexas_feature(text, freq))1268 feature.append(freq_hesco_feature(text, freq))1269 feature.append(freq_lamadrid_feature(text, freq))1270 feature.append(freq_cdnow_feature(text, freq))1271 feature.append(freq_herrera_feature(text, freq))1272 feature.append(freq_gpgfin_feature(text, freq))1273 feature.append(freq_hakemack_feature(text, freq))1274 feature.append(freq_sandi_feature(text, freq))1275 feature.append(freq_paso_feature(text, freq))1276 feature.append(freq_cp_feature(text, freq))1277 feature.append(freq_kcs_feature(text, freq))1278 feature.append(freq_eileen_feature(text, freq))1279 feature.append(freq_reliantenergy_feature(text, freq))1280 feature.append(freq_4179_feature(text, freq))1281 feature.append(freq_comments_feature(text, freq))1282 feature.append(freq_9497_feature(text, freq))1283 feature.append(freq_345_feature(text, freq))1284 feature.append(freq_gomes_feature(text, freq))1285 feature.append(freq_ponton_feature(text, freq))1286 feature.append(freq_enw_feature(text, freq))1287 feature.append(freq_1266_feature(text, freq))1288 feature.append(freq_enerfin_feature(text, freq))1289 feature.append(freq_neon_feature(text, freq))1290 feature.append(freq_tisdale_feature(text, freq))1291 feature.append(freq_dynegy_feature(text, freq))1292 feature.append(freq_strangers_feature(text, freq))1293 feature.append(freq_tetco_feature(text, freq))1294 feature.append(freq_mckay_feature(text, freq))1295 feature.append(freq_invoices_feature(text, freq))1296 feature.append(freq_neuweiler_feature(text, freq))1297 feature.append(freq_intrastate_feature(text, freq))1298 feature.append(freq_mops_feature(text, freq))1299 feature.append(freq_charlene_feature(text, freq))1300 feature.append(freq_trader_feature(text, freq))1301 feature.append(freq_interconnect_feature(text, freq))1302 feature.append(freq_0435_feature(text, freq))1303 feature.append(freq_gtc_feature(text, freq))1304 feature.append(freq_olsen_feature(text, freq))1305 feature.append(freq_availabilities_feature(text, freq))1306 feature.append(freq_tufco_feature(text, freq))1307 feature.append(freq_panenergy_feature(text, freq))1308 feature.append(freq_heidi_feature(text, freq))1309 feature.append(freq_valadez_feature(text, freq))1310 feature.append(freq_billed_feature(text, freq))1311 feature.append(freq_77002_feature(text, freq))1312 feature.append(freq_cass_feature(text, freq))1313 feature.append(freq_revisions_feature(text, freq))1314 feature.append(freq_unaccounted_feature(text, freq))1315 feature.append(freq_brazos_feature(text, freq))1316 feature.append(freq_copano_feature(text, freq))1317 feature.append(freq_origination_feature(text, freq))1318 feature.append(freq_winfree_feature(text, freq))1319 feature.append(freq_epgt_feature(text, freq))1320 feature.append(freq_christy_feature(text, freq))1321 feature.append(freq_reveffo_feature(text, freq))1322 feature.append(freq_crosstex_feature(text, freq))1323 feature.append(freq_troy_feature(text, freq))1324 feature.append(freq_dth_feature(text, freq))1325 feature.append(freq_lonestar_feature(text, freq))1326 feature.append(freq_rick_feature(text, freq))1327 feature.append(freq_encina_feature(text, freq))1328 feature.append(freq_kelly_feature(text, freq))1329 feature.append(freq_ews_feature(text, freq))1330 feature.append(freq_mmbtus_feature(text, freq))1331 feature.append(freq_cpr_feature(text, freq))1332 feature.append(freq_mtr_feature(text, freq))1333 feature.append(freq_csikos_feature(text, freq))1334 feature.append(freq_goliad_feature(text, freq))1335 feature.append(freq_pager_feature(text, freq))1336 feature.append(freq_assigned_feature(text, freq))1337 feature.append(freq_vols_feature(text, freq))1338 feature.append(freq_mcmills_feature(text, freq))1339 feature.append(freq_beaty_feature(text, freq))1340 feature.append(freq_marta_feature(text, freq))1341 feature.append(freq_kristen_feature(text, freq))1342 feature.append(freq_gdp_feature(text, freq))1343 feature.append(freq_gisb_feature(text, freq))1344 feature.append(freq_henderson_feature(text, freq))1345 feature.append(freq_463_feature(text, freq))1346 feature.append(freq_sweeney_feature(text, freq))1347 feature.append(freq_texoma_feature(text, freq))1348 feature.append(freq_hernandez_feature(text, freq))1349 feature.append(freq_ebs_feature(text, freq))1350 feature.append(freq_hillary_feature(text, freq))1351 feature.append(freq_seaman_feature(text, freq))1352 feature.append(freq_schedulers_feature(text, freq))1353 feature.append(freq_patti_feature(text, freq))1354 feature.append(freq_lindley_feature(text, freq))1355 feature.append(freq_memo_feature(text, freq))1356 feature.append(freq_mazowita_feature(text, freq))1357 feature.append(freq_pathing_feature(text, freq))1358 feature.append(freq_984132_feature(text, freq))1359 feature.append(freq_pgev_feature(text, freq))1360 feature.append(freq_027_feature(text, freq))1361 feature.append(freq_suzanne_feature(text, freq))1362 feature.append(freq_eb_feature(text, freq))1363 feature.append(freq_kinsey_feature(text, freq))1364 feature.append(freq_centana_feature(text, freq))1365 feature.append(freq_5192_feature(text, freq))1366 feature.append(freq_allocations_feature(text, freq))1367 feature.append(freq_2700_feature(text, freq))1368 feature.append(freq_pena_feature(text, freq))1369 return feature1370# This method generates a design matrix with a list of filenames1371# Each file is a single training example1372def generate_design_matrix(filenames):1373 design_matrix = []1374 for filename in filenames:1375 with open(filename) as f:1376 text = f.read() # Read in text from file1377 text = text.replace('\r\n', ' ') # Remove newline character1378 words = re.findall(r'\w+', text)1379 word_freq = defaultdict(int) # Frequency of all words1380 for word in words:1381 word_freq[word] += 11382 # Create a feature vector1383 feature_vector = generate_feature_vector(text, word_freq)1384 design_matrix.append(feature_vector)1385 return design_matrix1386# ************** Script starts here **************1387# DO NOT MODIFY ANYTHING BELOW1388spam_filenames = glob.glob(BASE_DIR + SPAM_DIR + '*.txt')1389spam_design_matrix = generate_design_matrix(spam_filenames)1390ham_filenames = glob.glob(BASE_DIR + HAM_DIR + '*.txt')1391ham_design_matrix = generate_design_matrix(ham_filenames)1392# Important: the test_filenames must be in numerical order as that is the1393# order we will be evaluating your classifier1394test_filenames = [BASE_DIR + TEST_DIR + str(x) + '.txt' for x in range(NUM_TEST_EXAMPLES)]1395test_design_matrix = generate_design_matrix(test_filenames)1396X = spam_design_matrix + ham_design_matrix1397Y = [1]*len(spam_design_matrix) + [0]*len(ham_design_matrix)1398file_dict = {}1399file_dict['training_data'] = X1400file_dict['training_labels'] = Y1401file_dict['test_data'] = test_design_matrix...
jquery-ui-timepicker-addon-i18n.js
Source:jquery-ui-timepicker-addon-i18n.js
1/*! jQuery Timepicker Addon - v1.4.5 - 2014-05-262* http://trentrichardson.com/examples/timepicker3* Copyright (c) 2014 Trent Richardson; Licensed MIT */4(function($){5/* Afrikaans translation for the jQuery Timepicker Addon */6/* Written by Deon Heyns */7(function($) {8 $.timepicker.regional['af'] = {9 timeOnlyTitle: 'Kies Tyd',10 timeText: 'Tyd ',11 hourText: 'Ure ',12 minuteText: 'Minute',13 secondText: 'Sekondes',14 millisecText: 'Millisekondes',15 microsecText: 'Mikrosekondes',16 timezoneText: 'Tydsone',17 currentText: 'Huidige Tyd',18 closeText: 'Klaar',19 timeFormat: 'HH:mm',20 amNames: ['AM', 'A'],21 pmNames: ['PM', 'P'],22 isRTL: false23 };24 $.timepicker.setDefaults($.timepicker.regional['af']);25})(jQuery);26/* Armenian translation for the jQuery Timepicker Addon */27/* Written by Artavazd Avetisyan artavazda@hotmail.com */28(function($) {29 $.timepicker.regional['am'] = {30 timeOnlyTitle: 'Ô¸Õ¶Õ¿ÖÕ¥Ö ÕªÕ¡Õ´Õ¡Õ¶Õ¡Õ¯Õ¨',31 timeText: 'ÔºÕ¡Õ´Õ¡Õ¶Õ¡Õ¯Õ¨',32 hourText: 'ÔºÕ¡Õ´',33 minuteText: 'ÕÕ¸ÕºÕ¥',34 secondText: 'ÕÕ¡ÖÕ¯ÕµÕ¡Õ¶',35 millisecText: 'ÕÕ«Õ¬Õ«Õ¾Õ¡ÖÕ¯ÕµÕ¡Õ¶',36 microsecText: 'ÕÕ«Õ¯ÖÕ¸Õ¾Õ¡ÖÕ¯ÕµÕ¡Õ¶',37 timezoneText: 'ÔºÕ¡Õ´Õ¡ÕµÕ«Õ¶ Õ£Õ¸Õ¿Õ«Õ¶',38 currentText: 'Ô±ÕµÕªÕ´',39 closeText: 'ÕÕ¡Õ¯Õ¥Õ¬',40 timeFormat: 'HH:mm',41 amNames: ['AM', 'A'],42 pmNames: ['PM', 'P'],43 isRTL: false44 };45 $.timepicker.setDefaults($.timepicker.regional['am']);46})(jQuery);47/* Bulgarian translation for the jQuery Timepicker Addon */48/* Written by Plamen Kovandjiev */49(function($) {50 $.timepicker.regional['bg'] = {51 timeOnlyTitle: 'ÐзбеÑеÑе вÑеме',52 timeText: 'ÐÑеме',53 hourText: 'ЧаÑ',54 minuteText: 'ÐинÑÑи',55 secondText: 'СекÑнди',56 millisecText: 'ÐилиÑекÑнди',57 microsecText: 'ÐикÑоÑекÑнди',58 timezoneText: 'ЧаÑови поÑÑ',59 currentText: 'Сега',60 closeText: 'ÐаÑвоÑи',61 timeFormat: 'HH:mm',62 amNames: ['AM', 'A'],63 pmNames: ['PM', 'P'],64 isRTL: false65 };66 $.timepicker.setDefaults($.timepicker.regional['bg']);67})(jQuery);68/* Catalan translation for the jQuery Timepicker Addon */69/* Written by Sergi Faber */70(function($) {71 $.timepicker.regional['ca'] = {72 timeOnlyTitle: 'Escollir una hora',73 timeText: 'Hora',74 hourText: 'Hores',75 minuteText: 'Minuts',76 secondText: 'Segons',77 millisecText: 'Milisegons',78 microsecText: 'Microsegons',79 timezoneText: 'Fus horari',80 currentText: 'Ara',81 closeText: 'Tancar',82 timeFormat: 'HH:mm',83 amNames: ['AM', 'A'],84 pmNames: ['PM', 'P'],85 isRTL: false86 };87 $.timepicker.setDefaults($.timepicker.regional['ca']);88})(jQuery);89/* Czech translation for the jQuery Timepicker Addon */90/* Written by OndÅej VodáÄek */91(function($) {92 $.timepicker.regional['cs'] = {93 timeOnlyTitle: 'Vyberte Äas',94 timeText: 'Äas',95 hourText: 'Hodiny',96 minuteText: 'Minuty',97 secondText: 'VteÅiny',98 millisecText: 'Milisekundy',99 microsecText: 'Mikrosekundy',100 timezoneText: 'Äasové pásmo',101 currentText: 'NynÃ',102 closeText: 'ZavÅÃt',103 timeFormat: 'HH:mm',104 amNames: ['dop.', 'AM', 'A'],105 pmNames: ['odp.', 'PM', 'P'],106 isRTL: false107 };108 $.timepicker.setDefaults($.timepicker.regional['cs']);109})(jQuery);110/* Danish translation for the jQuery Timepicker Addon */111/* Written by Lars H. Jensen (http://www.larshj.dk) */112(function ($) {113 $.timepicker.regional['da'] = {114 timeOnlyTitle: 'Vælg tid',115 timeText: 'Tid',116 hourText: 'Time',117 minuteText: 'Minut',118 secondText: 'Sekund',119 millisecText: 'Millisekund',120 microsecText: 'Mikrosekund',121 timezoneText: 'Tidszone',122 currentText: 'Nu',123 closeText: 'Luk',124 timeFormat: 'HH:mm',125 amNames: ['am', 'AM', 'A'],126 pmNames: ['pm', 'PM', 'P'],127 isRTL: false128 };129 $.timepicker.setDefaults($.timepicker.regional['da']);130})(jQuery);131/* German translation for the jQuery Timepicker Addon */132/* Written by Marvin */133(function($) {134 $.timepicker.regional['de'] = {135 timeOnlyTitle: 'Zeit wählen',136 timeText: 'Zeit',137 hourText: 'Stunde',138 minuteText: 'Minute',139 secondText: 'Sekunde',140 millisecText: 'Millisekunde',141 microsecText: 'Mikrosekunde',142 timezoneText: 'Zeitzone',143 currentText: 'Jetzt',144 closeText: 'Fertig',145 timeFormat: 'HH:mm',146 amNames: ['vorm.', 'AM', 'A'],147 pmNames: ['nachm.', 'PM', 'P'],148 isRTL: false149 };150 $.timepicker.setDefaults($.timepicker.regional['de']);151})(jQuery);152/* Hellenic translation for the jQuery Timepicker Addon */153/* Written by Christos Pontikis */154(function($) {155 $.timepicker.regional['el'] = {156 timeOnlyTitle: 'ÎÏιλογή ÏÏαÏ',157 timeText: 'ÎÏα',158 hourText: 'ÎÏεÏ',159 minuteText: 'ÎεÏÏά',160 secondText: 'ÎεÏ
ÏεÏÏλεÏÏα',161 millisecText: 'μιλιδεÏ
ÏεÏÏλεÏÏο',162 microsecText: 'Microseconds',163 timezoneText: 'ÎÏνη ÏÏαÏ',164 currentText: 'ΤÏÏα',165 closeText: 'ÎλείÏιμο',166 timeFormat: 'HH:mm',167 amNames: ['Ï.μ.', 'AM', 'A'],168 pmNames: ['μ.μ.', 'PM', 'P'],169 isRTL: false170 };171 $.timepicker.setDefaults($.timepicker.regional['el']);172})(jQuery);173/* Spanish translation for the jQuery Timepicker Addon */174/* Written by Ianaré Sévi */175(function($) {176 $.timepicker.regional['es'] = {177 timeOnlyTitle: 'Elegir una hora',178 timeText: 'Hora',179 hourText: 'Horas',180 minuteText: 'Minutos',181 secondText: 'Segundos',182 millisecText: 'Milisegundos',183 microsecText: 'Microsegundos',184 timezoneText: 'Huso horario',185 currentText: 'Ahora',186 closeText: 'Cerrar',187 timeFormat: 'HH:mm',188 amNames: ['a.m.', 'AM', 'A'],189 pmNames: ['p.m.', 'PM', 'P'],190 isRTL: false191 };192 $.timepicker.setDefaults($.timepicker.regional['es']);193})(jQuery);194/* Estonian translation for the jQuery Timepicker Addon */195/* Written by Karl Sutt (karl@sutt.ee) */196(function($) {197 $.timepicker.regional['et'] = {198 timeOnlyTitle: 'Vali aeg',199 timeText: 'Aeg',200 hourText: 'Tund',201 minuteText: 'Minut',202 secondText: 'Sekund',203 millisecText: 'Millisekundis',204 microsecText: 'Mikrosekundis',205 timezoneText: 'Ajavöönd',206 currentText: 'Praegu',207 closeText: 'Valmis',208 timeFormat: 'HH:mm',209 amNames: ['AM', 'A'],210 pmNames: ['PM', 'P'],211 isRTL: false212 };213 $.timepicker.setDefaults($.timepicker.regional['et']);214})(jQuery);215/* Basque trannslation for JQuery Timepicker Addon */216/* Translated by Xabi Fer */217/* Fixed by Asier Iturralde Sarasola - iametza interaktiboa */218(function($) {219 $.timepicker.regional['eu'] = {220 timeOnlyTitle: 'Aukeratu ordua',221 timeText: 'Ordua',222 hourText: 'Orduak',223 minuteText: 'Minutuak',224 secondText: 'Segundoak',225 millisecText: 'Milisegundoak',226 microsecText: 'Mikrosegundoak',227 timezoneText: 'Ordu-eremua',228 currentText: 'Orain',229 closeText: 'Itxi',230 timeFormat: 'HH:mm',231 amNames: ['a.m.', 'AM', 'A'],232 pmNames: ['p.m.', 'PM', 'P'],233 isRTL: false234 };235 $.timepicker.setDefaults($.timepicker.regional['eu']);236})(jQuery);237/* Finnish translation for the jQuery Timepicker Addon */238/* Written by Juga Paazmaya (http://github.com/paazmaya) */239(function($) {240 $.timepicker.regional['fi'] = {241 timeOnlyTitle: 'Valitse aika',242 timeText: 'Aika',243 hourText: 'Tunti',244 minuteText: 'Minuutti',245 secondText: 'Sekunti',246 millisecText: 'Millisekunnin',247 microsecText: 'Mikrosekuntia',248 timezoneText: 'Aikavyöhyke',249 currentText: 'Nyt',250 closeText: 'Sulje',251 timeFormat: 'HH:mm',252 amNames: ['ap.', 'AM', 'A'],253 pmNames: ['ip.', 'PM', 'P'],254 isRTL: false255 };256 $.timepicker.setDefaults($.timepicker.regional['fi']);257})(jQuery);258/* French translation for the jQuery Timepicker Addon */259/* Written by Thomas Lété */260(function($) {261 $.timepicker.regional['fr'] = {262 timeOnlyTitle: 'Choisir une heure',263 timeText: 'Heure',264 hourText: 'Heures',265 minuteText: 'Minutes',266 secondText: 'Secondes',267 millisecText: 'Millisecondes',268 microsecText: 'Microsecondes',269 timezoneText: 'Fuseau horaire',270 currentText: 'Maintenant',271 closeText: 'Terminé',272 timeFormat: 'HH:mm',273 amNames: ['AM', 'A'],274 pmNames: ['PM', 'P'],275 isRTL: false276 };277 $.timepicker.setDefaults($.timepicker.regional['fr']);278})(jQuery);279/* Galician translation for the jQuery Timepicker Addon */280/* Written by David Barral */281(function($) {282 $.timepicker.regional['gl'] = {283 timeOnlyTitle: 'Elixir unha hora',284 timeText: 'Hora',285 hourText: 'Horas',286 minuteText: 'Minutos',287 secondText: 'Segundos',288 millisecText: 'Milisegundos',289 microsecText: 'Microssegundos',290 timezoneText: 'Fuso horario',291 currentText: 'Agora',292 closeText: 'Pechar',293 timeFormat: 'HH:mm',294 amNames: ['a.m.', 'AM', 'A'],295 pmNames: ['p.m.', 'PM', 'P'],296 isRTL: false297 };298 $.timepicker.setDefaults($.timepicker.regional['gl']);299})(jQuery);300/* Hebrew translation for the jQuery Timepicker Addon */301/* Written by Lior Lapid */302(function($) {303 $.timepicker.regional["he"] = {304 timeOnlyTitle: "×××רת ×××",305 timeText: "שע×",306 hourText: "שע×ת",307 minuteText: "×ק×ת",308 secondText: "×©× ××ת",309 millisecText: "××פ×ת ××©× ×××",310 microsecText: "××קר×",311 timezoneText: "×××ר ×××",312 currentText: "×¢×ש××",313 closeText:"ס××ר",314 timeFormat: "HH:mm",315 amNames: ['××¤× ×"צ', 'AM', 'A'],316 pmNames: ['×××"צ', 'PM', 'P'],317 isRTL: true318 };319 $.timepicker.setDefaults($.timepicker.regional["he"]);320})(jQuery);321/* Croatian translation for the jQuery Timepicker Addon */322/* Written by Mladen */323(function($) {324 $.timepicker.regional['hr'] = {325 timeOnlyTitle: 'Odaberi vrijeme',326 timeText: 'Vrijeme',327 hourText: 'Sati',328 minuteText: 'Minute',329 secondText: 'Sekunde',330 millisecText: 'Milisekunde',331 microsecText: 'Mikrosekunde',332 timezoneText: 'Vremenska zona',333 currentText: 'Sada',334 closeText: 'Gotovo',335 timeFormat: 'HH:mm',336 amNames: ['a.m.', 'AM', 'A'],337 pmNames: ['p.m.', 'PM', 'P'],338 isRTL: false339 };340 $.timepicker.setDefaults($.timepicker.regional['hr']);341})(jQuery);342/* Hungarian translation for the jQuery Timepicker Addon */343/* Written by Vas Gábor */344(function($) {345 $.timepicker.regional['hu'] = {346 timeOnlyTitle: 'Válasszon idÅpontot',347 timeText: 'IdÅ',348 hourText: 'Ãra',349 minuteText: 'Perc',350 secondText: 'Másodperc',351 millisecText: 'Milliszekundumos',352 microsecText: 'Ezredmásodperc',353 timezoneText: 'IdÅzóna',354 currentText: 'Most',355 closeText: 'Kész',356 timeFormat: 'HH:mm',357 amNames: ['de.', 'AM', 'A'],358 pmNames: ['du.', 'PM', 'P'],359 isRTL: false360 };361 $.timepicker.setDefaults($.timepicker.regional['hu']);362})(jQuery);363/* Indonesian translation for the jQuery Timepicker Addon */364/* Written by Nia */365(function($) {366 $.timepicker.regional['id'] = {367 timeOnlyTitle: 'Pilih Waktu',368 timeText: 'Waktu',369 hourText: 'Pukul',370 minuteText: 'Menit',371 secondText: 'Detik',372 millisecText: 'Milidetik',373 microsecText: 'Mikrodetik',374 timezoneText: 'Zona Waktu',375 currentText: 'Sekarang',376 closeText: 'OK',377 timeFormat: 'HH:mm',378 amNames: ['AM', 'A'],379 pmNames: ['PM', 'P'],380 isRTL: false381 };382 $.timepicker.setDefaults($.timepicker.regional['id']);383})(jQuery);384/* Italian translation for the jQuery Timepicker Addon */385/* Written by Marco "logicoder" Del Tongo */386(function($) {387 $.timepicker.regional['it'] = {388 timeOnlyTitle: 'Scegli orario',389 timeText: 'Orario',390 hourText: 'Ora',391 minuteText: 'Minuti',392 secondText: 'Secondi',393 millisecText: 'Millisecondi',394 microsecText: 'Microsecondi',395 timezoneText: 'Fuso orario',396 currentText: 'Adesso',397 closeText: 'Chiudi',398 timeFormat: 'HH:mm',399 amNames: ['m.', 'AM', 'A'],400 pmNames: ['p.', 'PM', 'P'],401 isRTL: false402 };403 $.timepicker.setDefaults($.timepicker.regional['it']);404})(jQuery);405/* Japanese translation for the jQuery Timepicker Addon */406/* Written by Jun Omae */407(function($) {408 $.timepicker.regional['ja'] = {409 timeOnlyTitle: 'æéãé¸æ',410 timeText: 'æé',411 hourText: 'æ',412 minuteText: 'å',413 secondText: 'ç§',414 millisecText: 'ããªç§',415 microsecText: 'ãã¤ã¯ãç§',416 timezoneText: 'ã¿ã¤ã ã¾ã¼ã³',417 currentText: 'ç¾æå»',418 closeText: 'éãã',419 timeFormat: 'HH:mm',420 amNames: ['åå', 'AM', 'A'],421 pmNames: ['åå¾', 'PM', 'P'],422 isRTL: false423 };424 $.timepicker.setDefaults($.timepicker.regional['ja']);425})(jQuery);426/* Korean translation for the jQuery Timepicker Addon */427/* Written by Genie */428(function($) {429 $.timepicker.regional['ko'] = {430 timeOnlyTitle: 'ìê° ì í',431 timeText: 'ìê°',432 hourText: 'ì',433 minuteText: 'ë¶',434 secondText: 'ì´',435 millisecText: 'ë°ë¦¬ì´',436 microsecText: 'ë§ì´í¬ë¡',437 timezoneText: 'íì¤ ìê°ë',438 currentText: 'íì¬ ìê°',439 closeText: 'ë«ê¸°',440 timeFormat: 'tt h:mm',441 amNames: ['ì¤ì ', 'AM', 'A'],442 pmNames: ['ì¤í', 'PM', 'P'],443 isRTL: false444 };445 $.timepicker.setDefaults($.timepicker.regional['ko']);446})(jQuery);447/* Lithuanian translation for the jQuery Timepicker Addon */448/* Written by Irmantas Å iupÅ¡inskas */449(function($) {450 $.timepicker.regional['lt'] = {451 timeOnlyTitle: 'Pasirinkite laikÄ
',452 timeText: 'Laikas',453 hourText: 'Valandos',454 minuteText: 'MinutÄs',455 secondText: 'SekundÄs',456 millisecText: 'MilisekundÄs',457 microsecText: 'MikrosekundÄs',458 timezoneText: 'Laiko zona',459 currentText: 'Dabar',460 closeText: 'Uždaryti',461 timeFormat: 'HH:mm',462 amNames: ['prieÅ¡piet', 'AM', 'A'],463 pmNames: ['popiet', 'PM', 'P'],464 isRTL: false465 };466 $.timepicker.setDefaults($.timepicker.regional['lt']);467})(jQuery);468/* Dutch translation for the jQuery Timepicker Addon */469/* Written by Martijn van der Lee */470(function($) {471 $.timepicker.regional['nl'] = {472 timeOnlyTitle: 'Tijdstip',473 timeText: 'Tijd',474 hourText: 'Uur',475 minuteText: 'Minuut',476 secondText: 'Seconde',477 millisecText: 'Milliseconde',478 microsecText: 'Microseconde',479 timezoneText: 'Tijdzone',480 currentText: 'Vandaag',481 closeText: 'Sluiten',482 timeFormat: 'HH:mm',483 amNames: ['AM', 'A'],484 pmNames: ['PM', 'P'],485 isRTL: false486 };487 $.timepicker.setDefaults($.timepicker.regional['nl']);488})(jQuery);489/* Norwegian translation for the jQuery Timepicker Addon */490/* Written by Morten Hauan (http://hauan.me) */491(function($) {492 $.timepicker.regional['no'] = {493 timeOnlyTitle: 'Velg tid',494 timeText: 'Tid',495 hourText: 'Time',496 minuteText: 'Minutt',497 secondText: 'Sekund',498 millisecText: 'Millisekund',499 microsecText: 'mikrosekund',500 timezoneText: 'Tidssone',501 currentText: 'NÃ¥',502 closeText: 'Lukk',503 timeFormat: 'HH:mm',504 amNames: ['am', 'AM', 'A'],505 pmNames: ['pm', 'PM', 'P'],506 isRTL: false507 };508 $.timepicker.setDefaults($.timepicker.regional['no']);509})(jQuery);510/* Polish translation for the jQuery Timepicker Addon */511/* Written by MichaÅ Pena */512(function($) {513 $.timepicker.regional['pl'] = {514 timeOnlyTitle: 'Wybierz godzinÄ',515 timeText: 'Czas',516 hourText: 'Godzina',517 minuteText: 'Minuta',518 secondText: 'Sekunda',519 millisecText: 'Milisekunda',520 microsecText: 'Mikrosekunda',521 timezoneText: 'Strefa czasowa',522 currentText: 'Teraz',523 closeText: 'Gotowe',524 timeFormat: 'HH:mm',525 amNames: ['AM', 'A'],526 pmNames: ['PM', 'P'],527 isRTL: false528 };529 $.timepicker.setDefaults($.timepicker.regional['pl']);530})(jQuery);531/* Brazilian Portuguese translation for the jQuery Timepicker Addon */532/* Written by Diogo Damiani (diogodamiani@gmail.com) */533(function ($) {534 $.timepicker.regional['pt-BR'] = {535 timeOnlyTitle: 'Escolha o horário',536 timeText: 'Horário',537 hourText: 'Hora',538 minuteText: 'Minutos',539 secondText: 'Segundos',540 millisecText: 'Milissegundos',541 microsecText: 'Microssegundos',542 timezoneText: 'Fuso horário',543 currentText: 'Agora',544 closeText: 'Fechar',545 timeFormat: 'HH:mm',546 amNames: ['a.m.', 'AM', 'A'],547 pmNames: ['p.m.', 'PM', 'P'],548 isRTL: false549 };550 $.timepicker.setDefaults($.timepicker.regional['pt-BR']);551})(jQuery);552/* Portuguese translation for the jQuery Timepicker Addon */553/* Written by Luan Almeida */554(function($) {555 $.timepicker.regional['pt'] = {556 timeOnlyTitle: 'Escolha uma hora',557 timeText: 'Hora',558 hourText: 'Horas',559 minuteText: 'Minutos',560 secondText: 'Segundos',561 millisecText: 'Milissegundos',562 microsecText: 'Microssegundos',563 timezoneText: 'Fuso horário',564 currentText: 'Agora',565 closeText: 'Fechar',566 timeFormat: 'HH:mm',567 amNames: ['a.m.', 'AM', 'A'],568 pmNames: ['p.m.', 'PM', 'P'],569 isRTL: false570 };571 $.timepicker.setDefaults($.timepicker.regional['pt']);572})(jQuery);573/* Romanian translation for the jQuery Timepicker Addon */574/* Written by Romeo Adrian Cioaba */575(function($) {576 $.timepicker.regional['ro'] = {577 timeOnlyTitle: 'AlegeÅ£i o orÄ',578 timeText: 'Timp',579 hourText: 'Ore',580 minuteText: 'Minute',581 secondText: 'Secunde',582 millisecText: 'Milisecunde',583 microsecText: 'Microsecunde',584 timezoneText: 'Fus orar',585 currentText: 'Acum',586 closeText: 'Ãnchide',587 timeFormat: 'HH:mm',588 amNames: ['AM', 'A'],589 pmNames: ['PM', 'P'],590 isRTL: false591 };592 $.timepicker.setDefaults($.timepicker.regional['ro']);593})(jQuery);594/* Russian translation for the jQuery Timepicker Addon */595/* Written by Trent Richardson */596(function($) {597 $.timepicker.regional['ru'] = {598 timeOnlyTitle: 'ÐÑбеÑиÑе вÑемÑ',599 timeText: 'ÐÑемÑ',600 hourText: 'ЧаÑÑ',601 minuteText: 'ÐинÑÑÑ',602 secondText: 'СекÑндÑ',603 millisecText: 'ÐиллиÑекÑндÑ',604 microsecText: 'ÐикÑоÑекÑндÑ',605 timezoneText: 'ЧаÑовой поÑÑ',606 currentText: 'СейÑаÑ',607 closeText: 'ÐакÑÑÑÑ',608 timeFormat: 'HH:mm',609 amNames: ['AM', 'A'],610 pmNames: ['PM', 'P'],611 isRTL: false612 };613 $.timepicker.setDefaults($.timepicker.regional['ru']);614})(jQuery);615/* Slovak translation for the jQuery Timepicker Addon */616/* Written by David Vallner */617(function($) {618 $.timepicker.regional['sk'] = {619 timeOnlyTitle: 'Zvoľte Äas',620 timeText: 'Äas',621 hourText: 'Hodiny',622 minuteText: 'Minúty',623 secondText: 'Sekundy',624 millisecText: 'Milisekundy',625 microsecText: 'Mikrosekundy',626 timezoneText: 'Äasové pásmo',627 currentText: 'Teraz',628 closeText: 'ZavrieÅ¥',629 timeFormat: 'H:m',630 amNames: ['dop.', 'AM', 'A'],631 pmNames: ['pop.', 'PM', 'P'],632 isRTL: false633 };634 $.timepicker.setDefaults($.timepicker.regional['sk']);635})(jQuery);636/* Serbian cyrilic translation for the jQuery Timepicker Addon */637/* Written by Vladimir Jelovac */638(function($) {639 $.timepicker.regional['sr-RS'] = {640 timeOnlyTitle: 'ÐдабеÑиÑе вÑеме',641 timeText: 'ÐÑеме',642 hourText: 'СаÑи',643 minuteText: 'ÐинÑÑи',644 secondText: 'СекÑнде',645 millisecText: 'ÐилиÑекÑнде',646 microsecText: 'ÐикÑоÑекÑнде',647 timezoneText: 'ÐÑеменÑка зона',648 currentText: 'Сада',649 closeText: 'ÐаÑвоÑи',650 timeFormat: 'HH:mm',651 amNames: ['AM', 'A'],652 pmNames: ['PM', 'P'],653 isRTL: false654 };655 $.timepicker.setDefaults($.timepicker.regional['sr-RS']);656})(jQuery);657/* Serbian latin translation for the jQuery Timepicker Addon */658/* Written by Vladimir Jelovac */659(function($) {660 $.timepicker.regional['sr-YU'] = {661 timeOnlyTitle: 'Odaberite vreme',662 timeText: 'Vreme',663 hourText: 'Sati',664 minuteText: 'Minuti',665 secondText: 'Sekunde',666 millisecText: 'Milisekunde',667 microsecText: 'Mikrosekunde',668 timezoneText: 'Vremenska zona',669 currentText: 'Sada',670 closeText: 'Zatvori',671 timeFormat: 'HH:mm',672 amNames: ['AM', 'A'],673 pmNames: ['PM', 'P'],674 isRTL: false675 };676 $.timepicker.setDefaults($.timepicker.regional['sr-YU']);677})(jQuery);678/* Swedish translation for the jQuery Timepicker Addon */679/* Written by Nevon */680(function($) {681 $.timepicker.regional['sv'] = {682 timeOnlyTitle: 'Välj en tid',683 timeText: 'Tid',684 hourText: 'Timme',685 minuteText: 'Minut',686 secondText: 'Sekund',687 millisecText: 'Millisekund',688 microsecText: 'Mikrosekund',689 timezoneText: 'Tidszon',690 currentText: 'Nu',691 closeText: 'Stäng',692 timeFormat: 'HH:mm',693 amNames: ['AM', 'A'],694 pmNames: ['PM', 'P'],695 isRTL: false696 };697 $.timepicker.setDefaults($.timepicker.regional['sv']);698})(jQuery);699/* Thai translation for the jQuery Timepicker Addon */700/* Written by Yote Wachirapornpongsa */701(function($) {702 $.timepicker.regional['th'] = {703 timeOnlyTitle: 'à¹à¸¥à¸·à¸à¸à¹à¸§à¸¥à¸²',704 timeText: 'à¹à¸§à¸¥à¸² ',705 hourText: 'à¸à¸±à¹à¸§à¹à¸¡à¸ ',706 minuteText: 'à¸à¸²à¸à¸µ',707 secondText: 'วิà¸à¸²à¸à¸µ',708 millisecText: 'มิลลิวิà¸à¸²à¸à¸µ',709 microsecText: 'à¹à¸¡à¹à¸à¸£à¸´à¸§à¸´à¸à¸²à¸à¸µ',710 timezoneText: 'à¹à¸à¸à¹à¸§à¸¥à¸²',711 currentText: 'à¹à¸§à¸¥à¸²à¸à¸±à¸à¸à¸¸à¸à¸±à¸',712 closeText: 'à¸à¸´à¸',713 timeFormat: 'hh:mm tt'714 };715 $.timepicker.setDefaults($.timepicker.regional['th']);716})(jQuery);717/* Turkish translation for the jQuery Timepicker Addon */718/* Written by Fehmi Can Saglam, Edited by Goktug Ozturk */719(function($) {720 $.timepicker.regional['tr'] = {721 timeOnlyTitle: 'Zaman Seçiniz',722 timeText: 'Zaman',723 hourText: 'Saat',724 minuteText: 'Dakika',725 secondText: 'Saniye',726 millisecText: 'Milisaniye',727 microsecText: 'Mikrosaniye',728 timezoneText: 'Zaman Dilimi',729 currentText: 'Åu an',730 closeText: 'Tamam',731 timeFormat: 'HH:mm',732 amNames: ['ÃÃ', 'Ã'],733 pmNames: ['ÃS', 'S'],734 isRTL: false735 };736 $.timepicker.setDefaults($.timepicker.regional['tr']);737})(jQuery);738/* Ukrainian translation for the jQuery Timepicker Addon */739/* Written by Sergey Noskov */740(function($) {741 $.timepicker.regional['uk'] = {742 timeOnlyTitle: 'ÐибеÑÑÑÑ ÑаÑ',743 timeText: 'ЧаÑ',744 hourText: 'Ðодини',745 minuteText: 'Хвилини',746 secondText: 'СекÑнди',747 millisecText: 'ÐÑлÑÑекÑнди',748 microsecText: 'ÐÑкÑоÑекÑнди',749 timezoneText: 'ЧаÑовий поÑÑ',750 currentText: 'ÐаÑаз',751 closeText: 'ÐакÑиÑи',752 timeFormat: 'HH:mm',753 amNames: ['AM', 'A'],754 pmNames: ['PM', 'P'],755 isRTL: false756 };757 $.timepicker.setDefaults($.timepicker.regional['uk']);758})(jQuery);759/* Vietnamese translation for the jQuery Timepicker Addon */760/* Written by Nguyen Dinh Trung */761(function($) {762 $.timepicker.regional['vi'] = {763 timeOnlyTitle: 'Chá»n giá»',764 timeText: 'Thá»i gian',765 hourText: 'Giá»',766 minuteText: 'Phút',767 secondText: 'Giây',768 millisecText: 'Mili giây',769 microsecText: 'Micrô giây',770 timezoneText: 'Múi giá»',771 currentText: 'Hiá»n thá»i',772 closeText: 'Äóng',773 timeFormat: 'HH:mm',774 amNames: ['SA', 'S'],775 pmNames: ['CH', 'C'],776 isRTL: false777 };778 $.timepicker.setDefaults($.timepicker.regional['vi']);779})(jQuery);780/* Simplified Chinese translation for the jQuery Timepicker Addon /781/ Written by Will Lu */782(function($) {783 $.timepicker.regional['zh-CN'] = {784 timeOnlyTitle: 'éæ©æ¶é´',785 timeText: 'æ¶é´',786 hourText: 'å°æ¶',787 minuteText: 'åé',788 secondText: 'ç§é',789 millisecText: '毫ç§',790 microsecText: 'å¾®ç§',791 timezoneText: 'æ¶åº',792 currentText: 'ç°å¨æ¶é´',793 closeText: 'å
³é',794 timeFormat: 'HH:mm',795 amNames: ['AM', 'A'],796 pmNames: ['PM', 'P'],797 isRTL: false798 };799 $.timepicker.setDefaults($.timepicker.regional['zh-CN']);800})(jQuery);801/* Chinese translation for the jQuery Timepicker Addon */802/* Written by Alang.lin */803(function($) {804 $.timepicker.regional['zh-TW'] = {805 timeOnlyTitle: 'é¸ææåç§',806 timeText: 'æé',807 hourText: 'æ',808 minuteText: 'å',809 secondText: 'ç§',810 millisecText: '毫ç§',811 microsecText: 'å¾®ç§',812 timezoneText: 'æå',813 currentText: 'ç¾å¨æé',814 closeText: '確å®',815 timeFormat: 'HH:mm',816 amNames: ['ä¸å', 'AM', 'A'],817 pmNames: ['ä¸å', 'PM', 'P'],818 isRTL: false819 };820 $.timepicker.setDefaults($.timepicker.regional['zh-TW']);821})(jQuery);...
test_textutil.py
Source:test_textutil.py
...78 return text79# def raise_exception(exception_class, *args):80# raise exception_class(*args)81#82# def catch_raised_exception_and_return_as_text(exception_class, *args, **kwargs):83# encoding = kwargs.pop("encoding", None)84# try:85# raise_exception(*args)86# except Exception as e:87# return text(e, encoding=encoding)88# -----------------------------------------------------------------------------89# TEST SUITE90# -----------------------------------------------------------------------------91xfail = pytest.mark.xfail92requires_python2 = pytest.mark.skipif(not six.PY2, reason="requires python2")93UNICODE_TEXT_VALUES1 = [u"Alice", u"Bob"]94UNICODE_TEXT_VALUES = [u"Café", u"100⬠(Euro)", u"Frühaufsteher"]95BYTES_TEXT_TUPLES_WITH_UTF8_ENCODING = [96 (codecs.encode(_text, "utf-8"), _text) for _text in UNICODE_TEXT_VALUES97]98class TestTextConversion(object):99 """Unit tests for the :func:`behave.textutil.text()` function."""100 @pytest.mark.parametrize("value", UNICODE_TEXT_VALUES)101 def test_text__with_unicode_value(self, value):102 value_id = id(value)103 actual_text = text(value)104 assert actual_text == value105 assert id(actual_text) == value_id # PARANOID check w/ unicode copy.106 @pytest.mark.parametrize("bytes_value, expected_text",107 BYTES_TEXT_TUPLES_WITH_UTF8_ENCODING)108 def test_text__with_bytes_value(self, bytes_value, expected_text):109 actual_text = text(bytes_value)110 assert actual_text == expected_text111 @pytest.mark.parametrize("text_value, encoding", [112 (u"Ãrgernis", "UTF-8"),113 (u"Ãbermut", "UTF-8"),114 ])115 def test_text__with_bytes_value_and_encoding(self, text_value, encoding):116 bytes_value = text_value.encode(encoding)117 assert isinstance(bytes_value, bytes)118 actual = text(bytes_value, encoding)119 assert isinstance(actual, six.text_type)120 assert actual == text_value121 def test_text__with_exception_traceback(self): pass122 @pytest.mark.parametrize("text_value", UNICODE_TEXT_VALUES)123 def test_text__with_object_convertable_to_unicode(self, text_value):124 obj = ConvertableToUnicode(text_value)125 actual_text = text(obj)126 assert actual_text == text_value127 assert isinstance(actual_text, six.text_type)128 # @pytest.mark.parametrize("expected, text_value, encoding", [129 # (u"Ãrgernis", u"Ãrgernis".encode("UTF-8"), "UTF-8"),130 # (u"Ãbermut", u"Ãbermut".encode("latin-1"), "latin-1"),131 # ])132 # def test_text__with_object_convertable_to_unicode2(self, expected,133 # text_value, encoding):134 # obj = ConvertableToUnicode(text_value, encoding)135 # actual_text = text(obj)136 # assert actual_text == expected137 # assert isinstance(actual_text, six.text_type)138 @pytest.mark.parametrize("text_value", UNICODE_TEXT_VALUES)139 def test_text__with_object_convertable_to_string(self, text_value):140 obj = ConvertableToString(text_value)141 actual_text = text(obj)142 assert actual_text == text_value143 assert isinstance(actual_text, six.text_type)144 @xfail145 @requires_python2146 @pytest.mark.parametrize("text_value", UNICODE_TEXT_VALUES)147 def test_text__with_object_convertable_to_py2string_only(self, text_value):148 class ConvertableToPy2String(object):149 """Lacks feature: convertable-to-unicode (only: to-string)"""150 def __init__(self, message=""):151 self.message = message or ""152 if self.message and isinstance(self.message, six.text_type):153 self.message = self.message.encode("UTF-8")154 def __str__(self):155 # assert isinstance(self.message, str)156 return self.message157 obj = ConvertableToPy2String(text_value.encode("UTF-8"))158 actual = text(obj)159 print(u"actual: %s" % actual)160 print(u"text_value: %s" % text_value)161 assert actual == text_value162class TestObjectToTextConversion(object):163 """Unit tests for the :func:`behave.textutil.text()` function.164 Explore case with object-to-text conversion.165 """166 ENCODING = "UTF-8"167 # -- CASE: object=exception168 @pytest.mark.parametrize("message", [169 u"Ãrgernis", u"Ãbermütig"170 ])171 def test_text__with_assert_failed_and_unicode_message(self, message):172 with pytest.raises(AssertionError) as e:173 assert False, message174 text2 = text(e)175 expected = u"AssertionError: %s" % message176 assert text2.endswith(expected)177 @requires_python2178 @pytest.mark.parametrize("message", [179 u"Ãrgernis", u"Ãbermütig"180 ])181 def test_text__with_assert_failed_and_bytes_message(self, message):182 # -- ONLY PYTHON2: Use case makes no sense for Python 3.183 bytes_message = message.encode(self.ENCODING)184 with pytest.raises(AssertionError) as e:185 assert False, bytes_message186 text2 = text(e)187 expected = u"AssertionError: %s" % message188 assert text2.endswith(expected)189 @pytest.mark.parametrize("exception_class, message", [190 (AssertionError, u"Ãrgernis"),191 (RuntimeError, u"Ãbermütig"),192 ])193 def test_text__with_raised_exception_and_unicode_message(self,194 exception_class,195 message):196 with pytest.raises(exception_class) as e:197 raise exception_class(message)198 text2 = text(e)199 expected = u"%s: %s" % (exception_class.__name__, message)200 assert isinstance(text2, six.text_type)201 assert text2.endswith(expected)202 @requires_python2203 @pytest.mark.parametrize("exception_class, message", [204 (AssertionError, u"Ãrgernis"),205 (RuntimeError, u"Ãbermütig"),206 ])207 def test_text__with_raised_exception_and_bytes_message(self, exception_class,208 message):209 # -- ONLY PYTHON2: Use case makes no sense for Python 3.210 bytes_message = message.encode(self.ENCODING)211 with pytest.raises(exception_class) as e:212 raise exception_class(bytes_message)213 text2 = text(e)214 unicode_message = bytes_message.decode(self.ENCODING)215 expected = u"%s: %s" % (exception_class.__name__, unicode_message)216 assert isinstance(text2, six.text_type)217 assert text2.endswith(expected)218 # -- DIAGNOSTICS:219 print(u"text2: "+ text2)...
space_text.py
Source:space_text.py
...121 ).type = 'FILE_TOP'122 layout.operator("text.move",123 text="Bottom of File",124 ).type = 'FILE_BOTTOM'125class TEXT_MT_text(Menu):126 bl_label = "Text"127 def draw(self, context):128 layout = self.layout129 st = context.space_data130 text = st.text131 layout.operator("text.new")132 layout.operator("text.open")133 if text:134 layout.operator("text.reload")135 layout.column()136 layout.operator("text.save")137 layout.operator("text.save_as")138 if text.filepath:139 layout.operator("text.make_internal")...
Writer.py
Source:Writer.py
...4 self.stream = stream5 self.text_styles = ["normal", "italic", "bold"]6 def get_stream(self):7 return self.stream8 def get_stylized_text(self, text, text_style):9 string = ""10 # text needs to be stripped of white space to make the new formatting take effect ("_ text" -> "_text")11 text_stripped = text.strip()12 if text_style != self.text_styles[0]:13 if text_style == self.text_styles[1]:14 string += "_" + text_stripped + "_"15 elif text_style == self.text_styles[2]:16 string += "__" + text_stripped + "__"17 else:18 raise ValueError(19 "text style is not available, possible values are: "20 + ", ".join(self.text_styles)21 )22 else:23 string = text24 return string25 def transform_special_characters(self, text):26 string = text27 string = string.replace("*", "\*")28 string = string.replace("`", "\`")29 string = string.replace("_", "\_")30 string = string.replace("{", "\{")31 string = string.replace("}", "\}")32 string = string.replace("[", "\[")33 string = string.replace("]", "\]")34 string = string.replace("(", "\(")35 string = string.replace(")", "\)")36 string = string.replace("#", "\#")37 string = string.replace("+", "\+")38 string = string.replace("-", "\-")39 string = string.replace("!", "\!")40 string = string.replace("&", "&")41 string = string.replace("<", "<")42 return string43 def add_colored_text(self, text, text_color):44 string = ""45 text_stripped = text.strip()46 text_color = text_color.lower()47 string += f'<span style="color:{text_color}">{text_stripped}</span>'48 string += " "49 self.stream += string50 def add_font_changes(self, text, text_font, text_size):51 # <span style="font-family:Papyrus; font-size:4em;">LOVE!</span>52 string = ""53 text_stripped = text.strip()54 if text_font == "" and text_size == "":55 string += " "56 elif text_font == "":57 string += f'<span style="font-size:{text_size}">{text_stripped}</span>'58 elif text_size == "":59 string += f'<span style="font-family:{text_font}">{text_stripped}</span>'60 else:61 string += f'<span style="font-family:{text_font};font-size:{text_size}">{text_stripped}</span>'62 string += " "63 self.stream += string64 def add_superscript(self, text):65 # E=MC<sup>2</sup>66 string = ""67 text_stripped = text.strip()68 string += f"<sup>{text_stripped}</sup>"69 string += " "70 self.stream += string71 def add_subscript(self, text):72 # Plants need CO<sub>2</sub>73 string = ""74 text_stripped = text.strip()75 string += f"<sub>{text_stripped}</sub>"76 string += " "77 self.stream += string78 def add_space(self):79 self.stream += " "80 def add_simple_line_break(self):81 self.stream += " \n"82 def add_double_line_break(self):83 self.stream += "\n \n"84 def add_tabulation(self, tab_num):85 self.stream += ">" * tab_num86 def add_horizontal_rule(self):87 self.add_double_line_break()88 self.stream += "-----"89 self.add_double_line_break()90 def add_header(self, text, level=1):91 if level < 1 or level > 6:92 raise ValueError("header level must be included in [1,6]")93 self.stream += "#" * level + " "94 self.stream += text + "\n"95 def add_paragraph(self, text, tabulation=0, text_style="normal"):96 if tabulation < 0:97 raise ValueError("tabulation number must be positive")98 self.stream += ">" * tabulation99 self.stream += self.get_stylized_text(100 self.transform_special_characters(text), text_style101 )102 self.add_double_line_break()103 def add_text(self, text, text_style="normal"):104 self.stream += self.get_stylized_text(105 self.transform_special_characters(text), text_style106 )107 def add_list(self, text, num_style_list=False, tabulation=0, text_style="normal"):108 if type(text) is not list:109 raise ValueError("request a list of string")110 if tabulation < 0:111 raise ValueError("tabulation number must be positive")112 for i in range(0, len(text)):113 if num_style_list is False:114 self.stream += ">" * tabulation115 self.stream += "+ "116 self.stream += self.get_stylized_text(text[i], text_style)117 self.add_simple_line_break()118 else:119 self.stream += ">" * tabulation120 self.stream += str(i + 1) + ". "121 self.stream += self.get_stylized_text(text[i], text_style)122 self.add_simple_line_break()123 def add_code_block(self, code_text):124 code_lines = code_text.split("\n")125 self.add_simple_line_break()126 for line in code_lines:127 self.stream += "\t"128 self.stream += line129 self.add_simple_line_break()130 def add_code_word(self, code_word):131 self.stream += "`"132 self.stream += code_word133 self.stream += "`"134 def add_link(self, link_url, link_text, link_title=""):135 self.stream += "[" + link_text + "]"...
menudata.js
Source:menudata.js
1var menudata={children:[2{text:"Main Page",url:"index.html"},3{text:"Related Pages",url:"pages.html"},4{text:"Modules",url:"modules.html"},5{text:"Classes",url:"annotated.html",children:[6{text:"Class List",url:"annotated.html"},7{text:"Class Index",url:"classes.html"},8{text:"Class Hierarchy",url:"hierarchy.html"},9{text:"Class Members",url:"functions.html",children:[10{text:"All",url:"functions.html",children:[11{text:"a",url:"functions.html#index_a"},12{text:"b",url:"functions_b.html#index_b"},13{text:"c",url:"functions_c.html#index_c"},14{text:"d",url:"functions_d.html#index_d"},15{text:"e",url:"functions_e.html#index_e"},16{text:"f",url:"functions_f.html#index_f"},17{text:"g",url:"functions_g.html#index_g"},18{text:"h",url:"functions_h.html#index_h"},19{text:"i",url:"functions_i.html#index_i"},20{text:"l",url:"functions_l.html#index_l"},21{text:"m",url:"functions_m.html#index_m"},22{text:"n",url:"functions_n.html#index_n"},23{text:"o",url:"functions_o.html#index_o"},24{text:"p",url:"functions_p.html#index_p"},25{text:"r",url:"functions_r.html#index_r"},26{text:"s",url:"functions_s.html#index_s"},27{text:"t",url:"functions_t.html#index_t"},28{text:"w",url:"functions_w.html#index_w"},29{text:"x",url:"functions_x.html#index_x"},30{text:"y",url:"functions_y.html#index_y"}]},31{text:"Functions",url:"functions_func.html",children:[32{text:"a",url:"functions_func.html#index_a"},33{text:"b",url:"functions_func_b.html#index_b"},34{text:"c",url:"functions_func_c.html#index_c"},35{text:"d",url:"functions_func_d.html#index_d"},36{text:"e",url:"functions_func_e.html#index_e"},37{text:"f",url:"functions_func_f.html#index_f"},38{text:"g",url:"functions_func_g.html#index_g"},39{text:"h",url:"functions_func_h.html#index_h"},40{text:"i",url:"functions_func_i.html#index_i"},41{text:"l",url:"functions_func_l.html#index_l"},42{text:"m",url:"functions_func_m.html#index_m"},43{text:"n",url:"functions_func_n.html#index_n"},44{text:"o",url:"functions_func_o.html#index_o"},45{text:"p",url:"functions_func_p.html#index_p"},46{text:"r",url:"functions_func_r.html#index_r"},47{text:"s",url:"functions_func_s.html#index_s"},48{text:"t",url:"functions_func_t.html#index_t"},49{text:"w",url:"functions_func_w.html#index_w"},50{text:"x",url:"functions_func_x.html#index_x"},51{text:"y",url:"functions_func_y.html#index_y"}]},52{text:"Variables",url:"functions_vars.html",children:[53{text:"a",url:"functions_vars.html#index_a"},54{text:"b",url:"functions_vars.html#index_b"},55{text:"c",url:"functions_vars.html#index_c"},56{text:"d",url:"functions_vars.html#index_d"},57{text:"g",url:"functions_vars.html#index_g"},58{text:"h",url:"functions_vars.html#index_h"},59{text:"i",url:"functions_vars.html#index_i"},60{text:"l",url:"functions_vars.html#index_l"},61{text:"m",url:"functions_vars.html#index_m"},62{text:"n",url:"functions_vars.html#index_n"},63{text:"o",url:"functions_vars.html#index_o"},64{text:"p",url:"functions_vars.html#index_p"},65{text:"r",url:"functions_vars.html#index_r"},66{text:"s",url:"functions_vars.html#index_s"},67{text:"t",url:"functions_vars.html#index_t"},68{text:"w",url:"functions_vars.html#index_w"},69{text:"x",url:"functions_vars.html#index_x"},70{text:"y",url:"functions_vars.html#index_y"}]}]}]},71{text:"Files",url:"files.html",children:[72{text:"File List",url:"files.html"},73{text:"File Members",url:"globals.html",children:[74{text:"All",url:"globals.html",children:[75{text:"a",url:"globals.html#index_a"},76{text:"b",url:"globals_b.html#index_b"},77{text:"c",url:"globals_c.html#index_c"},78{text:"d",url:"globals_d.html#index_d"},79{text:"e",url:"globals_e.html#index_e"},80{text:"f",url:"globals_f.html#index_f"},81{text:"g",url:"globals_g.html#index_g"},82{text:"i",url:"globals_i.html#index_i"},83{text:"l",url:"globals_l.html#index_l"},84{text:"m",url:"globals_m.html#index_m"},85{text:"n",url:"globals_n.html#index_n"},86{text:"p",url:"globals_p.html#index_p"},87{text:"r",url:"globals_r.html#index_r"},88{text:"s",url:"globals_s.html#index_s"},89{text:"t",url:"globals_t.html#index_t"},90{text:"u",url:"globals_u.html#index_u"},91{text:"v",url:"globals_v.html#index_v"},92{text:"w",url:"globals_w.html#index_w"}]},93{text:"Functions",url:"globals_func.html",children:[94{text:"g",url:"globals_func.html#index_g"},95{text:"i",url:"globals_func.html#index_i"},96{text:"p",url:"globals_func.html#index_p"},97{text:"s",url:"globals_func.html#index_s"},98{text:"t",url:"globals_func.html#index_t"},99{text:"u",url:"globals_func.html#index_u"},100{text:"v",url:"globals_func.html#index_v"}]},101{text:"Variables",url:"globals_vars.html"},102{text:"Typedefs",url:"globals_type.html"},103{text:"Enumerations",url:"globals_enum.html"},104{text:"Enumerator",url:"globals_eval.html"},105{text:"Macros",url:"globals_defs.html",children:[106{text:"a",url:"globals_defs.html#index_a"},107{text:"c",url:"globals_defs.html#index_c"},108{text:"g",url:"globals_defs.html#index_g"},109{text:"l",url:"globals_defs.html#index_l"},110{text:"m",url:"globals_defs.html#index_m"},111{text:"n",url:"globals_defs.html#index_n"},112{text:"r",url:"globals_defs.html#index_r"},113{text:"s",url:"globals_defs.html#index_s"},114{text:"t",url:"globals_defs.html#index_t"},...
cleanhtml.py
Source:cleanhtml.py
1import sys2import re345def cleancss(text):6 text = re.compile('\s+').sub(' ', text)7 text = re.compile('\s*(?P<a>,|:)\s*').sub('\g<a> ', text)8 text = re.compile('\s*;\s*').sub(';\n ', text)9 text = re.compile('\s*\{\s*').sub(' {\n ', text)10 text = re.compile('\s*\}\s*').sub('\n}\n\n', text)11 return text121314def cleanhtml(text):15 text = text.lower()16 r = re.compile('\<script.+?/script\>', re.DOTALL)17 scripts = r.findall(text)18 text = r.sub('<script />', text)19 r = re.compile('\<style.+?/style\>', re.DOTALL)20 styles = r.findall(text)21 text = r.sub('<style />', text)22 text = re.compile(23 '<(?P<tag>(input|meta|link|hr|br|img|param))(?P<any>[^\>]*)\s*(?<!/)>')\24 .sub('<\g<tag>\g<any> />', text)25 text = text.replace('\n', ' ')26 text = text.replace('>', '>\n')27 text = text.replace('<', '\n<')28 text = re.compile('\s*\n\s*').sub('\n', text)29 lines = text.split('\n')30 (indent, newlines) = (0, [])31 for line in lines:32 if line[:2] == '</': indent = indent - 133 newlines.append(indent * ' ' + line)34 if not line[:2] == '</' and line[-1:] == '>' and \35 not line[-2:] in ['/>', '->']: indent = indent + 136 text = '\n'.join(newlines)37 text = re.compile(38 '\<div(?P<a>( .+)?)\>\s+\</div\>').sub('<div\g<a>></div>', text)39 text = re.compile('\<a(?P<a>( .+)?)\>\s+(?P<b>[\w\s\(\)\/]+?)\s+\</a\>').sub('<a\g<a>>\g<b></a>', text)40 text = re.compile('\<b(?P<a>( .+)?)\>\s+(?P<b>[\w\s\(\)\/]+?)\s+\</b\>').sub('<b\g<a>>\g<b></b>', text)41 text = re.compile('\<i(?P<a>( .+)?)\>\s+(?P<b>[\w\s\(\)\/]+?)\s+\</i\>').sub('<i\g<a>>\g<b></i>', text)42 text = re.compile('\<span(?P<a>( .+)?)\>\s+(?P<b>[\w\s\(\)\/]+?)\s+\</span\>').sub('<span\g<a>>\g<b></span>', text)43 text = re.compile('\s+\<br(?P<a>.*?)\/\>').sub('<br\g<a>/>', text)44 text = re.compile('\>(?P<a>\s+)(?P<b>[\.\,\:\;])').sub('>\g<b>\g<a>', text)45 text = re.compile('\n\s*\n').sub('\n', text)46 for script in scripts:47 text = text.replace('<script />', script, 1)48 for style in styles:49 text = text.replace('<style />', cleancss(style), 1)50 return text515253def read_file(filename):54 f = open(filename, 'r')55 try:56 return f.read()57 finally:58 f.close()5960file = sys.argv[1]61if file[-4:] == '.css':62 print cleancss(read_file(file))63if file[-5:] == '.html':
...
Using AI Code Generation
1const { text } = require('taiko');2const { openBrowser, goto, closeBrowser } = require('taiko');3(async () => {4 try {5 await openBrowser();6 await goto("google.com");7 await text("I'm Feeling Lucky").exists();8 } catch (e) {9 console.error(e);10 } finally {11 await closeBrowser();12 }13})();14const { textContains } = require('taiko');15const { openBrowser, goto, closeBrowser } = require('taiko');16(async () => {17 try {18 await openBrowser();19 await goto("google.com");20 await textContains("I'm Feeling Lucky").exists();21 } catch (e) {22 console.error(e);23 } finally {24 await closeBrowser();25 }26})();27const { textContains } = require('taiko');28const { openBrowser, goto, closeBrowser } = require('taiko');29(async () => {30 try {31 await openBrowser();32 await goto("google.com");33 await textContains("I'm Feeling Lucky").exists();34 console.log("Text is available");35 } catch (e) {36 console.error(e);37 console.log("Text is not available");38 } finally {39 await closeBrowser();40 }41})();42const { textContains } = require('taiko');43const {
Using AI Code Generation
1const { text, openBrowser, goto, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await text("Gmail").exists();6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12You can also use the text() method to get the text of an element:13const { text, openBrowser, goto, closeBrowser } = require('taiko');14(async () => {15 try {16 await openBrowser();17 let text = await text("Gmail").text();18 console.log(text);19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25The text() method can also be used to get the text of a particular element using the below syntax:26text("Gmail", { element: "a" })27The text() method can also be used to get the text of a particular element using the below syntax:28text("Gmail", { element: "a" })29The text() method can also be used to get the text of a particular element using the below syntax:30text("Gmail", { element: "a" })31The text() method can also be used to get the text of a particular element using the below syntax:32text("Gmail", { element: "a" })33The text() method can also be used to get the text of a particular element using the below syntax:34text("Gmail", { element: "a" })35The text() method can also be used to get the text of a particular element using the below syntax:36text("G
Using AI Code Generation
1const { openBrowser, goto, textBox, toRightOf, write, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await write("Taiko",into(textBox(toRightOf("Google Search"))));7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, textBox, toRightOf, write, closeBrowser } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await goto("google.com");18 await write("Taiko",into(textBox(toRightOf("Google Search"))));19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, textBox, toRightOf, write, closeBrowser } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await goto("google.com");30 await write("Taiko",into(textBox(toRightOf("Google Search"))));31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();37const { openBrowser, goto, textBox, toRightOf, write, closeBrowser } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await goto("google.com");42 await write("Taiko",into(textBox(toRightOf("Google Search"))));43 } catch (e) {44 console.error(e);45 } finally {46 await closeBrowser();47 }48})();49const { openBrowser, goto, textBox, toRightOf, write, closeBrowser } = require('taiko');50(async () => {51 try {52 await openBrowser();53 await goto("google.com");54 await write("Taiko",into(textBox(toRightOf("Google Search"))));55 } catch (e) {56 console.error(e);57 } finally {58 await closeBrowser();59 }60})();
Using AI Code Generation
1const { openBrowser, goto, text, write, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("taiko", into(text("Search")));6 await press("Enter");7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, text, write, closeBrowser } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await write("taiko", into(text("Search")));18 await press("Enter");19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, text, write, closeBrowser } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await write("taiko", into(text("Search")));30 await press("Enter");31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();37const { openBrowser, goto, text, write, closeBrowser } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await write("taiko", into(text("Search")));42 await press("Enter");43 } catch (e) {44 console.error(e);45 } finally {46 await closeBrowser();47 }48})();49const { openBrowser, goto, text, write, closeBrowser } = require('taiko');50(async () => {51 try {52 await openBrowser();53 await write("taiko", into(text("Search")));54 await press("Enter");55 } catch (e) {56 console.error(e);57 } finally {58 await closeBrowser();59 }60})();
Using AI Code Generation
1const { text } = require('taiko');2(async () => {3 try {4 await text("Login").exists();5 console.log("Login exists");6 } catch (e) {7 console.error("Login does not exists");8 } finally {9 closeBrowser();10 }11})();12const { link } = require('taiko');13(async () => {14 try {15 await link("Login").exists();16 console.log("Login exists");17 } catch (e) {18 console.error("Login does not exists");19 } finally {20 closeBrowser();21 }22})();23const { link } = require('taiko');24(async () => {25 try {26 await link("Login").exists();27 console.log("Login exists");28 } catch (e) {29 console.error("Login does not exists");30 } finally {31 closeBrowser();32 }33})();34const { link } = require('taiko');35(async () => {36 try {37 await link("Login").exists();38 console.log("Login exists");39 } catch (e) {40 console.error("Login does not exists");41 } finally {42 closeBrowser();43 }44})();45const { link } = require('taiko');46(async () => {47 try {48 await link("Login").exists();49 console.log("Login exists");50 } catch (e) {51 console.error("Login does not exists");52 } finally {53 closeBrowser();54 }55})();56const { link } = require('taiko');57(async () => {58 try {59 await link("Login").exists();60 console.log("Login exists");61 } catch (e) {62 console.error("Login does not exists");63 } finally {64 closeBrowser();65 }66})();67const { link } = require('taiko');68(async () => {69 try {70 await link("Login").exists();71 console.log("Login exists");72 } catch (e) {73 console.error("Login does not exists");74 } finally {75 closeBrowser();76 }77})();78const { link } = require('taiko');79(async () => {
Using AI Code Generation
1const { text } = require('taiko');2(async () => {3 await text('a').exists();4 await text('a').exists(2);5 await text('a').exists(3);6 await text('a').exists(4);7 await text('a').exists(5);8 await text('a').exists(6);9 await text('a').exists(7);10 await text('a').exists(8);11 await text('a').exists(9);12 await text('a').exists(10);13 await text('a').exists(11);14 await text('a').exists(12);15 await text('a').exists(13);16 await text('a').exists(14);17 await text('a').exists(15);18 await text('a').exists(16);19 await text('a').exists(17);20 await text('a').exists(18);21 await text('a').exists(19);22 await text('a').exists(20);23 await text('a').exists(21);24 await text('a').exists(22);25 await text('a').exists(23);26 await text('a').exists(24);27 await text('a').exists(25);28 await text('a').exists(26);29 await text('a').exists(27);30 await text('a').exists(28);31 await text('a').exists(29);32 await text('a').exists(30);33 await text('a').exists(31);34 await text('a').exists(32);35 await text('a').exists(33);36 await text('a').exists(34);37 await text('a').exists(35);38 await text('a').exists(36);39 await text('a').exists(37);40 await text('a').exists(38);41 await text('a').exists(39);42 await text('a').exists(40);43 await text('a').exists(41);44 await text('a').exists(42);45 await text('a').exists(43);46 await text('a').exists(44);47 await text('a').exists(45);48 await text('a').exists(46);49 await text('a').exists(47);50 await text('a').exists(48);
Using AI Code Generation
1const { openBrowser, goto, text, write } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko", into(text("Search")));6 await press("Enter");7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, text, write } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await write("Taiko", into(text("Search")));18 await press("Enter");19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, text, write } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await write("Taiko", into("Search"));30 await press("Enter");31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!