How chitikesisiddharth04/bilingual-movie-review-sentiment-analysis-using-nlp works
Purpose and entry points
This is a Flask-served bilingual movie-review sentiment classifier. Users submit English or Telugu text through a single browser UI; the backend selects the corresponding trained Bag-of-Words/Bernoulli Naive Bayes pipeline and returns Positive or Negative sentiment. Runtime entry point: app.py; browser entry template: templates/index.html.
Web application boundary
app.py owns HTTP routing, request handling, language selection, model invocation, and response generation. templates/index.html is the unified client interface, including language switching and review submission. The app runs locally with Flask and is intended for Gunicorn in production (gunicorn app:app).
English inference pipeline
English review processing and training logic are centered in english/MRA.py. Its deployed artifacts are the fitted classifier english/model1.pkl and fitted vocabulary/vectorizer english/bow.pkl. The expected flow is raw English text → preprocessing/tokenization/stopword removal/stemming → vectorization → BernoulliNB prediction → sentiment result.
Telugu inference pipeline
Telugu has an independent language-specific pipeline in telugu/telugu_MRA.py, allowing Unicode-aware text normalization, Telugu tokenization, and custom stopword handling without coupling to English rules. Deployed model artifacts are telugu/telugu_model.pkl and telugu/telugu_vectorizer.pkl. Flow mirrors English: Telugu review → Telugu preprocessing → vectorization → BernoulliNB prediction → sentiment result.
Model artifact contract
The Flask layer depends on each language model and its matching vectorizer being loaded together: English paths are english/model1.pkl plus english/bow.pkl; Telugu paths are telugu/telugu_model.pkl plus telugu/telugu_vectorizer.pkl. Vectorizer feature spaces are model-specific and must not be interchanged. Training scripts regenerate these serializable artifacts for serving.
Training versus serving boundary
Training is offline/manual rather than part of normal application startup. english/MRA.py is intended to train from an IMDB review dataset supplied externally; telugu/telugu_MRA.py trains from a supplied Telugu dataset. Serving uses committed pre-trained .pkl files only, keeping request-time work limited to preprocessing, feature extraction, and inference.
Runtime and deployment
Material runtime dependencies are Python 3.8+, Flask, NLTK, scikit-learn, and Pandas, declared in requirements.txt. render-build.sh provides the Render build-stage integration; production deployment targets Render with Gunicorn. External data sources are Kaggle/IMDB data for optional English retraining and a separately supplied Telugu dataset; neither dataset is present in the supplied file tree.
Main entry points: MRA.py English inference · telugu_MRA.py Telugu inference · app.py Flask application · index.html Unified review UI
Components 14
Web Serving
- Browser · Users submit a review and choose a language.
- Unified review UI · Language switching and review submission interface.
templates/index.html - Flask application · Routes requests, selects a language pipeline, and returns sentiment.
app.py
English Pipeline
- English inference · Preprocesses English text, vectorizes it, and predicts sentiment.
english/MRA.py - English vectorizer · Feature space paired only with the English classifier.
english/bow.pkl - English BernoulliNB
english/model1.pkl - IMDB training data · Optional external Kaggle/IMDB source for offline retraining.
Telugu Pipeline
- Telugu inference · Uses Unicode-aware normalization, Telugu tokenization, and custom stopwords.
telugu/telugu_MRA.py - Telugu vectorizer · Feature space paired only with the Telugu classifier.
telugu/telugu_vectorizer.pkl - Telugu BernoulliNB
telugu/telugu_model.pkl - Telugu training data · Supplied externally for offline retraining.
Deployment
- Python dependencies · Declares Flask, NLTK, scikit-learn, Pandas, and Python requirements.
requirements.txt - Render build stage
render-build.sh - Gunicorn on Render · Serves the Flask app using gunicorn app:app.
Connections 17
- Browser → Unified review UI: loads UI
- Unified review UI → Flask application: submits review + language
- Flask application → English inference: English request
- Flask application → Telugu inference: Telugu request
- English vectorizer → English inference: vectorizes text
- English BernoulliNB → English inference: predicts sentiment
- Telugu vectorizer → Telugu inference: vectorizes text
- Telugu BernoulliNB → Telugu inference: predicts sentiment
- IMDB training data → English inference: offline training input
- English inference → English vectorizer: regenerates offline
- English inference → English BernoulliNB: regenerates offline
- Telugu training data → Telugu inference: offline training input
- Telugu inference → Telugu vectorizer: regenerates offline
- Telugu inference → Telugu BernoulliNB: regenerates offline
- Render build stage → Python dependencies: installs
- Gunicorn on Render → Flask application: serves
- Python dependencies → Gunicorn on Render: runtime dependencies