def predictEmotion(tweet, fs, model):
    vectors = []
    vector = Mix_IG.vectorize(fs, tweet)
    vectors.append(vector)
    labels = [0]

    m_happy, p_acc, p_happy = svm_predict(labels, vectors, happy_model, '-b 1')
    m_sad, p_acc, p_sad = svm_predict(labels, vectors, sad_model, '-b 1')
    m_angry, p_acc, p_angry = svm_predict(labels, vectors, angry_model, '-b 1')
    m_ashamed, p_acc, p_ashamed = svm_predict(labels, vectors, ashamed_model, '-b 1')
    m_afraid, p_acc, p_afraid = svm_predict(labels, vectors, afraid_model, '-b 1')
	
    tempZ = []
    tempZ.append(p_angry[0][1])
    tempZ.append(p_happy[0][1])
    tempZ.append(p_sad[0][1])	
    tempZ.append(p_ashamed[0][1])
    tempZ.append(p_afraid[0][0])
	
    print max(tempZ)
	
    if(max(tempZ)<0.6):
    	return "neutral"

    m, p_acc, p_vals = predict(labels, vectors, model)

    map = {1 : "happy", 0 : "angry", 2 : "sad", 3 : "ashamed", 4 : "afraid"}

    return map[m[0]]
import crawler
sys.path.append('/Users/oliverfengpet/Program/nlp/python_parser/no_index/libsvm-3.12/python/')
sys.path.append('/Users/oliverfengpet/Dropbox/TwitterAffect/liblinear-1.93/python')
from svmutil import *
from liblinearutil import *
# define (url -> python) mapping in urls.py

 # (r'^$', index.print_welcome)
 # http://127.0.0.1:8000/
happy_model = svm_load_model('libsvm_SVC_stem_emoticons_Happy.model')
sad_model = svm_load_model('libsvm_SVC_stem_emoticons_Sad.model')
ashamed_model = svm_load_model('libsvm_SVC_stem_emoticons_Ashamed.model')
angry_model = svm_load_model('libsvm_SVC_stem_emoticons_Angry.model')
afraid_model = svm_load_model('libsvm_SVC_stem_emoticons_Afraid.model')
model = load_model('libsvm_SVC_Mix.model')
bi = Mix_IG.load_bi("IG_Bigram.txt")
fs = Mix_IG.create_feature_space_IG(bi)
def print_welcome(request):
    html = "<html>" + get_style() + \
           "<body><div id=\"wrapper\">" \
           "CIS630 Project 2 - Twitter Affect" + \
           "<br>Tao Feng Shang CC le ya!" + \
           "<br><a href=\"crawler\">See Random Tweets Classification</a>" \
           "</div></body></html>"

    return HttpResponse(html)


#  (r'^crawler/$', index.print_crawling)
#   http://127.0.0.1:8000/crawler/