Created
July 24, 2019 03:34
-
-
Save agustinustheo/cc5d1bca31ef848620ce3fbbe185efc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def convertText(text): | |
| words = word_tokenize(text) | |
| new_string = '' | |
| for msg in words: | |
| new_word = '' | |
| alpha_flag = False | |
| digit_flag = False | |
| for c in msg: | |
| if c.isalpha(): | |
| alpha_flag = True | |
| elif c.isdigit(): | |
| digit_flag = True | |
| if alpha_flag and digit_flag: | |
| msg = msg.lower() | |
| if msg[-4:] != 'ribu' and msg[-3:] != 'rbu' and msg[-2:] != 'rb': | |
| for c in msg: | |
| if c == '1': | |
| c = 'i' | |
| elif c == '2': | |
| c = 's' | |
| elif c == '3': | |
| c = 'e' | |
| elif c == '4': | |
| c = 'a' | |
| elif c == '5': | |
| c = 's' | |
| elif c == '6': | |
| c = 'g' | |
| elif c == '7': | |
| c = 't' | |
| elif c == '8': | |
| c = 'b' | |
| elif c == '9': | |
| c = 'g' | |
| elif c == '0': | |
| c = 'o' | |
| new_word = new_word + c | |
| if new_word != '': | |
| new_string = new_string + new_word + ' ' | |
| else: | |
| new_string = new_string + msg + ' ' | |
| return new_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment