Skip to content

Commit

Permalink
local changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seekshreyas committed Jun 5, 2014
1 parent c47273f commit b07709e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
10 changes: 8 additions & 2 deletions appClassifierBenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ def trimDf(df):
cols.remove('price') # considered only free apps
cols.remove('appName') # removing appNames

return df[list(cols)]
# return df[list(cols)]



return df[list(('revSent', 'appLabel'))]



Expand Down Expand Up @@ -245,7 +249,7 @@ def allClassifier(cDf, models, modelchoice):
performClassification(classifier, featVector, labelVector)
else:
if modelchoice in models and modelchoice != 'svm-nl':
classifier = models[choice]
classifier = models[modelchoice]
performClassification(classifier, featVector, labelVector)
else:
print "Incorrect Choice"
Expand Down Expand Up @@ -273,6 +277,8 @@ def main():
appDf = loadAppData(userInput['file'])
appDf = trimDf(appDf)

print appDf.columns

if userInput['sample'] == 'all':
allClassifier(appDf, models, userInput['classifier'])
else:
Expand Down
22 changes: 12 additions & 10 deletions obidroidMR.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from cPickle import load
import re
import nltk
# import pattern
from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer
import sys
# import simplejson
import math


class ObidroidReview(MRJob):
Expand Down Expand Up @@ -51,6 +50,8 @@ def getFeatures(rev):
blob = TextBlob(rev, analyzer=NaiveBayesAnalyzer())
blobSent = blob.sentiment



# print blobSent

if blobSent[0] == 'pos':
Expand All @@ -61,7 +62,7 @@ def getFeatures(rev):
revSent = 0



revSent = round(revSent, 4)

return [
revCharLength,
Expand All @@ -84,21 +85,22 @@ def getRecord(self, _, record): #Mapper 1
idpattern = re.compile('(\w+\.+\w+[(\.+)(\w+)]+)')

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


features = ObidroidReview.getFeatures(record[2])

features.append(appid[1])
features.append(reviewid)

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

yield reviewid, features
yield appid, features


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



Expand Down

0 comments on commit b07709e

Please sign in to comment.