/PredictPlay

An NLP Model that writes portion of a play in Shakespearean english

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Project logo

predict-play

Status Platform GitHub Issues GitHub Pull Requests License


An NLP Model that writes portion of a play in Shakespearean english.

📝 Table of Contents

🧐 About

This project demonstrates how to generate text using a character-based RNN. Given a sequence of characters from the data, model predicts the next character in the sequence ("e").Longer sequences of text can be generated by calling the model repeatedly.

FrontEnd is handled by an react app which is built as a webpack during deployment and rendered using flask render_template.

While some of the sentences are grammatical, most do not make sense. The model has not learned the meaning of words, but consider:

  • The model is character-based. When training started, the model did not know how to spell an English word, or that words were even a unit of text.

  • The structure of the output resembles a play—blocks of text generally begin with a speaker name, in all capital letters similar to the dataset.

  • The model is trained on small batches of text (100 characters each), and is still able to generate a longer sequence of text with coherent structure.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system like EC2 or Heroku.

Prerequisites

Things you need to install the project are all listed in requirements.txt

pip install -r requirements.txt

Installing

After all the requirements are installed, run the following command to build the webpack

node run heroku-postbuild

After the webpack is build, run the following command to start the flask app

gunicorn server:app

The server should return the address and the port in the cli where you can access the webpage.

Example

[1787198] [INFO] Starting gunicorn 20.0.4
[1787198] [INFO] Listening at: http://127.0.0.1:8000
[1787198] [INFO] Using worker: sync
[1787200] [INFO] Booting worker with pid: 1787200

🎈 Usage

In Order to Use the app just open the url returned by guincorn in your local browser and give the input as "NAME:" in the text box and click on submit.

DEMO LiveServer

🚀 Deployment

Heroku

Push the repo to your local github and set up a deployment in heroku.

Add the following buildpacks under Settings > Buildpacks

heroku/python
heroku/nodejs

The first build back will install all the dependencies for flask app and the second buildpack will ensure that webpack is compiled and available for rendering. Procfile is already defined so just naviagte to your heroku app uri and the website should show up.

Amacon EC2

The deployment procedure on ec2 is exactly same as installing on local machine.Getting Started

Be sure to open the required ports in the security group for the instance.

The web app will be available on the elastic ip associated to your ec2 instance along with port number returned by the guicorn.

http://your-elastic-ip:port/

⛏️ Built Using

  • Tensorflow - An end-to-end open source machine learning platform for everyone.
  • Flask - Flask is a lightweight WSGI web application framework.
  • React - React is an open-source JavaScript library for building user interfaces or UI components.

✍️ Authors

See also the list of contributors who participated in this project.