Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import numpy as np
  2.  
  3. text = 'привет братан с пикабу'
  4.  
  5. dictionary ={
  6.        
  7.         0:'й',
  8.         1:'ц',
  9.         2:'у',
  10.         3:'к',
  11.         4:'е',
  12.         5:'н',
  13.         6:'г',
  14.         7:'ш',
  15.         8:'щ',
  16.         9:'з',
  17.         10:'х',
  18.         11:'ф',
  19.         12:'ы',
  20.         13:'в',
  21.         14:'а',
  22.         15:'п',
  23.         16:'р',
  24.         17:'о',
  25.         18:'л',
  26.         19:'д',
  27.         20:'ж',
  28.         21:'э',
  29.         22:'я',
  30.         23:'ч',
  31.         24:'с',
  32.         25:'м',
  33.         26:'и',
  34.         27:'т',
  35.         28:'ь',
  36.         29:'б',
  37.         30:'ю'
  38.         }
  39.  
  40.    
  41. words = text.split()
  42.  
  43.  
  44. words = text.split()
  45. sequences = []
  46. for word in words:
  47.     word_seq = []
  48.     for char in word:
  49.         n = list(dictionary.keys())[list(dictionary.values()).index(char)]
  50.         word_seq.append(n)
  51.     sequences.append(word_seq)
  52.  
  53. for i in sequences:
  54.     for j in i:
  55.         n = np.random.uniform(0, 1)
  56.         tmp = 0
  57.         if (n > 0.8):
  58.             tmp = np.random.randint(-1, 1)
  59.         print(dictionary[j + tmp], end='')
  60.     print(end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement