Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# create integer-to-token mapping
int2token = {}
cnt = 0
for w in set(" ".join(movie_plots).split()):
int2token[cnt] = w
cnt+= 1
# create token-to-integer mapping
token2int = {t: i for i, t in int2token.items()}
token2int["the"], int2token[14271]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment