Advertisement
EXTREMEXPLOIT

temp

May 11th, 2022
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. corruptedTrain = [] # The structure is [Cypher, Text]
  2. file = open(myDrive + 'Text.txt', 'r')
  3.  
  4. for sentence in file:
  5.     sentence = sentence.replace(' ', '').replace('\n', '').upper()
  6.     if len(sentence) >= 32:
  7.         sentence = sentence[:32] # Use first 32 chars.
  8.         text = torch.tensor([vocab.index(i) for i in sentence])
  9.         cypher = (text + NUMERIC_KEY) % 26 # Perform encryption
  10.         dashNumber = random.randint(1, 4) # Number of corrupted chars.
  11.         for _ in range(dashNumber):
  12.             tryAgain = True
  13.             while tryAgain: # Avoid placing two dashes on the same position.
  14.                 i = random.randint(0, len(sentence)-1)
  15.                 if cypher[i] != 25: # If there's not dash
  16.                     cypher[i] = 25
  17.                     tryAgain = False
  18.         corruptedTrain.append([cypher, text])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement