Text Generation using RNNs

In this brief notebook we show how we can load a chat from WhatsApp and try to emulate the behaviour from one of the users withing the group chat.

We start by importing some libraries and loading the group chat text file.


In [ ]:
from __future__ import print_function
import sys
sys.path.append('../')

In [3]:
import whatstk.parser as wp

Still in development


In [5]:
# load group chat
chat = wp.WhatsAppChat("../chats/samplechat.txt")
# choose user to emulate
user = 'Ash Ketchum'
#text_characters = chat.get_text(user, characters = True)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-ffea6fcc3963> in <module>()
      3 # choose user to emulate
      4 user = 'Ash Ketchum'
----> 5 text_characters = chat.get_text(user, characters = True)

AttributeError: 'WhatsAppChat' object has no attribute 'get_text'

Next, we initialize the RNN object using the retrieved data from the text.


In [8]:
from whatstk.learn.rnn import RNN, read_data
rnn = RNN(l, n_hidden_states=100)

Time to train!


In [ ]:
smooth_loss, iters, generated_sequences = rnn.generate_sequence()