(sorted_words_power, pword_dside, merge_data, word_level=True)
return pword_dside_rate
注意rate是指label=0的可能性，question pair中两侧powerful word越多，power越大，则rate越小
注意rate是指label=0的可能性，question pair中两侧powerful word越多，power越大，则rate越小
注意rate是指label = 0的可能性，question pair中两侧powerful word越多，power越大，则rate越小
def powerful_word_dside_rate(sorted_words_power, pword_dside, merge_data, word_level=True):
    '''
    注意rate是指label=0的可能性，question pair中两侧powerful word越多，power越大，则rate越小
    '''
    num_least = 300
    
    if word_level:
        merge = merge_data[['words_x','words_y']]
    else:
        merge = merge_data[['chars_x','chars_y']]
        
    merge.columns = ['q1','q2']
        
    words_power = dict(sorted_words_power)  #转化为字典格式

    pword_dside_rate = []

    for i in merge.index:
        rate = 1.0    # 指labei=0的可能性,先初始化为1
        q1_words = set(merge.loc[i,'q1'].lower().split())
        q2_words = set(merge.loc[i,'q2'].lower().split())
        share_words = list(q1_words.intersection(q2_words))
        for word in share_words:
            if word in pword_dside:
                rate *= (1.0 - words_power[word][6])    #uestion pair中两侧powerful word越多，power越大，则rate越小
        pword_dside_rate.append(1-rate)
    return pword_dside_rate
def powerful_word_dside_rate ( sorted_words_power , pword_dside , merge_data , word_level = True ) : num_least = 300 if word_level : merge = merge_data [ [ 'words_x' , 'words_y' ] ] else : merge = merge_data [ [ 'chars_x' , 'chars_y' ] ] merge . columns = [ 'q1' , 'q2' ] words_power = dict ( sorted_words_power ) #转化为字典格式 pword_dside_rate = [ ] for i in merge . index : rate = 1.0 # 指labei=0的可能性,先初始化为1 q1_words = set ( merge . loc [ i , 'q1' ] . lower ( ) . split ( ) ) q2_words = set ( merge . loc [ i , 'q2' ] . lower ( ) . split ( ) ) share_words = list ( q1_words . intersection ( q2_words ) ) for word in share_words : if word in pword_dside : rate *= ( 1.0 - words_power [ word ] [ 6 ] ) #uestion pair中两侧powerful word越多，power越大，则rate越小 pword_dside_rate . append ( 1 - rate ) return pword_dside_rate