Advertisement
Fillinlak3

Pasareasca Traducator

Jun 6th, 2020
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. #############################
  2. # Bird language translator  #
  3. #       By Fillinlak3       #
  4. #############################
  5.  
  6. # For Title
  7. import ctypes
  8.  
  9. # Set Title
  10. ctypes.windll.kernel32.SetConsoleTitleW("Pasareasca - Translator")
  11.  
  12. # Global variable
  13. vocale = "AEIOUaeiou"
  14.  
  15. # Main func
  16. def main():
  17.  
  18.     text = str(input("Text: "))
  19.     option = str(input("Option: "))
  20.     if option == "1":
  21.         text = Pasareasca_IN(text)
  22.     elif option == "2":
  23.         text = Pasareasca_OUT(text)
  24.     else:
  25.         print("Invalid option!")
  26.         exit(0)
  27.  
  28.     print(text)
  29.  
  30.  
  31. # Code in pasareasca
  32. def Pasareasca_IN(text):
  33.     alfabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  34.     text_pasareasca = str()
  35.     for x in range(0,len(text)):
  36.         text_pasareasca += text[x]
  37.         if text[x] in vocale:
  38.             text_pasareasca += "p" + text[x].lower()
  39.         elif x < (len(text)) - 1:
  40.             if text[x+1] == ' ':
  41.                 text_pasareasca += "p"
  42.            
  43.     if text[len(text)-1] not in vocale and text[len(text)-1] in alfabet:
  44.         text_pasareasca += "p"
  45.  
  46.     return text_pasareasca
  47.  
  48. # Decode in pasareasca
  49. def Pasareasca_OUT(text):
  50.     text_pasareasca = str()
  51.     for x in range(0,len(text)):
  52.         text_pasareasca += text[x]
  53.         if x < len(text)-1:
  54.             if text[x] == "p":
  55.                 if text[x+1] == ' ':
  56.                     text_pasareasca = text_pasareasca[:-1]
  57.                 elif text[x+1] in vocale:
  58.                     text_pasareasca = text_pasareasca[:-2]
  59.  
  60.     if text_pasareasca[len(text_pasareasca)-1] == "p" and text_pasareasca[len(text_pasareasca)-2] != "p":
  61.         text_pasareasca = text_pasareasca[:-1]
  62.  
  63.     return text_pasareasca
  64.  
  65.  
  66. if __name__ == '__main__':
  67.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement