Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from os import path
- from random import choice as random_choice
- from sys import argv
- NUMS_TO_UNICODE = {
- "1": "⌞",
- "2": "⊥",
- "3": "⌟",
- "4": "⊢",
- "5": "᛭",
- "6": "⊣",
- "7": "⌜",
- "8": "⊤",
- "9": "⌝"
- }
- LETTERS_TO_NUMS = {
- "A": ["179364", "1464793"],
- "B": ["56317965", "17965631"],
- "C": ["9713"],
- "D": ["178621"],
- "E": ["9745413"],
- "F": ["145479"],
- "G": ["971365"],
- "H": ["174693", "714639", "714693"],
- "I": ["98231287", "978213"],
- "J": ["79624"],
- "K": ["745953541", "9535471"],
- "L": ["713"],
- "M": ["1785893"],
- "N": ["1739"],
- "O": ["84268"],
- "P": ["17964"],
- "Q": ["6842653"],
- "R": ["179653"],
- "S": ["974631"],
- "T": ["7982", "78289"],
- "U": ["7139"],
- "V": ["74269"],
- "W": ["7125239"],
- "X": ["759153", "73519"],
- "Y": ["75952", "25759"],
- "Z": ["7913"],
- }
- def numbers_to_symbols(numbers):
- thisLetter = []
- prev = None
- for number in numbers:
- symbol = NUMS_TO_UNICODE[number]
- if prev == "⌝" and symbol == "⌜" or prev == "⌟" and symbol == "⌞":
- thisLetter.append(" ")
- thisLetter.append(symbol)
- prev = symbol
- return ("".join(thisLetter))
- def translate_text(text):
- text = text.split(" ")
- words = [word.upper() for word in text]
- allText = []
- for word in words:
- thisWord = []
- for letter in word:
- # if letter == "\n":
- # thisWord.append(letter)
- # prev = letter
- # continue
- try:
- numbers = random_choice(LETTERS_TO_NUMS[letter])
- except KeyError:
- pass
- if random_choice([0, 1]) == 1:
- numbers = numbers[::-1]
- symbol = numbers_to_symbols(numbers)
- thisWord.append(symbol)
- allText.append(".".join(thisWord))
- return "..".join(allText)
- if __name__ == "__main__":
- myPath = path.dirname(path.realpath(__file__))
- with open("%s/in.txt" % myPath, "r") as inFile:
- inText = inFile.read()
- outText = translate_text(inText)
- keyLine1 = numbers_to_symbols("789")
- keyLine2 = numbers_to_symbols("456")
- keyLine3 = numbers_to_symbols("123")
- print(outText)
- with open("out.txt", "w", encoding="utf-8") as outFile:
- outFile.write("%s\n\n" % outText)
- outFile.write("%s\n" % keyLine1)
- outFile.write("%s\n" % keyLine2)
- outFile.write("%s\n" % keyLine3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement