Horje
encoding int to chr in python and vice versa Code Example
encoding int to chr in python and vice versa
# encode the text and map each character to an integer and vice versa

# we create two dictionaries:
# 1. int2char, which maps integers to characters
# 2. char2int, which maps characters to unique integers
chars = tuple(set(text))
int2char = {ind:char for ind,char in enumerate(chars)}
char2int = {char:ind for ind,char in enumerate(chars)}

# encode the text
encoded = np.array([char2int[ch] for ch in text])




Python

Related
vscode python workding directory Code Example vscode python workding directory Code Example
math plotlib 2 y axes Code Example math plotlib 2 y axes Code Example
tar unpack to folder Code Example tar unpack to folder Code Example
full_like numpy Code Example full_like numpy Code Example
delete history django simple Code Example delete history django simple Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7