from search import *

def getsearchinfo(filename):
    filepath=os.path.join(data_file_path,filename)
    df=readFile(filepath)
    return df

def skusinfo(skus):
    skuinfo_change_info=concatSql(skuinfo_sql,**{"sku_no":skus})
    df=execmysl(119,skuinfo_change_info)
    print(df[['sku_no','sku_name']])
    return df[['sku_no','sku_name']]

def dealCustomSearch(word,isrigth=1):
    '''
    :param word: 自定义搜索词，慎用，这块只适合搜索词结果为空的情况
    :param isrigth:
    :return:
    '''
    if isrigth:
        sku_change_info=skuinfo_sql+'like'+'%'+word+'%'
    else:
        sku_change_info=skuinfo_sql+'not like'+'%'+word+'%'
    return sku_change_info

def compareresult(skuname,word):
    pass



def score(filename):
    search_df=getsearchinfo(filename)
    for search in search_df.itertuples():
        search_result_skus=search.__getattribute__('seaech_result')
        search_df['skunames']=skusinfo(search_result_skus)['sku_name'].to_list()
    return search_df

if __name__ == '__main__':
    filename="searchinfo.xlsx"
    t=score(filename)
    print(t)
    #print(t[['skunames',"search_word"]])

