镜像自地址
https://gitee.com/medical-alliance/Medical-nlp.git
已同步 2025-12-06 09:26:47 +00:00
增加百度相似度
这个提交包含在:
22
src/baidu.py
普通文件
22
src/baidu.py
普通文件
@@ -0,0 +1,22 @@
|
||||
from aip import AipNlp
|
||||
from config import Config
|
||||
|
||||
|
||||
def baidu_sim(text1, text2):
|
||||
"""
|
||||
百度词语相似度
|
||||
:param text1: 词语1
|
||||
:param text2: 词语2
|
||||
:return: 相似度
|
||||
"""
|
||||
APP_ID = Config.APP_ID
|
||||
API_KEY = Config.API_KEY
|
||||
SECRET_KEY = Config.SECRET_KEY
|
||||
# options = {}
|
||||
# options["model"] = "CNN"
|
||||
client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
|
||||
result = client.simnet(text1, text2)
|
||||
if "score" in result:
|
||||
return {"score": result['score']}
|
||||
else:
|
||||
return {"error": "error"}
|
||||
在新工单中引用
屏蔽一个用户