Spaces:
Runtime error
Runtime error
Update consult_func.py
Browse files- consult_func.py +37 -0
consult_func.py
CHANGED
@@ -370,3 +370,40 @@ def keyword(
|
|
370 |
if kmp(text,word)!=-1 and score>=0:
|
371 |
return True
|
372 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
if kmp(text,word)!=-1 and score>=0:
|
371 |
return True
|
372 |
return False
|
373 |
+
|
374 |
+
|
375 |
+
#保存测试数据
|
376 |
+
def save2(username,password,):
|
377 |
+
new_data2=[2,3,4,5.0,'该回答的分数',6,7.0,'该回答的文字',8.0,'该回答的文字','最终建议']
|
378 |
+
if (username=='' or password==''):
|
379 |
+
return '请填写完整信息'
|
380 |
+
|
381 |
+
user_login_df=pd.read_csv('./user_login/login.csv',encoding='gbk',converters = {'password':str})
|
382 |
+
user_login=user_login_df.set_index('username')['password'].T.to_dict()
|
383 |
+
user_data2_df=pd.read_csv('./user_data/data_2.csv',encoding='gbk',converters ={'senti_flt':float,'hobby_flt':float,'all_flt':float})
|
384 |
+
|
385 |
+
results=''
|
386 |
+
is_usn=(username in user_login)
|
387 |
+
if(is_usn):
|
388 |
+
pswd_crct=(password==user_login[username])
|
389 |
+
if(is_usn and pswd_crct):
|
390 |
+
results='登录成功,存储报告成功。'
|
391 |
+
user_data2_df.loc[len(user_data2_df)]=[username,datetime.date.today(),
|
392 |
+
datetime.datetime.now().strftime('%H:%M:%S')]+new_data2
|
393 |
+
user_data2_df.to_csv('./user_data/data_2.csv',encoding='gbk',index=False)
|
394 |
+
elif(is_usn):
|
395 |
+
results='密码错误!'
|
396 |
+
else:
|
397 |
+
user_login_df.loc[len(user_login_df)]=[username,password]
|
398 |
+
user_data2_df.loc[len(user_data2_df)]=[username,datetime.date.today(),
|
399 |
+
datetime.datetime.now().strftime('%H:%M:%S')]+new_data2
|
400 |
+
user_login_df.to_csv('./user_login/login.csv',encoding='gbk',index=False)
|
401 |
+
user_data2_df.to_csv('./user_data/data_2.csv',encoding='gbk',index=False)
|
402 |
+
results='账户不存在,已创建新的账户并保存数据。'
|
403 |
+
|
404 |
+
|
405 |
+
return results
|
406 |
+
|
407 |
+
#从作答项目获取存储内容
|
408 |
+
def get_info():
|
409 |
+
pass
|