def getSentimentProb_FromEV(wordList, textList): sentimentVal = dict() sentimentProb = dict() sentiWordIndex = dict() for words in wordList: sentimentProb[words] = [0.0, 0.0] sentimentVal[words] = [0.0, 0.0] sentiWordIndex[words] = [] keyword = wordList [sentimentVal, countAll] = Ev.EvalSentiment(textList, keyword) for i in range(len(sentimentVal)): sentimentProb[wordList[i]] = [ sentimentVal[wordList[i]][0] / float(100.0), sentimentVal[wordList[i]][1] / float(100.0) ] print sentimentProb return sentimentProb
sentimentProbGen = {} for word in sentimentHistogram.keys(): if ((sentimentHistogram[word][0] == 0.0) & (sentimentHistogram[word][1] == 0.0)): sentimentProbGen[word] = [0.5, 0.5] else: sumVal = sum(sentimentHistogram[word]) sentimentProbGen[word] = [ (sentimentHistogram[word][0] / float(sumVal)), (sentimentHistogram[word][1] / float(sumVal)) ] #Sentiment based Evaluation: #keyword=['bjp', 'congress', 'modi', 'rahul', 'gandhi', 'aap']; keyword = pModel.keys() [SentimentScoreALLText, countAll] = Ev.EvalSentiment(textList, keyword) [SentimentScoreMRS, countMRS] = Ev.EvalSentiment(summTweetMRS, keyword) [SentimentScoreRS, countRS] = Ev.EvalSentiment(textListsummRS, keyword) [SentimentScoreLR, countLR] = Ev.EvalSentiment(summLexRank, keyword) #print "LDA starts" #final.ldafinal(textList) #w = printtopics.printtopics1('Actual') #final.ldafinal(summTweetMRS) #x = printtopics.printtopics1('MRS') #final.ldafinal(textListsummRS) #y = printtopics.printtopics1('RS') #final.ldafinal(summLexRank) #z = printtopics.printtopics1('LR') #print "LDA done finally" #ft = open('topics.csv','w')