Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.64 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from os import path
  3. from random import choice as random_choice
  4. from sys import argv
  5.  
  6. NUMS_TO_UNICODE = {
  7.     "1": "⌞",
  8.     "2": "⊥",
  9.     "3": "⌟",
  10.     "4": "⊢",
  11.     "5": "᛭",
  12.     "6": "⊣",
  13.     "7": "⌜",
  14.     "8": "⊤",
  15.     "9": "⌝"
  16. }
  17.  
  18. LETTERS_TO_NUMS = {
  19.     "A": ["179364", "1464793"],
  20.     "B": ["56317965", "17965631"],
  21.     "C": ["9713"],
  22.     "D": ["178621"],
  23.     "E": ["9745413"],
  24.     "F": ["145479"],
  25.     "G": ["971365"],
  26.     "H": ["174693", "714639", "714693"],
  27.     "I": ["98231287", "978213"],
  28.     "J": ["79624"],
  29.     "K": ["745953541", "9535471"],
  30.     "L": ["713"],
  31.     "M": ["1785893"],
  32.     "N": ["1739"],
  33.     "O": ["84268"],
  34.     "P": ["17964"],
  35.     "Q": ["6842653"],
  36.     "R": ["179653"],
  37.     "S": ["974631"],
  38.     "T": ["7982", "78289"],
  39.     "U": ["7139"],
  40.     "V": ["74269"],
  41.     "W": ["7125239"],
  42.     "X": ["759153", "73519"],
  43.     "Y": ["75952", "25759"],
  44.     "Z": ["7913"],
  45. }
  46.  
  47. def numbers_to_symbols(numbers):
  48.     thisLetter = []
  49.     prev = None
  50.     for number in numbers:
  51.         symbol = NUMS_TO_UNICODE[number]
  52.         if prev == "⌝" and symbol == "⌜" or prev == "⌟" and symbol == "⌞":
  53.                 thisLetter.append(" ")
  54.  
  55.         thisLetter.append(symbol)
  56.         prev = symbol
  57.     return ("".join(thisLetter))
  58.  
  59. def translate_text(text):
  60.     text = text.split(" ")
  61.     words = [word.upper() for word in text]
  62.  
  63.     allText = []
  64.     for word in words:
  65.         thisWord = []
  66.         for letter in word:  
  67.             # if letter == "\n":
  68.             #     thisWord.append(letter)
  69.             #     prev = letter
  70.             #     continue
  71.                      
  72.             try:
  73.                 numbers = random_choice(LETTERS_TO_NUMS[letter])
  74.             except KeyError:
  75.                 pass
  76.  
  77.             if random_choice([0, 1]) == 1:
  78.                 numbers = numbers[::-1]
  79.            
  80.             symbol = numbers_to_symbols(numbers)
  81.  
  82.            
  83.             thisWord.append(symbol)
  84.  
  85.         allText.append(".".join(thisWord))
  86.  
  87.     return "..".join(allText)
  88.  
  89. if __name__ == "__main__":
  90.     myPath = path.dirname(path.realpath(__file__))
  91.     with open("%s/in.txt" % myPath, "r") as inFile:
  92.         inText = inFile.read()
  93.  
  94.     outText = translate_text(inText)
  95.     keyLine1 = numbers_to_symbols("789")
  96.     keyLine2 = numbers_to_symbols("456")
  97.     keyLine3 = numbers_to_symbols("123")
  98.  
  99.     print(outText)
  100.  
  101.     with open("out.txt", "w", encoding="utf-8") as outFile:
  102.         outFile.write("%s\n\n" % outText)
  103.         outFile.write("%s\n" % keyLine1)
  104.         outFile.write("%s\n" % keyLine2)
  105.         outFile.write("%s\n" % keyLine3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement