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

df=pd.read_csv("movie_reviews.csv")
pos={"excellent","enjoyable","loved","amazing","wonderful","good"}
neg={"boring","disappointing","hated","terrible","dull","poor"}

def score(x):
    w=set(x.lower().split())
    return len(w&pos)-len(w&neg)

df["score"]=df.review.apply(score)
df["predicted"]=np.where(df.score>0,"Positive",np.where(df.score<0,"Negative","Neutral"))
print(df[["id","review","score","predicted"]])
df.predicted.value_counts().plot.bar()
plt.title("Movie Review Sentiment")
plt.xlabel("Sentiment")
plt.ylabel("Count")
plt.show()