I have some text files containing movie reviews I need to find out whether the review is good or bad. I tried the following code but it's not working:
import nltk
with open("c:/users/user/desktop/datascience/moviesr/movies-1-32.txt", 'r') as m11:
mov_rev = m11.read()
mov_review1=nltk.word_tokenize(mov_rev)
bon="crap aweful horrible terrible bad bland trite sucks unpleasant boring dull moronic dreadful disgusting distasteful flawed ordinary slow senseless unoriginal weak wacky uninteresting unpretentious "
bag_of_negative_words=nltk.word_tokenize(bon)
bop="Absorbing Big-Budget Brilliant Brutal Charismatic Charming Clever Comical Dazzling Dramatic Enjoyable Entertaining Excellent Exciting Expensive Fascinating Fast-Moving First-Rate Funny Highly-Charged Hilarious Imaginative Insightful Inspirational Intriguing Juvenile Lasting Legendary Pleasant Powerful Ripping Riveting Romantic Sad Satirical Sensitive Sentimental Surprising Suspenseful Tender Thought Provoking Tragic Uplifting Uproarious"
bop.lower()
bag_of_positive_words=nltk.word_tokenize(bop)
vec=[]
for i in bag_of_negative_words:
if i in mov_review1:
vec.append(1)
else:
for w in bag_of_positive_words:
if w in moview_review1:
vec.append(5)
So I am trying to check whether the review contains a positive word or a negative word. If it contains a negative word then a value of 1 will be assigned to the vector vec else a value of 5 will be assigned. But the output I am getting is an empty vector.
Please help. Also, please suggest others way of solving this problem.