Welcome to The Echo Chamber, a platform designed to offer a multifaceted perspective on current events by diversifying your news feed and challenging your views with a spectrum of viewpoints. Here, critical thinking is ignited, and informed decisions are made. Listen, learn, and engage in dynamic conversations.
- News Fetching: Retrieve news articles based on search queries or categories using the NewsAPI.
- Sentiment Analysis: Analyze the sentiment of news articles to understand the overall tone.
- Recommendation System: Get recommendations for similar news articles based on content similarity.
- Python 3.7 or higher
- Virtual Environment (optional but recommended)
-
Clone the repository:
git clone https://github.com/krsnathkr/NewsML.git cd NewsML
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the root directory and add your NewsAPI key:API_KEY=your_newsapi_key_here
Start the Streamlit application by running:
streamlit run app.py
-
Search for News:
- Enter a search query to fetch relevant news articles.
- The articles will be displayed along with their sentiment analysis.
- Select an article to get recommendations for similar articles.
-
Category News:
- Select a news category from the sidebar to fetch top headlines in that category.
- The articles will be displayed along with their sentiment analysis.
- Select an article to get recommendations for similar articles.
Handles fetching news articles from the NewsAPI based on query or category.
def fetch_news(query):
# Fetches news articles based on a search query.
def fetch_news_by_category(category):
# Fetches top headlines based on a category.
Performs sentiment analysis on the fetched news articles.
def analyze_sentiment(articles):
# Analyzes the sentiment of the provided articles.
Prepares and operates the recommendation system for suggesting similar news articles.
def prepare_recommendation_system(df):
# Prepares the recommendation system based on article content.
The main application script that integrates the news fetching, sentiment analysis, and recommendation features using Streamlit for the user interface.
We welcome contributions to enhance The Echo Chamber. Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more information.