Yes, I Speak Computer Fluently
You’re a data scientist.
For CPSC 420, Modeling & Simulation, I was given the task of analyzing a huge amount of text, then simulating the author of that text writing some more. It involved comparing the frequency that words existed next to one another, eventually resulting in some crazy result that initially freaked me out.
I started the program from scratch; I wish I hadn’t. There currently exists quite a few libraries that are useful for analyzing text based on unigrams, bigrams, trigrams, or even n-grams. Those libraries would certainly be easier to implement than the way I did. Regardless, it was a fun experience figuring out how to make it work proper!
If you’d like to run it yourself, here’s what you do (for Unix or Mac users, sorry Windows):
- Go to https://pastebin.com/cvTXnnm8
- Click the Download button.
- In your Terminal, cd to your downloads directory.
- In your Terminal, type ‘mv cvTXnnm8.txt ngram.py’
- In your Terminal, type ‘python ngram.py’
Make sure you supply a lengthy text file (.txt) and pass it in when you run the script. Otherwise, it won’t do anything.