Sentence Generator is a program to predict following words after entered words.
Sentence Generator uses a language model trained with PTB dataset.
Deep Recursive Neural Network (with 2 LSTM Layers) is applied to implement the language model.
Although the generated sentences are not quite perfect
You will see it mimics the structure of sentences.
- Python > 3.5
- TensorFlow 1.4
Install all python packages required using pip
$ pip install -r requirements.txt
Using Virtualenv is recommended.
To train the model, Penn Tree Bank(PTB) dataset is used.
Download 'ptb.train.txt' here and place in ./data.
$ python word_sequence.py --mode train
$ python word_sequence.py --mode pretrained
Enter words(enter '!' to exit):
You can enter either a single word or multiple words.
In case you enter words out of the vocabulary, the program ends.
N is numbers.
<unk> is a tag indicating unknown words.
(They were already preprocessed in the PTB dataset)
If you want to use the sentence generator without training the model,
Use '--model pretrained' option.
(You need to download './pretrained')
$ python sentence_generator.py --mode generate --model pretrained