
from dao.preference_select import Preference

def preference_select():

    all_list = []
    preference = Preference()
    mean_list = []
    meaning_result = preference.select_meaning()
    for item in meaning_result:
        mean_list.append(item['select_meaning'])
        result = preference.select_sql(item['select_meaning'])
        for data in result:

            all_list.append(data['select_word'])

    preference_one_list = [all_list[1],all_list[5],all_list[10],all_list[15]]
    preference_two_list = [all_list[6], all_list[0], all_list[11], all_list[16]]
    preference_three_list = [all_list[12], all_list[7], all_list[2], all_list[17]]
    preference_four_list = [all_list[18], all_list[8], all_list[13], all_list[3]]
    preference_five_list = [all_list[4], all_list[9], all_list[14], all_list[19]]

    preference_list = [preference_one_list,preference_two_list,preference_three_list,preference_four_list,preference_five_list]

    return preference_list



def preference_meaning(list):
    preference = Preference()
    word_size_list = {}
    word_meaning_list = {}
    word_result = preference.select_word(list)
    for item in word_result:
        if item['select_word'] not in word_size_list:
            word_size_list[item['select_word']] = item['word_size']
            word_meaning_list[item['select_word']] = item['select_meaning']
    # print(word_meaning_list,word_size_list)
    return word_meaning_list,word_size_list

# preference_meaning(['文思海辉', '美的', '跟谁学', '同仁堂'])




