Optimize corpus creation.
Clean up unused variables.
Move to a Python dictionary for the word-id mappings.
Remove encoding as the dictionary should hold whatever was passed into it.