In the Fall of 2016, a month before the election, a list of tried and rejected slogans for the Hillary
Clinton campaign were leaked via email to the press. I thought these slogans were super interesting, with
some of my favorites being "Fairness worth the fight" or "New Solutions Real Results." Naturally, twitter
had a field day and we all had a bit of fun.
I, about a year later, wanted to have an excuse to try out text generating RNNs and decided to go back to
this dataset and check it out.
So below, over the course of about an hour, I built a RNN using @minimaxir's textgenrnn for this exact
purpose. Turns out, this library is aggressively easy to use, making this a great intro to textgen RNNs.
from textgenrnn import textgenrnn
textgen = textgenrnn()
textgen.generate()
Now let's take a look at the first 5 of our list of slogans, compiled into a txt file from an NYT article using the pandas library.
import pandas as pd
pd.read_fwf('Hilary_slogans.txt', sep = "").head()
And now we'll train the rnn from the text file.
textgen.train_from_file('Hilary_slogans.txt', num_epochs=5)
The last thing we want to do is simply make 10 generations using our model. The last one is my favorite!
for i in range(0,10):
textgen.generate()