def get_freq_intra_scus(): """ Create a dictionary of <'sen_id' : {frequency_x : count, total_wt}> freq_table = {1:{1:[5, wt], 2:[4, wt], 3:[6, wt]}, 2:{1:[3, wt],2:[3, wt]}}""" freq_table = {} for sen_id,v in best_scus.iteritems(): freq_table[sen_id] = {} scus_list = flatten_lists(v) scu_freq = compute_scu_freq(scus_list) for scu, freq in scu_freq.iteritems(): if freq not in freq_table[sen_id]: freq_table[sen_id][freq] = [1, scu_dict[scu]] else: freq_table[sen_id][freq][0] = freq_table[sen_id][freq][0] + 1 freq_table[sen_id][freq][1] = freq_table[sen_id][freq][1] + scu_dict[scu] return freq_table
def get_freq_intra_scus(): """ Create a dictionary of <'sen_id' : {frequency_x : count, total_wt}> freq_table = {1:{1:[5, wt], 2:[4, wt], 3:[6, wt]}, 2:{1:[3, wt],2:[3, wt]}}""" freq_table = {} for sen_id, v in best_scus.iteritems(): freq_table[sen_id] = {} scus_list = flatten_lists(v) scu_freq = compute_scu_freq(scus_list) for scu, freq in scu_freq.iteritems(): if freq not in freq_table[sen_id]: freq_table[sen_id][freq] = [1, scu_dict[scu]] else: freq_table[sen_id][freq][0] = freq_table[sen_id][freq][0] + 1 freq_table[sen_id][freq][ 1] = freq_table[sen_id][freq][1] + scu_dict[scu] return freq_table
def get_freq_inter_scus(): """Create a dictionary of <frequency_x : [count, total_wt]>""" freq_table = {} inter_scus = [] for sen_id, v in best_scus.iteritems(): scus_list = flatten_lists(v) inter_scus.extend(list(set(scus_list))) scu_freq = compute_scu_freq(inter_scus) for scu, freq in scu_freq.iteritems(): # print scu, freq if freq not in freq_table: freq_table[freq] = [1, scu_dict[scu], scu_dict[scu]] else: freq_table[freq][0] = freq_table[freq][0] + 1 freq_table[freq][1] = freq_table[freq][1] + scu_dict[scu] freq_table[freq][2] = float(freq_table[freq][1]) / float(freq_table[freq][0]) return freq_table
def get_freq_inter_scus(): """Create a dictionary of <frequency_x : [count, total_wt]>""" freq_table = {} inter_scus = [] for sen_id, v in best_scus.iteritems(): scus_list = flatten_lists(v) inter_scus.extend(list(set(scus_list))) scu_freq = compute_scu_freq(inter_scus) for scu, freq in scu_freq.iteritems(): # print scu, freq if freq not in freq_table: freq_table[freq] = [1, scu_dict[scu], scu_dict[scu]] else: freq_table[freq][0] = freq_table[freq][0] + 1 freq_table[freq][1] = freq_table[freq][1] + scu_dict[scu] freq_table[freq][2] = float(freq_table[freq][1]) / float( freq_table[freq][0]) return freq_table