예제 #1
0
def emotion_data_simulation_test(timestamp, query_str=None):
    if query_str:
        rv = app.get('/moodlens/data/global/?query=' + query_str + '&ts=' + str(timestamp))
    else:
        rv = app.get('/moodlens/data/global/?ts=' + str(timestamp))
    rv_data = json.loads(rv.data)
    print rv_data['happy'][1], rv_data['angry'][1], rv_data['sad'][1]
    return rv_data['happy'][1] + rv_data['angry'][1] + rv_data['sad'][1]
예제 #2
0
def emotion_weibos_data_simulation_test(timestamp, query_str=None, emotion=None):
    if emotion:
        if query_str:
            rv = app.get('/moodlens/weibos_data/' + emotion + '/global/?query=' + query_str + '&ts=' + str(timestamp))  
        else:
            rv = app.get('/moodlens/weibos_data/' + emotion + '/global/?ts=' + str(timestamp))
        rv_data = json.loads(rv.data)
        return len(rv_data)
예제 #3
0
def emotion_keywords_data_simulation_test(timestamp, query_str=None, emotion=None):
    if query_str:
        if emotion:
            rv = app.get('/moodlens/keywords_data/global/?query=' + query_str + '&ts=' + str(timestamp) + '&emotion=' + emotion)
        else:
            rv = app.get('/moodlens/keywords_data/global/?query=' + query_str + '&ts=' + str(timestamp))   
    else:
        if emotion:
            rv = app.get('/moodlens/keywords_data/global/?ts=' + str(timestamp) + '&emotion=' + emotion)
        else:
            rv = app.get('/moodlens/keywords_data/global/?ts=' + str(timestamp))
    rv_data = json.loads(rv.data)
    return len(rv_data)
예제 #4
0
def emotion_peaks_calc(happy_list, angry_list, sad_list, ts_list, query_str=None):
    if query_str:
        peak_url = '/moodlens/emotionpeak/?happy=' + ','.join(happy_list) + '&angry=' + ','.join(angry_list) + '&sad=' + ','.join(sad_list) + '&ts=' + ','.join(ts_list) + '&query=' + query_str
    else:
        peak_url = '/moodlens/emotionpeak/?happy=' + ','.join(happy_list) + '&angry=' + ','.join(angry_list) + '&sad=' + ','.join(sad_list) + '&ts=' + ','.join(ts_list)
    rv = app.get(peak_url)
    rv_data = json.loads(rv.data)
    print '#peaks: ', len(rv_data)
예제 #5
0
def emotion_peaks_prepare(query_str=None, total_days=30):
    during = 24 * 3600
    endts = date2ts('2013-03-01 02:00:00')
    happy_list = []
    angry_list = []
    sad_list = []
    ts_list = []
    for i in range(0, total_days):
        endts = endts - during
        if query_str:
            rv = app.get('/moodlens/data/global/?query=' + query_str  + '&ts=' + str(endts))
        else:
            rv = app.get('/moodlens/data/global/?ts=' + str(endts))
        rv_data = json.loads(rv.data)
        if rv_data['happy'][1] + rv_data['angry'][1] + rv_data['sad'][1] > 0:
            t_count = rv_data['happy'][1] + rv_data['angry'][1] + rv_data['sad'][1]
            happy_list.append(str(rv_data['happy'][1]*1.0 / t_count))
            angry_list.append(str(rv_data['angry'][1]*1.0 / t_count))
            sad_list.append(str(rv_data['sad'][1]*1.0 / t_count))
            ts_list.append(str(rv_data['happy'][0] / 1000))
    return happy_list, angry_list, sad_list, ts_list
예제 #6
0
def test_get_single_result(test='None', mid=None):
	print '/showresult_single/' + str(mid) + '/?test=' + test
	rv = app.get('/showresult_single/' + str(mid) + '/?test=' + test)
	print rv.data
예제 #7
0
def test_get_topic_result(test='None'):
	rv = app.get('/showresult/?keyword=两会&test=' + test)
	print rv.data
예제 #8
0
def test_person_basic_info(uid):
    rv = app.get('/profile/person/' + str(uid))
    rv_data = json.loads(rv.data)
    print rv_data
예제 #9
0
def test_person_weibo_count(uid, days_num, m):
    rv = app.get('/profile/person_count/' + str(uid) + '?interval=' + str(days_num) + '&m=' + str(m)) 
    rv_data = json.loads(rv.data)
    print rv_data