123456789101112131415161718192021222324252627 |
- # encoding:utf-8
- import requests
- def assess_token():
- # client_id 为官网获取的AK, client_secret 为官网获取的SK
- host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=orZUHE5R2gTiPzzY1X4cRaqi&client_secret=48ObBtvIoYNWdFQ8RTZGR6DsQq9VLBpb'
- response = requests.get(host)
- if response:
- return response.json()
- def similarity(assess_token):
- url = 'https://aip.baidubce.com/rpc/2.0/nlp/v2/simnet?charset=UTF-8&access_token=' + assess_token
- body = {
- "text_1": "张斌仁",
- "text_2": "张斌",
- "model": "CNN"
- }
- response = requests.post(url, json=body)
- if response:
- print(response.json())
- if __name__ == '__main__':
- # print(assess_token())
- similarity('24.2b77398439546b3a983e9b93b84dbe14.2592000.1610182288.282335-23131081')
|