Exemplo n.º 1
0
def party_burstiness(features, weeks, party, dic_tweets):
    bt = Burst()
    b_index = dict()
    for f in features:
        qtd_r = list()
        qtd_d = list()
        for w in range(1, weeks + 1):
            party_week = party + "_" + str(w)
            if party_week in dic_tweets:
                qtd_r.append(dic_tweets[party_week][f])
                qtd_d.append(sum(dic_tweets[party_week].values()))
            else:
                qtd_r.append(0)
                qtd_d.append(0)
        r = np.array(qtd_r)
        d = np.array(qtd_d)
        n = len(r)
        q, d, r, p = bt.burst_detection(r, d, n, 2, 1, 2)
        bursts = bt.enumerate_bursts(q, 'burstLabel')
        b_index[f] = bursts
    return b_index