-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b21c61c
commit 90e3307
Showing
2 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters