Skip to content
Open

Done #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions Project/SentimentAnalyzer.ipynb

This file was deleted.

31 changes: 31 additions & 0 deletions Project/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from textblob import TextBlob
import pandas as pd

def analyzeSentiment(text):
blob = TextBlob(text)
sentiment_score = blob.sentiment.polarity

if sentiment_score > 0:
return 'Positive'
elif sentiment_score < 0:
return 'Negative'
else:
return 'Neutral'

df = pd.read_csv('data.csv')

product_id = 'AVqkIhwDv8e3D1O-lebb' #or any id you want to search for

df_product = df[df['product_id'] == product_id]

product_name = df_product['name'].iloc[0]

df_product['sentiment'] = df_product['reviews.text'].apply(analyzeSentiment)

positive = (df_product['sentiment'] == 'Positive').sum()
negative = (df_product['sentiment'] == 'Negative').sum()
neutral = (df_product['sentiment'] == 'Neutral').sum()

print(f"The product with Name {product_name} has {positive} positive reviews, {negative} negative reviews, and {neutral} neutral reviews")

df_product.to_csv('output.csv', index=False)
244 changes: 0 additions & 244 deletions README.md

This file was deleted.

Binary file removed Tutorial/.DS_Store
Binary file not shown.
Binary file removed Tutorial/0. Introduction to Python.pdf
Binary file not shown.
Loading