Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- text = 'привет братан с пикабу'
- dictionary ={
- 0:'й',
- 1:'ц',
- 2:'у',
- 3:'к',
- 4:'е',
- 5:'н',
- 6:'г',
- 7:'ш',
- 8:'щ',
- 9:'з',
- 10:'х',
- 11:'ф',
- 12:'ы',
- 13:'в',
- 14:'а',
- 15:'п',
- 16:'р',
- 17:'о',
- 18:'л',
- 19:'д',
- 20:'ж',
- 21:'э',
- 22:'я',
- 23:'ч',
- 24:'с',
- 25:'м',
- 26:'и',
- 27:'т',
- 28:'ь',
- 29:'б',
- 30:'ю'
- }
- words = text.split()
- words = text.split()
- sequences = []
- for word in words:
- word_seq = []
- for char in word:
- n = list(dictionary.keys())[list(dictionary.values()).index(char)]
- word_seq.append(n)
- sequences.append(word_seq)
- for i in sequences:
- for j in i:
- n = np.random.uniform(0, 1)
- tmp = 0
- if (n > 0.8):
- tmp = np.random.randint(-1, 1)
- print(dictionary[j + tmp], end='')
- print(end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement