Example #1
0
def bjp_inc(request):
    '''
	...test1 = pd.read_csv("/home/sumeet/Desktop/DATATEST/BJP/bjpt.csv") 
	test1['pol'] = test1['Text'].apply(sentiment_func)
	test1['sentiment'] = test1['pol'].apply(polarity_func)
	targets_test1 = test1.sentiment.apply(sentiment2target)
	X_train, X_test1, y_train, y_test = getTrainingAndTestDataBJP(targets_test1)
	X_test1 = processTweets( X_test1)
	#x=clf.score(X_test,y_test)
	y_pred1 = clf.predict(X_test1)
	test1['Predictions']=y_pred1
	neg_c1=test1.loc[test1.Predictions == -1, 'Predictions'].count()
	pos_c1=test1.loc[test1.Predictions == 1, 'Predictions'].count()
	neu_c1=test1.loc[test1.Predictions == 0, 'Predictions'].count()
	
	test2 = pd.read_csv("/home/sumeet/Desktop/DATATEST/CONGRESS/congt.csv") 
	test2['pol'] = test2['Text'].apply(sentiment_func)
	test2['sentiment'] = test2['pol'].apply(polarity_func)
	targets_test2 = test2.sentiment.apply(sentiment2target)
	X_train, X_test2, y_train, y_test = getTrainingAndTestDataCON(targets_test2)
	X_test2 = processTweets( X_test2)
	#x=clf.score(X_test,y_test)
	y_pred2 = clf.predict(X_test2)
	test2['Predictions']=y_pred2
	neg_c2=test2.loc[test2.Predictions == -1, 'Predictions'].count()
	pos_c2=test2.loc[test2.Predictions == 1, 'Predictions'].count()
	neu_c2=test2.loc[test2.Predictions == 0, 'Predictions'].count()

	plot(neu_c1,neg_c1,pos_c1,neu_c2,neg_c2,pos_c2,"Bharatiya Janata Party","Indian National Congress")...
	'''
    neu_c1, neg_c1, pos_c1, neu_c2, neg_c2, pos_c2, pis1, nis1, pis2, nis2 = viewsshort(
        1, 2)

    posts = [{
        'pos': pos_c1,
        'neg': neg_c1,
        'neu': neu_c1,
        'pis': pis1,
        'nis': nis1
    }, {
        'pos': pos_c2,
        'neg': neg_c2,
        'neu': neu_c2,
        'pis': pis2,
        'nis': nis2
    }]
    context = {'posts': posts}
    return render(request, 'blog/res.html', context)
Example #2
0
def bjp_ncp(request):

    neu_c1, neg_c1, pos_c1, neu_c2, neg_c2, pos_c2, pis1, nis1, pis2, nis2 = viewsshort(
        1, 3)

    posts = [{
        'pos': pos_c1,
        'neg': neg_c1,
        'neu': neu_c1,
        'pis': pis1,
        'nis': nis1
    }, {
        'pos': pos_c2,
        'neg': neg_c2,
        'neu': neu_c2,
        'pis': pis2,
        'nis': nis2
    }]
    context = {'posts': posts}
    return render(request, 'blog/res.html', context)