Skip to content

brianpinto91/spell-checker-heroku-app

Repository files navigation

Spell Checker and Recommender

Build Status GitHub repo size CodeFactor Grade

A web application which can be used to get spelling recommendations for words entered by user in english language.

Table of Contents

App

Below is the screenshot of the application. You can check it out by clicking on the image.

App: screenshot

Motivation

The best way of learning about anything is by doing - Richard Branson

I took this project to explore Flask, Gunicorn, Jinja, Heroku, and continous integration with Travis CI. Also it was a good opportunity for me to refresh my html and css skills, by designing the frontend myself. This is just the start of many more complex machine learning and deep learning apps that I would be working on and deploying!

Implementation

I used the NLTK's Word Lists as vocabulary for english. To check for the spelling, Jaccard distance is used to find the dissimilarity of the input word with the words in the vocabulary starting with the same letter as the input word. The implmentation requires the words to be converted into set of appropriate n-grams. For more information on this topic, you can read this article.

I thought it would also be useful if the user gets some suggestions for spellings together with the meaning, when they input a wrong word. The PyDictionary package for python provides a dictionary to get the meaning for the words.

For the deployment, Heroku application engine is used with Flask served using Gunicorn (required in production web serving). I designed my own custom front end with html and css.

Installation

Since, I use Linux for software development, I am covering the installation for Linux / Mac OS.

Clone the repository

On your computer, first navigate to the directory were you want to download the repository to. Then run the following commands:

mkdir spell-checker-app
cd spell-checker-app
git clone --depth 1 https://github.com/brianpinto91/spell-checker-heroku-app.git

Setup Virtual Environment

The app is built and tested using Python 3.6.12. Follow this guide to install it. Create a virtual environment where you can install the dependencies to run the python program. Follow this guide to setup a virtual environment. Once you have created one, please make sure that you activate it using the command (subsitute your_env_path with the absolute path where you saved your environment)

source your_env_path/bin/activate

Install the dependencies

Before you install the dependencies update your pip and setuptools using:

pip install --upgrade pip
pip install --upgrade setuptools

Now, make sure you are in the root directory of this project that you created during cloning. Then install the dependency packages using:

pip install -r requirements.txt

Run the App Locally

To run using flask (for development purpose), use:

flask run

The app will start serving on your computer. You can open it using the address 127.0.0.1:5000 in your favorite web-browser.

Alternatively, you can run with gunicorn (as used with deployment):

gunicorn -b 127.0.0.1:5000 app:app

Deploy on Heroku

You need to create a Heroku account first, if you don't have one. Then in your command line run these commands one by one:

heroku login
heroku create your-app-name-here
heroku deploy

Note: If the app name is already taken, you will get error. You can try some other names again.

Heroku requires certain files for deployment in the root directory. The most important files for deployemnt are the app.py, requirements.txt and the Procfile.

The Procfile defines the configuration for Heroku and the entrypoint for the WSGI server which is Gunicorn

You can change the entrypoints if you want by defining it in the Procfile for example as:

web: gunicorn main_file_name:flask_app_object_name

In my repository I have used app as the name of my main file and also for the flask object.

Technologies

Python: shield HTML: shield forthebadge


License

License: MIT

Copyright 2020 Brian Pinto