How kiran-91/sentimeter--sentiment-analysis-using-rnn-and-nlp works
Project Type & Purpose
• This is a lightweight full-stack application combining a Streamlit front end with a simple RNN-based ML back end.
• Purpose: Accept movie-review text, preprocess it (tokenize/pad), run it through a pre-trained SimpleRNN model (SimpleRNN_imdb.h5) and display sentiment plus history.
File Structure
• Top level:
• app.py – Streamlit app (UI + orchestration)
• SimpleRNN_imdb.h5 – serialized Keras model
• prediction.ipynb & simpleRNN.ipynb – exploratory notebooks (model prototyping)
• requirements.txt, README.md, LICENSE – metadata/config
• No separate “frontend” or “backend” folders: both live in app.py.
Read README for Architecture Clues
• Streamlit provides the UI.
• NLP preprocessing uses nltk + Keras Tokenizer/Pad Sequences.
• The model is loaded from disk on startup.
• Review history is tracked in-memory (e.g., session_state) or optionally persisted.
Main Components & Interactions
a. Components:
1) User’s Browser/Client
2) Streamlit Server (app.py)
• UI Layer (text input, buttons, display panels)
• Controller Layer (handles clicks, triggers preprocessing & inference)
3) Preprocessing Module
• Tokenizer, padding logic, stop-word filtering (nltk)
4) Model Inference Module
• Keras loads SimpleRNN_imdb.h5
• Runs predict() to produce sentiment score
5) Review History Store
• Streamlit session_state or lightweight local CSV/JSON
6) External Libraries/Services
• nltk data, TensorFlow/Keras, Streamlit cloud (hosting)
b. Interactions/Data Flow:
• User enters text → Streamlit UI → Controller
• Controller calls Preprocessing → vectorized input
• Vector passed to Model Inference → sentiment probability
• Result returned to Controller → UI display
• Controller appends entry to Review History → history panel
• All flows logged on console or session_state
Architectural Patterns & Principles
• MVC-style separation within a single file:
• Model: SimpleRNN_imdb.h5 + Keras code
• View: Streamlit widgets
• Controller: app.py functions tying UI to model
• Stateless front end with ephemeral session storage for history.
• Single-process, synchronous request–response pattern.
Technologies & Libraries
• Frontend/UI: Streamlit
• NLP: NLTK (tokenization, stop-words)
• ML Framework: TensorFlow/Keras
• Data: IMDB dataset (training not in app)
• Hosting: Streamlit Cloud or local