Commit af31c91a authored by 于飞's avatar 于飞

敏感词加载修改---多添加一个接口

parent b2a61834
......@@ -32,15 +32,15 @@ async def get_spacy_keywords(dialogue: ConversationVo = Body(), auth: Auth = Dep
print('----------------begin---------------->')
# 从数据库中加载 并且初始化敏感词-->到内存中
await mydfafiter.parse_from_db(auth.db)
# await mydfafiter.parse_from_db(auth.db)
#先判断敏感词
dfa_result, is_sensitive = mydfafiter.filter(dialogue.user_input, "*")
dfa_result, is_sensitive,matched_sensitives = mydfafiter.filter(dialogue.user_input, "*")
print(dfa_result)
if is_sensitive:
print('用户输入有敏感词')
result = {'code': 200, 'message': 'success', 'data': [{'type': 3, 'word_name': '111', 'is_sensitive': 1, 'user_input':dfa_result}]}
result = {'code': 200, 'message': 'success', 'data': [{'type': 3, 'word_name': matched_sensitives, 'is_sensitive': 1, 'user_input':dfa_result}]}
return SuccessResponse(result) #返回type=3
#没有敏感词的时候,查找是否有相关图片 或者 视频
......@@ -86,6 +86,12 @@ async def get_spacy_keywords(dialogue: ConversationVo = Body(), auth: Auth = Dep
print(f"-----没有找到需要查询的内容:---->")
return ErrorResponse("没有找到需要查询的内容")
@router.get("/load_parse_from_db", summary="加载敏感词")
async def load_parse_from_db(auth: Auth = Depends(OpenAuth())):
# 从数据库中加载 并且初始化敏感词-->到内存中
await mydfafiter.parse_from_db(auth.db)
return SuccessResponse("sensitive load OK")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment