(sorted_words_power, pword_oside, merge_data, word_level=True)
return pword_oside_rate
注意rate是指label=1的可能性，question pair中单侧powerful word越多，power越大，则rate越小
注意rate是指label=1的可能性，question pair中单侧powerful word越多，power越大，则rate越小
注意rate是指label = 1的可能性，question pair中单侧powerful word越多，power越大，则rate越小
def powerful_word_oside_rate(sorted_words_power, pword_oside, merge_data, word_level=True):
    '''
    注意rate是指label=1的可能性，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_oside_rate = []
        
    for i in merge.index:
        rate = 1.0    # 指labei=1的可能性,先初始化为1
        q1_words = set(merge.loc[i,'q1'].lower().split())
        q2_words = set(merge.loc[i,'q2'].lower().split())
        q1_diff = list(set(q1_words).difference(set(q2_words)))
        q2_diff = list(set(q2_words).difference(set(q1_words)))
        all_diff = set(q1_diff + q2_diff)
        for word in all_diff:
            if word in pword_oside:
                rate *= (1.0 - words_power[word][4])    #question pair中单侧powerful word越多，power越大，则rate越小
        pword_oside_rate.append(1-rate)
            
    return pword_oside_rate
def powerful_word_oside_rate ( sorted_words_power , pword_oside , 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_oside_rate = [ ] for i in merge . index : rate = 1.0 # 指labei=1的可能性,先初始化为1 q1_words = set ( merge . loc [ i , 'q1' ] . lower ( ) . split ( ) ) q2_words = set ( merge . loc [ i , 'q2' ] . lower ( ) . split ( ) ) q1_diff = list ( set ( q1_words ) . difference ( set ( q2_words ) ) ) q2_diff = list ( set ( q2_words ) . difference ( set ( q1_words ) ) ) all_diff = set ( q1_diff + q2_diff ) for word in all_diff : if word in pword_oside : rate *= ( 1.0 - words_power [ word ] [ 4 ] ) #question pair中单侧powerful word越多，power越大，则rate越小 pword_oside_rate . append ( 1 - rate ) return pword_oside_rate