This project aims to build a comprehensive system for collecting and analyzing restaurant reviews. The system will:
- Collect reviews from various platforms.
- Analyze the sentiment of the reviews to generate a rating.
- Provide explanations for the generated ratings.
- Create a word cloud highlighting key themes from the reviews.
- Analyze restaurant images to classify them based on suitability for different dining experiences (e.g., family, casual, date) and suggest improvements.
- Review Collection: Gather restaurant reviews from sources like Yelp and Google Reviews.
- Sentiment Analysis: Analyze the sentiment of the reviews to derive a rating.
- Rating Explanation: Provide detailed explanations for the generated ratings.
- Word Cloud Generation: Identify common themes in the reviews to create a word cloud.
- Image Analysis: Classify the restaurant type based on images and suggest improvements.
- Python: Main programming language.
- Gemini Pro API: Used for NLP and image analysis tasks.
- NLP Libraries: For additional natural language processing.
- Image Processing Libraries: For analyzing restaurant images.
- Web Scraping Tools: To collect reviews from various platforms.
- Python 3.7 or higher
- API key for Gemini Pro
-
Clone the repository:
git clone https://github.com/PhenomSG/Sentiment_Analysis_Using_NLP.git cd restaurant-review-analysis
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up your Gemini Pro API key:
export GEMINI_API_KEY='your_gemini_api_key'
To collect reviews from a source (e.g., Yelp), use the provided collect_reviews_from_source
function:
from review_collector import collect_reviews_from_source
reviews = collect_reviews_from_source('yelp', 'restaurant_id')
To analyze sentiment and generate a rating:
from review_analysis import sentiment_analysis, aggregate_ratings, gemini_pro_explain_rating
ratings = sentiment_analysis(reviews, model='gemini_pro')
overall_rating = aggregate_ratings(ratings)
explanation = gemini_pro_explain_rating(reviews, overall_rating)
To generate a word cloud from the reviews:
from word_cloud_generator import extract_keywords, generate_word_cloud
word_cloud_data = extract_keywords(reviews)
generate_word_cloud(word_cloud_data)
To classify restaurant type and suggest improvements based on images:
from image_analysis import classify_restaurant_type, assess_image_quality
for image in restaurant_images:
category = classify_restaurant_type(image, model='gemini_pro')
improvements = assess_image_quality(image, model='gemini_pro')
print(f"Category: {category}, Improvements: {improvements}")
restaurant-review-analysis/
│
├── README.md # Project overview and instructions
├── requirements.txt # List of dependencies
├── collect_reviews.py # Functions for collecting reviews
├── review_analysis.py # Functions for analyzing reviews
├── word_cloud_generator.py # Functions for generating word clouds
├── image_analysis.py # Functions for analyzing images
└── main.py # Main script to run the analysis
This project is licensed under the MIT License. See the LICENSE file for details.