π Sentiment Analyser Dashboard Overview:
The Sentiment Analyser Dashboard is a data-driven web application built with Streamlit that collects Reddit posts and news articles, performs sentiment analysis, and provides interactive visualizations to help users understand market sentiment around specific keywords.
Users can:
Fetch Reddit and news data for selected keywords.
Analyze sentiment (positive, negative, neutral) using NLP techniques.
Visualize trends through charts, tables, and summaries.
Customize analysis by adding their own keywords dynamically.
This project demonstrates the integration of data collection, storage, processing, visualization, and interactivity in a seamless workflow.
β¨ Key Features
π Keyword-based sentiment analysis on Reddit + news data.
π₯ Automatic data fetching from Reddit & news APIs.
π Interactive visualizations (bar charts, tables, sentiment summaries).
π User-defined keywords via Streamlit UI.
π Persistent storage using PostgreSQL.
β‘ Fast and lightweight dashboard powered by Streamlit.
π Technologies Used: Frontend / Dashboard:
Streamlit β For building the interactive web UI.
Backend & Data Collection:
PRAW / Reddit API β To fetch Reddit posts.
News API β To fetch latest news headlines.
Requests β For making API calls.
JSON β Handling API responses.
Data Processing & Analysis
Pandas β Data wrangling and summarization.
NumPy β Numeric computations.
VADER Sentiment Analyzer β Rule-based sentiment classification.
Database:
PostgreSQL β Storing Reddit + news posts and sentiment results.
SQLAlchemy β ORM for database interaction.
Visualization:
Matplotlib / Plotly β Charts and graphs.
Streamlit Tables / DataFrames β Interactive data exploration.
Environment & Project Structure:
Python 3.10+
πΉ Demo
Click the "Fetch Latest Data" button to pull new Reddit posts and News articles and see the sentiment comparison.
πΉ Features
β Fetch Reddit posts from relevant subreddits
β Fetch News articles via NewsAPI
β Perform sentiment analysis using VADER
β Label posts/articles as Positive / Negative / Neutral
β Compare sentiment across Reddit and News
β Interactive bar charts and summary tables in Streamlit
βοΈ Getting Started (Local Setup)
Requirements: PostgreSQL, Reddit API credentials, NewsAPI credentials
- Setup Reddit API
Go to Reddit Developer Portal
Create an app
Copy REDDIT_CLIENT_ID (highlighted in the app page)
Copy REDDIT_CLIENT_SECRET
Set a REDDIT_USER_AGENT (any descriptive string)
- Setup NewsAPI
Go to NewsAPI
Click Get API Key
Copy your NEWS_API_KEY
- Setup PostgreSQL
Download PostgreSQL from postgresql.org
Create a database and note: DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME
-
Clone the repo git clone https://github.com/Addy0606/sentimentanalyser/ cd sentimentanalyser
-
Create a virtual environment python -m venv sentimentanalyser-venv
sentimentanalyser-venv\Scripts\activate
source sentimentanalyser-venv/bin/activate
-
Install dependencies pip install -r requirements.txt
-
Configure environment variables
Create a .env file in the main project directory with:
DB_USER=your_postgres_user
DB_PASSWORD=your_postgres_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_db_name
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret
REDDIT_USER_AGENT=your_reddit_user_agent
NEWS_API_KEY=your_newsapi_key
- Create PostgreSQL tables
Reddit Posts Table
CREATE TABLE reddit_posts ( post_id TEXT PRIMARY KEY, subreddit TEXT, keyword TEXT, title TEXT, url TEXT, created_utc TIMESTAMP, selftext TEXT, sentiment FLOAT, label TEXT );
News Posts Table
CREATE TABLE news_posts ( id SERIAL PRIMARY KEY, title TEXT, url TEXT, published_at TIMESTAMP, source TEXT, keyword TEXT, description TEXT, content TEXT, sentiment FLOAT, label TEXT );
Open the URL displayed in the terminal (usually http://localhost:8501)
Add stocks/keywords as desired.
Click "π Fetch Latest Data" to fetch, analyze, and display data.
π Project Structure sentimentanalyser/ β
ββ src/
β ββ init.py
β ββ app.py # Streamlit dashboard
β ββ fetchreddit.py # Reddit fetching module
β ββ fetchnews.py # NewsAPI fetching module
β ββ sentiment.py # Sentiment analysis & summary
β ββ config.py # Keywords and subreddits
β ββ .env # Environment variables (not in repo)
ββ .gitignore
ββ requirements.txt # Python dependencies
ββ README.md
Free API limits: NewsAPI and Reddit API have request restrictions
Ensure PostgreSQL is running and accessible before fetching data