currently for smilarity model,i am creating the embeddings for all data at once from…
- User
currently for smilarity model,i am creating the embeddings for all data at once from acsv column,is there any better way to do this
- Assistant
- User
i need to improve accuracy
- Assistant
- User
find all the dates in a string,date can be in any format
- Assistant
- User
i am using date finder and gettig good response for date import datefinder dates = datefinder.find_dates(usertext) for date in dates: print(date)
answer is in the format 2022-01-05 00:00:00 by above mentioned code. I need to mach this date with 05-Jan-2022 this format date and filter all data from a clumn in dataframe where date matches this date
- Assistant
If you're working with Python and have extracted dates using the library and now want to filter a pandas DataFrame for rows matching a specific date in a different format (), you can follow these steps:
- User
after using filtered df like this, def get_most_similar_question(userText,history):
print('aaaaa',userText)
filtered_df = preporcess_input(userText)print('bbbbb',userText)
# if not has_year(userText):
# current_year = datetime.datetime.now().year
# userText+=f"{current_year}"
print('ccccc',userText)
print(userText)
filtered_df['Question'] = filtered_df['Question'].str.lower() print(filtered_df.head()) data_list = filtered_df["Question"].to_list() fin = [re.sub(r'\r\n', '', line) for line in data_list] data_emb = retrieval_model.encode(fin) inp_emb = retrieval_model.encode([userText]) corr = np.inner(inp_emb, data_emb) print(corr) flat_list = [item for sublist in corr for item in sublist]print(flat_list)
top_1_idx = np.argsort(flat_list)[-1:] print('dfdafdv',top_1_idx) top_1_values = [flat_list[i] for i in top_1_idx] print('dffdfdfdd',top_1_values) print("top_1_values",top_1_values[0]) n_data = new_df.iloc[top_1_idx,[10]] print('dfdf',n_data) df_html_with_sql = n_data.to_html(index=False) x = n_data.to_string(header=False, index=False, index_names=False).split('\n') print('ddfd',x) - Assistant
- User
if there is date in usertext then only preprocess the date other wise for all other questions,filter the data with no dates or balnk dates and then return their dataframe and apply similiarity logic on that,if date is wrong or data is not present int he dataframe ,tell user that 'data is not available for this date',put all other boundary conditions as needed
- Assistant
- User
- Assistant
- User
give me complete code
- Assistant
- User
date may or may not part of usertext,if there is no date then there are other questions without date,filter questions without date and do the similarity process same
- Assistant
- User
in date field some dates are not present ,how to filter the,
- Assistant
- User
need check for valid date,invalid date and no date
- Assistant