Skip to content
anYoneoPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

NLP Chatbot with NLTK + Keras

A conversational AI chatbot built with Python, Flask, NLTK, and Keras. The chatbot uses Natural Language Processing (NLP) to understand user inputs and a Deep Learning model to classify intents and provide appropriate responses.

✨ Features

  • Intent Classification: Uses a deep learning model to accurately classify user intents.
  • Natural Language Processing: Employs NLTK for tokenization, lemmatization, and bag-of-words creation.
  • Web Interface: Simple and intuitive web interface powered by Flask.
  • Configurable: Easy to update intents and retrain the model via config.py.
  • Error Handling: Graceful fallback response when intent is not recognized.

🛠️ Tech Stack

Technology Description
Python Core programming language
Flask Web framework for the server and API
NLTK Natural Language Toolkit for text processing
Keras / TensorFlow Deep learning framework for the classification model

🚀 Installation

  1. Clone the repository:

    git clone https://github.com/anYoneo/chatbot
    cd chatbot
  2. Install the required dependencies:

    pip install -r requirements.txt

💬 Usage

Training the Model

Before running the app for the first time, or after updating data.json, train the model:

python training.py

This generates model.h5, texts.pkl, and labels.pkl.

Running the Chatbot

python app.py

Open your browser at http://localhost:5000

📁 Project Structure

chatbot/
├── app.py             # Main Flask application and NLP prediction logic
├── config.py          # Configuration settings (threshold, paths, debug)
├── training.py        # Script to train the Keras model
├── data.json          # Training data (intents, patterns, responses)
├── requirements.txt   # Python dependencies
├── README.md          # Project documentation
├── .gitignore         # Git ignore rules
├── static/            # Static files (CSS, JS, images)
└── templates/         # HTML templates
    └── index.html     # Main chat UI

(Binary files model.h5, texts.pkl, labels.pkl are generated after training)

🧠 Architecture

Training Phase:

  1. Reads data.json containing intents (tags, patterns, responses)
  2. Tokenizes & lemmatizes patterns using NLTK
  3. Creates Bag of Words representation
  4. Trains a feedforward neural network (Keras) to classify intents
  5. Saves model + vocabulary to disk

Inference Phase:

  1. User sends message via Flask web UI
  2. Message is tokenized, lemmatized → Bag of Words
  3. Keras model predicts intent probability
  4. If probability > ERROR_THRESHOLD (0.25): best intent is chosen
  5. Random response for the intent is returned to user

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages