This project uses Natural Language Processing (NLP) to analyze restaurant reviews and determine whether they are Positive or Negative. It leverages machine learning to classify the sentiment and provides an interactive interface for users to submit their own reviews. The project also calculates the percentage of positive and negative reviews based on the data collected.
- Sentiment Classification: Classifies reviews as Positive or Negative 🟢🔴.
- User Interaction: Users can submit their reviews, and the sentiment is predicted instantly 💬🔍.
- Data Storage: Reviews and their sentiments are stored for future analysis 📊💾.
- Sentiment Percentages: Displays the percentage of positive and negative reviews based on collected data 📈.
- Programming Language: Python 🐍
- Libraries:
pandas
: For data handling 📊sklearn
: For machine learning and sentiment analysis 🧠matplotlib
&seaborn
: For visualizing results 📉wordcloud
: For generating word clouds 🌈gradio
: For creating the interactive web interface 🌐ipywidgets
: For interactive widgets 🎛️
- Data Input: Users can input restaurant reviews manually or choose from sample reviews 🍴📝.
- Sentiment Analysis: The review is processed using a pre-trained model that classifies it as either Positive or Negative 💡.
- Output: The sentiment prediction is displayed, and the review is stored for future reference 💾.
- Percentage Calculation: After multiple reviews are submitted, the project calculates and displays the percentage of Positive vs Negative reviews 📊.
- Interactive Interface: The project uses Gradio and ipywidgets to provide a seamless user experience 🖥️.
-
Clone the repository:
git clone <repository_url> cd <project_folder>
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the project:
python sentiment_analysis.py
-
Review: "The food was delicious and the service was excellent!"
- Predicted Sentiment: Positive ✨
-
Review: "Terrible experience, food was cold and service was slow."
- Predicted Sentiment: Negative 💔
- Submit your review: Type your review in the input box and see the sentiment prediction 🔍.
- Sample Reviews: Click on sample review buttons to quickly load reviews and see the predictions 🍽️.
- Sentiment Breakdown: The interface shows the percentage of positive and negative reviews 📈.
- Review History: Your submitted reviews and their sentiment classification are displayed for easy reference 📝.
The project includes an intuitive interface created with Gradio. Here’s how it’s structured:
- Restaurant Details: Information about the restaurant and cuisine 🍕🍔🍣.
- User Reviews: Input a review, select from sample reviews, or see sentiment analysis results 🌟.
- Review History: See a history of your submitted reviews and the sentiment breakdown 📜.
- Sentiment Percentages: Displays the percentage of Positive vs Negative reviews based on the submitted data 📊.
- Predicted Sentiment: Positive or Negative 🟢🔴
- Sentiment Percentages:
- Positive Reviews: 60.00% 👍
- Negative Reviews: 40.00% 👎
predict_sentiment(review)
: Processes the input review and predicts whether it’s Positive or Negative.save_review(review, sentiment)
: Saves the review and its sentiment, and updates the sentiment percentages.calculate_percentages()
: Calculates the percentage of Positive and Negative reviews based on the stored reviews.
- Input a review into the text box or choose a sample review using the provided buttons.
- The system will classify the sentiment as Positive or Negative.
- Your review will be saved, and the sentiment percentages will be updated.
Feel free to fork the repository and contribute! Here’s how you can get started:
- Fork the repository.
- Create your branch (
git checkout -b feature-name
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Create a pull request to merge your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Multilingual Support: Add sentiment analysis support for multiple languages 🌍.
- Sentiment Visualization: Improve sentiment visualization with word clouds and more charts 🧑🎨.
- Model Improvement: Experiment with different models for better accuracy 🧠.