Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
adl13006 committed Mar 17, 2016
1 parent ac01541 commit 47c6a2a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions GlossCount.py
Expand Up @@ -57,30 +57,33 @@ class GlossCount:
neutral = set(newsets[2])

# Learn Classifier
print len(negative)
print len(positive)
trainfeats = [({word : True},"pos") for word in positive] + [({word : True},"neg") for word in negative]
classifier = NaiveBayesClassifier.train(trainfeats)
print "cat"
#print classifier.classify(dict([(word, True) for word in words]))
print classifier.classify(dict([("bad",True),("bad",True)]))
#print classifier.classify(dict([("bad",True),("bad",True)]))
# Iterate through all of the reviews and find sentiment
count = 0.00
correct = 0.00
for reviews in movie_reviews.fileids():
for reviews in movie_reviews.fileids(): #For every review
score = 0;
for words in movie_reviews.words(fileids=[reviews]):
if()
sent_value = classifier.classify(dict([(word, True)]))
if(sent_value is 'neg'):
score = score - 1
elif(sent_value is 'pos'):
score = score + 1
tokens = nltk.pos_tag(nltk.word_tokenize(movie_reviews.raw(fileids=[reviews]))) #Tokenize all words
for token in tokens:
if (token[1]== "JJ" or token[1] == "JJR" or token[1] == "JJS"): # If adjective, check value
sent_value = classifier.classify(dict([(token[0], True)]))
if(sent_value is 'neg'):
score = score - 1
elif(sent_value is 'pos'):
score = score + 1
if (score < 0):
print "Negative at %d" % (score)
sentiment = 'neg'
else:
sentiment = 'pos'
print "Positive at %d" % (score)
if (sentiment == movie_reviews.categories(fileids=[reviews])[0]):
print "Correct"
correct = correct + 1.00
count = count + 1.00
print correct/count
Expand Down

0 comments on commit 47c6a2a

Please sign in to comment.