import pandas as pd,numpy as np,matplotlib.pyplot as plt

df=pd.read_csv('reviews.csv')
txt=df['Text'].str.lower()
p=txt.str.contains(r'amazing|worth|satisfied|recommend|flawlessly|excellent|perfect|great')
n=txt.str.contains(r'unhelpful|rude|disappointed|poor|damaged|late|stopped|lacks')
df['Sentiment']=np.select([p>n,n>p],['Positive','Negative'],'Neutral')
df['Lang']=np.where(df['Text'].str.contains(r'[^\x00-\x7F]'),'Non-English','English')
pd.crosstab(df['Window'],df['Sentiment']).plot(kind='bar',stacked=True,color=['red','purple','yellow'],edgecolor='black')
plt.title('Product Review Sentiment Analysis')
plt.xlabel('Platform')
plt.ylabel('Count')
plt.tight_layout()
plt.show()