[PYTHON] Play with A3RT (Text Suggest)

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".

environment

On Cloud9 (recent personal trends)

Installation

pip install requests
pip install pya3rt

Sample code

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.

Somehow it got stuck

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)

Official website

https://a3rt.recruit-tech.co.jp/product/textSuggestAPI/

Recommended Posts

Play with A3RT (Text Suggest)
Play with Prophet
Play with PyTorch
Play with 2016-Python
Play with CentOS 8
Play with Pyramid
Play with Fathom
Play with Othello (Reversi)
Text mining with Python-Scraping-
Let's play with 4D 4th
Let's play with Amedas data-Part 1
Play with reinforcement learning with MuZero
Play with push notifications with imap4lib
Play around with Linux partitions
Let's play with Amedas data-Part 4
Play with Jupyter Notebook (IPython Notebook)
[Python] Play with Discord's Webhook.
Play RocketChat with API / Python
Let's play with Amedas data-Part 3
Let's play with Amedas data-Part 2
Play with ASE MD module
Text sentiment analysis with ML-Ask
Play with numerical calculation of magnetohydrodynamics
Play with a turtle with turtle graphics (Part 1)
GOTO in Python with Sublime Text 3
Make ASCII art with deep learning
Text extraction with AWS Textract (Python3.6)
Play with Poincare series and SymPy
Text mining with Python ① Morphological analysis
Enable Python raw_input with Sublime Text 3
Let's play with Excel with Python [Beginner]
Easy GUI app with Tkinter Text
Play with Pythonista UI implementation [Action implementation]
Play with PIR sensor module [DSUN-PIR]
Play around with Linux partitions ~ Continued ~
Speak Japanese text with OpenJTalk + python
Spark play with WSL anaconda jupyter (2)
Play with Turtle on Google Colab
Play with demons because it's setsubun