Skip to content

Commit

Permalink
committing map reduce code
Browse files Browse the repository at this point in the history
  • Loading branch information
seekshreyas committed May 1, 2014
1 parent b21c61c commit 90e3307
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
37 changes: 20 additions & 17 deletions obidroidMR.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
from mrjob.job import MRJob
from sentClassifier import sentClassify
# from mrjob.protocol import JSONValueProtocol,RawValueProtocol
import os
from cPickle import load



class ObidroidReview(MRJob):
# INPUT_PROTOCOL = RawValueProtocol

@staticmethod
def getFeatures(rev):
revsent = sentClassify(rev)
revLength = len(rev)


return [revsent, revLength]

def sentiment(review): #helper
return review

def wordcount(review): #helper
return review

def reviewLength(review): #helper
review = review.split(" ")
return len(review)


def getRecord(self, _, record): #Mapper 1
record = record.split(',')
def getFeatures(rev):
sent = sentClassify(rev)

return sent

features = getFeatures(record[1])
appid = record[0]
features = ObidroidReview.getFeatures(record[1])


yield appid, features


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





def steps(self):
return [
self.mr(mapper=self.getRecord, reducer=self.performAction)
]



if __name__ == '__main__':

ObidroidReview.run()
1 change: 1 addition & 0 deletions sentClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def tokenizeReviewsBySentence(revStr):




def getReviewSentiment(tknRevs, classifier):
revAggSentiment = 0

Expand Down

0 comments on commit 90e3307

Please sign in to comment.