ENSAE-CKW/nlp_understanding

fct de print la heatmap

Closed this issue · 1 comments

a regler quand exemple plus petit que threshold

Before :

def reshape_token_to_plot(text, heatmap, threshold= 10):
    num_token= len(text)
    token_adjusted= None
    heatmap_adjusted= None

    if num_token >= threshold:
        # easy case : 80 // 40 = 2 ==> 40*2==80 = true
        entire_part= num_token // threshold
    ....
    ....
    ....

Correction :

def reshape_token_to_plot(text, heatmap, threshold= 10):
    num_token= len(text)
    token_adjusted= None
    heatmap_adjusted= None

    if num_token < threshold:
        diff_size= threshold - num_token
        text= text + ["" for i in range(diff_size)]
        heatmap= np.array(heatmap.tolist() + [0 for i in range(diff_size)])

    # easy case : 80 // 40 = 2 ==> 40*2==80 = true
    entire_part= num_token // threshold
    ....
    ....
    ....