1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【作業メモ】Google CloudのNatural Language APIでさっくりエンティティ分析

Last updated at Posted at 2023-08-31

はじめに

APIのお勉強として、コマンドプロンプトからNatural Language API叩いて文章内のエンティティを抽出してもらう。
gcloudコマンドは既に使える状態なので、そこら辺の話は割愛。

ドキュメントは以下

1. APIを有効化する

Google Cloudコンソールの[APIとサービス] → [ライブラリ]から「Cloud Natural Language API」を有効化する。

image.png

image.png

2. API叩く

--contentは自由に書き換えてどうぞ

gcloud ml language analyze-entities --content="I like to write a shell script."

こんな感じで返ってくるよ

{
  "entities": [
    {
      "mentions": [
        {
          "text": {
            "beginOffset": 18,
            "content": "shell script"
          },
          "type": "COMMON"
        }
      ],
      "metadata": {},
      "name": "shell script",
      "salience": 1.0,
      "type": "WORK_OF_ART"
    }
  ],
  "language": "en"
}

おわりに

とりあえずAPI何かしら叩いてみたかったので試した
レスポンスの項目の意味調べるのが次回の宿題かな

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?