镜像自地址
https://gitee.com/medical-alliance/Medical-nlp.git
已同步 2025-12-06 01:16:47 +00:00
23 行
540 B
Python
23 行
540 B
Python
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"}
|