Python wrapper and web UI for IBM Watson NLP emotion detection (anger, disgust, fear, joy, sadness).
emotion_detector(text)sends text to the Watson NLP emotion endpoint and returns scores for anger, disgust, fear, joy and sadness.- Adds a
dominant_emotionfield with the highest-scoring emotion. - Returns
Nonefor every emotion (and fordominant_emotion) if the request or parsing fails. - Single-page UI (
templates/index.html) with a text box and a "Run Sentiment Analysis" button that shows the result below the form.
final_project/emotion_detection.py Watson NLP client function
templates/index.html Single-page UI (Bootstrap 4)
static/mywebscript.js Sends the text to the backend and renders the response
Requirements: Python 3 and the requests package. The detector calls a hosted IBM Watson endpoint, so network access is required.
pip install requests
python -c "from final_project.emotion_detection import emotion_detector; print(emotion_detector('I am so happy today'))"The UI is plain HTML and JavaScript. Its script calls emotionDetector?textToAnalyze=<text>, but this repository does not include the server route that serves that endpoint, so the page cannot return results from this repo alone. Open templates/index.html only after adding a backend that provides that route.
Apache License 2.0. See LICENSE.