This project is an AI-powered web application for detecting emotions in text. It uses the Watson NLP Library to analyze the input and return the corresponding emotions with their respective scores. The application is developed with Flask and incorporates features such as error handling and a user-friendly interface.
- Detect emotions such as anger, disgust, fear, joy, and sadness.
- Display the dominant emotion for the provided text.
- Error handling for invalid or blank inputs.
- Simulated responses for offline testing.
- RESTful API endpoint for integrating with other applications.
final_project/
├── EmotionDetection/
│ ├── __init__.py
│ ├── emotion_detection.py
├── static/
│ ├── mywebscript.js
├── templates/
│ ├── index.html
├── server.py
├── test_emotion_detection.py
├── README.md
├── LICENSE
└── .gitignore
-
Python 3.12 or higher
-
Flask
-
PyLint
-
Postman (For API testing)
- Clone the repository
git clone https://github.com/AIExxplorer/final_project.git cd final_project
- Set up a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the required packages
pip install -r requirements.txt
- Start the Flask Server
python server.py
- Open your browser and navigate to http://127.0.0.1:5000
- Use Postman to test the /emotionDetector endpoint.
- Example JSON body:"
{
"text": "I think I am having fun"
}
- Expected output:"
{
"anger": 0.0,
"disgust": 0.0,
"fear": 0.0,
"joy": 0.99,
"sadness": 0.01,
"dominant_emotion": "joy"
}
- If no input is provided, the system will return:
{
"error": "Invalid text! Please try again!"
}
- Run the unit tests:
python -m unittest test_emotion_detection.py
- Check the output for all test passing.
- Run static code analysis with PyLint:
pylint server.py
- Ensure a score of 10/10 for clean and maintainable code.
- This project is licensed under the APACHE License for more details click under LICENSE at the top right of the repository.
- IBM Watson NLP Library for enabling the emotion detection funcionality.
- Flask for simplifying the web application development.