Prince-29/news-sentiment-analyzer
1
News Summarization & Sentiment Analysis
Overview
This project is a web-based application that extracts news articles related to a given company, performs sentiment analysis, generates a comparative analysis, and converts the summarized content into Hindi speech.
Features
- News Extraction: Fetches news articles using NewsAPI and scrapes additional content when available.
- Sentiment Analysis: Categorizes each article as Positive, Negative, or Neutral.
- Comparative Analysis: Provides an overview of sentiment distribution across articles.
- Text-to-Speech: Converts summarized news titles into Hindi speech.
- Web Interface: Allows users to input a company name via a Streamlit UI.
- API Integration: Backend developed using FastAPI to communicate with the frontend.
Installation
Prerequisites
Ensure you have Python installed (>= 3.8). Install the required dependencies:
pip install requests nltk beautifulsoup4 gtts deep-translator streamlit fastapi pydantic uvicornDownload NLTK Data
To enable sentiment analysis, run:
import nltk
nltk.download('vader_lexicon')Usage
Running the FastAPI Backend
Start the FastAPI server using:
uvicorn news:app --reloadRunning the Streamlit UI
Launch the web application:
streamlit run news.pyAPI Endpoints
POST /get_news/- Request Body:
{ "company": "Tesla" }- Response:
{
"articles": [...],
"sentiment_summary": {"Positive": 3, "Negative": 4, "Neutral": 3}
}Deployment
- Deploy FastAPI Backend: Use services like AWS, Heroku, or Render.
- Deploy Streamlit UI: Host on Streamlit Cloud or Hugging Face Spaces.
Acknowledgments
- NewsAPI for fetching news.
- NLTK for sentiment analysis.
- Google Translate API for Hindi translation.
- Streamlit for the UI.
- FastAPI for backend API.
