Skip to content

Commit

Permalink
updated obidroidMapReduce for reviewid
Browse files Browse the repository at this point in the history
  • Loading branch information
seekshreyas committed May 5, 2014
1 parent 43fb4b0 commit 485c9f3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions mapreduce/obidroidMR.py → obidroidMR.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from mrjob.job import MRJob
# from sentClassifier import sentClassify
# from cPickle import load
from sentClassifier import sentClassify
from cPickle import load
import re
import nltk
# import pattern
from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer
import sys
# import simplejson


Expand Down Expand Up @@ -50,7 +51,7 @@ def getFeatures(rev):
blob = TextBlob(rev, analyzer=NaiveBayesAnalyzer())
blobSent = blob.sentiment

print blobSent
# print blobSent

if blobSent[0] == 'pos':
revSent = 1 * blobSent[1]
Expand Down Expand Up @@ -82,17 +83,22 @@ def getRecord(self, _, record): #Mapper 1

idpattern = re.compile('(\w+\.+\w+[(\.+)(\w+)]+)')

appid = idpattern.split(record[0])
reviewid = record[0]
appid = idpattern.split(record[1])


features = ObidroidReview.getFeatures(record[1])
features = ObidroidReview.getFeatures(record[2])

features.append(appid[1])

yield appid[1], features
sys.stderr.write("MAPPER INPUT: ({0},{1})\n".format(reviewid,features))

yield reviewid, features

def performAction(self,appid,appfeature): #Reducer 1
yield appid, list(appfeature)

def performAction(self,revid,revfeatures): #Reducer 1
sys.stderr.write("MAPPER INPUT: ({0},{1})\n".format(revid,revfeatures))
yield revid, list(revfeatures)



Expand Down

0 comments on commit 485c9f3

Please sign in to comment.