I tried the API published by Recruit Technologies Co., Ltd., which I had been interested in for a while. For the time being, only "Text Suggest API".
On Cloud9 (recent personal trends)
pip install requests
pip install pya3rt
suggest.py
# -*- coding: utf-8 -*-
import pya3rt
apikey = "{Your API Key}"
api = pya3rt.TextSuggestClient(apikey)
pd = "What is Bushido?"
sug_dict = api.text_suggest(previous_description=pd)
print(pd + sug_dict["suggestion"][0])
Well, I played the chords hoping that the famous phrase would be completed. Result is,,,, "Bushido has a big building."
Well, it has become a modern sentence.
When I ran the above code, I got an error for some reason. The details of the error are as follows.
File "/usr/local/lib/python3.5/dist-packages/pya3rt/text_suggest.py", line 17, in request
response = requests.get(endpoint, params)
TypeError: get() takes 1 positional argument but 2 were given
It is said that "there are many get arguments", so when I looked at the corresponding source,
response = requests.get(endpoint, params)
There are certainly many, so I modified it as follows and made it work.
response = requests.get(endpoint, params=params)
https://a3rt.recruit-tech.co.jp/product/textSuggestAPI/
Recommended Posts