CoolFace
Apppublic

Prince-29/news-sentiment-analyzer

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
App README

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:

bash
pip install requests nltk beautifulsoup4 gtts deep-translator streamlit fastapi pydantic uvicorn

Download NLTK Data

To enable sentiment analysis, run:

python
import nltk
nltk.download('vader_lexicon')

Usage

Running the FastAPI Backend

Start the FastAPI server using:

bash
uvicorn news:app --reload

Running the Streamlit UI

Launch the web application:

bash
streamlit run news.py

API Endpoints

  • POST /get_news/
  • Request Body:
json
    { "company": "Tesla" }
  • Response:
json
    {
      "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