Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Not sure
  • Loading branch information
adl13006 committed Mar 30, 2016
1 parent 77869d0 commit 7b2c04e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions GlossCount.py
Expand Up @@ -57,19 +57,23 @@ 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]))
<<<<<<< HEAD
#print classifier.classify(dict([("bad",True),("bad",True)]))


=======
print classifier.classify(dict([("bad",True),("bad",True)]))
>>>>>>> parent of 47c6a2a... Bugfix
# Iterate through all of the reviews and find sentiment
count = 0.00
correct = 0.00
for reviews in movie_reviews.fileids(): #For every review
for reviews in movie_reviews.fileids():
score = 0;
<<<<<<< HEAD
tokens = nltk.pos_tag(nltk.word_tokenize(movie_reviews.raw(fileids=[reviews]))) #Tokenize all words with POS
for token in tokens:
if (token[1]== "JJ" or token[1] == "JJR" or token[1] == "JJS"): # If adjective, check value
Expand All @@ -78,14 +82,22 @@ class GlossCount:
score = score - 1
elif(sent_value is 'pos'):
score = score + 1
=======
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
>>>>>>> parent of 47c6a2a... Bugfix
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 7b2c04e

Please sign in to comment.