[Qiita x COTOHA API present plan] Let's analyze text with COTOHA API! I found a project, so I will summarize how to use the COTOHA API and the result of actually summarizing the old story using the COTOHA API. I did.
See About the COTOHA API for more information.
To use the COTOHA API, you must first register for an account in order to obtain the information required to use the API. Click the "New Registration" button at the top right of the COTOHA API Site to move to the email address registration screen. Register your account from the URL in the email that comes after you register your email address. After completing the account registration, log in from the Login screen. When you log in, you will see two items in the "for Developers Account Information" table: "Client ID" and "Client secret". These are the information you need to use the COTOHA API.
Colaboratory is a Jupyter notebook environment that runs entirely in the cloud. No settings are required and you can use it for free. With Colaboratory, you can write and execute code, store and share analyzes, access powerful computing resources, and more, all for free from your browser.
You can use Google Colaboratory if you have a Google account.
When you open Google Colaboratory, first select File → New Notebook from the menu to create a new notebook.
Next, copy the code from this article.
Replace only the following parts with your own "Client ID" and "Client secret" that were displayed when you logged in earlier.
client_id = "Client ID"
client_secret = "Client secret"
After copying the code, press the ▷ button to execute the code.
If you want to add a code, press "+ code".
Since it's a big deal, I tried to summarize various old stories using the summary API of the COTOHA API.
The summary API receives a sentence composed of multiple sentences written in Japanese as input, calculates the importance of this sentence for each sentence, and gives a score. Then, it returns important sentences according to the number of summary sentences specified at the time of input. This API will be provided as a beta version. https://api.ce-cotoha.com/contents/reference/apireference.html
I borrowed the text of the old story from the following site. http://hukumusume.com/douwa/pc/jap/index.html
The program code is below.
cotoha_call("summary", "Once upon a time, an old man and an old woman lived in a certain place. ~~~")
"Momotaro-san, Momotaro-san. Where are you going?" "I'm going to Onigashima to get rid of the demons." "Then let me accompany you." "Okay, I understand. Then I'll do the best millet dumplings in Japan, so follow me." In this way, the dog received a millet dumpling and joined Momotaro's companion.
Kintaro's friends are mountain animals. Among the animals, there were big bears, cows, horses and deer, but Kintaro is the only one. "Tug of war also wins Kintaro!" Kintaro is a very strong man, but he is not only strong but also a very kind boy.
Please take your time. " Mr. Urashima was guided to the hall of Ryugu. "By the way, Otohime-sama said. When you open this Tamatebako," time "will come back.
The grandfather and grandmother asked God because they had no children. A demon also came to this. "Please say,'Get your back, get your back,' as if my back were stretched." The princess gladly shook her head.
What a gentle girl you notice. Then my daughter started to take the opportunity again. "Hey, grandfather.
"Grandfather, what's wrong?" "The raccoon dog, the raccoon dog, ran away like this for her grandmother." "Oh, that bad raccoon dog. "Raccoon dog. I made a boat, so let's go fishing in the sea." "That's good.
Please lend me your white eagle. " The greedy grandfather forcibly took Shiro to the field. However, only stones come out, and no treasure comes out. "Let's make dead trees bloom.
Yeah! ···Yup? this is! When the grandfather cut the bamboo, there was a little girl inside. Among them, there were five particularly enthusiastic young people. There is no more Muko-san. " Kaguya Hime, who does not intend to go to her bride, decided to refuse, but if she goes against Mikado, she may be killed.
I'll hide me. " So the father and mother mice went to the clouds. Would you like to have Chuko as your bride? " "I'm happy, but the wind is stronger than I am. "The strongest wall in the world.
Somehow, I think it's a summary. The summary is still in beta, so I'm looking forward to the official version.
Recommended Posts