This code is fully explained in a post on my technical blog, Agatha.

This program is designed to be run in the command line/terminal.

You'll need the following installed to run it:

  • Python 3+ on your machine
  • The Natural Language Processing Toolkit on your computer or in a Python Virtual Environment
  • Any file in .txt format - the path will need to be added to the characters.py file where it now reads 'corpus/hp1.txt'

When you have that set up, run this file by typing python characters.py in the terminal/command line.

If you have any questions or feedback about the code, please comment on the accompanying blog post.