How j43fura/text-sentiment-analysis works
Project Type & Purpose
• This is a lightweight full-stack web application built on FastAPI.
File Structure
• Top-level files: README, requirements.txt, .gitignore, .gitattributes.
• src/
• main.py – FastAPI application entrypoint.
• sentiment_analysis.py – encapsulates sentiment logic (TextBlob, VADER usage).
• templates/index.html – Jinja2 template for rendering results.
Key Insights from README
• Frameworks & Tools: FastAPI (with Uvicorn), Jinja2, simplecss for styling.
• Models: TextBlob, VADER (externally maintained Python libraries, plus TextBlob corpora).
• Execution: served via Uvicorn at HTTP endpoints, renders HTML form + results.
Main Components & Their Interactions
a. Client Browser (Front-end)
• Displays index.html (form + empty result area).
• Sends HTTP POST (or GET) with user text to the FastAPI endpoint.
b. Web Server & API Layer
• Uvicorn running FastAPI (main.py)
• Routes: e.g., “/” serving index.html, “/analyze” handling form submissions.
c. Template Engine
• Jinja2 integrates with FastAPI to render dynamic HTML based on analysis.
d. Sentiment Analysis Module
• sentiment_analysis.py exposes functions that:
• Invoke TextBlob for polarity/subjectivity.
• Invoke VADER for sentiment scoring.
• Classify tokens into one of five categories.
e. External Dependencies & Data
• TextBlob corpora (downloaded at setup).
• VADER lexicon.
• simplecss static style sheet.
Architectural Patterns & Principles
• Separation of concerns:
• Presentation (templates + static CSS) vs. business logic (analysis module) vs. API layer.
• Modular design: sentiment logic is isolated for easy extension (e.g., adding new models).
• Request-response pattern over HTTP.