Cloud Natural Language API: Qwik Start(日本語)
Google Cloud Natural Language API を使用すると、ドキュメントやニュース記事、ブログ投稿に含まれる人、場所、イベントなどに関する情報を抽出できます。ソーシャル メディア上のコメントから商品に対するセンチメント(感情)を把握したり、コールセンターやメッセージ アプリに寄せられた消費者の意見から顧客満足度を分析したりすることができます。また、分析を行うためにドキュメントをアップロードすることもできます。
例題
gcloud ml language analyze-entities --content="Michelangelo Caravaggio, Italian painter, is known for 'The Calling of Saint Matthew'."
ミケランジェロ・カラヴァッジョ、イタリアの画家、聖マタイの召命で知られている。ですかね。
{ "entities": [ { "mentions": [ { "text": { "beginOffset": 0, "content": "Michelangelo Caravaggio" }, "type": "PROPER" }, { "text": { "beginOffset": 33, "content": "painter" }, "type": "COMMON" } ], "metadata": { "mid": "/m/020bg", "wikipedia_url": "https://en.wikipedia.org/wiki/Caravaggio" }, "name": "Michelangelo Caravaggio", "salience": 0.82904786, "type": "PERSON" }, { "mentions": [ { "text": { "beginOffset": 25, "content": "Italian" }, "type": "PROPER" } ], "metadata": { "mid": "/m/03rjj", "wikipedia_url": "https://en.wikipedia.org/wiki/Italy" }, "name": "Italian", "salience": 0.13981608, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 56, "content": "The Calling of Saint Matthew" }, "type": "PROPER" } ], "metadata": { "mid": "/m/085_p7", "wikipedia_url": "https://en.wikipedia.org/wiki/The_Calling_of_St_Matthew_(Caravaggio)" }, "name": "The Calling of Saint Matthew", "salience": 0.031136045, "type": "EVENT" } ], "language": "en" }
テキトーに選んだニュースをエンティティ分析
上原浩治投手引退会見ニュースをエンティティ分析
gcloud ml language analyze-entities --content="巨人・上原浩治投手が20日、都内ホテルで引退会見を行った。シーズン序盤、突然の引退発表。会見場には報道陣200人超が詰めかけた。21年間に及んだ現役生活。会見場に上がった上原は冒頭から涙を流し、「本日をもちまして21年間の現役生活を終えたいなと思います」と挨拶すると、「えー…」と声を詰まらせ、目をぬぐった。「これまで自分に関わってもらった人々、方々、みんなに感謝したいと思います、ありがとうございました」と語った。" { "entities": [ { "mentions": [ { "text": { "beginOffset": 0, "content": "巨人" }, "type": "COMMON" }, { "text": { "beginOffset": 9, "content": "上原浩治" }, "type": "PROPER" } ], "metadata": { "mid": "/m/0c9lhg", "wikipedia_url": "https://en.wikipedia.org/wiki/Koji_Uehara" }, "name": "上原浩治", "salience": 0.16061519, "type": "PERSON" }, { "mentions": [ { "text": { "beginOffset": 60, "content": "引退会見" }, "type": "COMMON" } ], "metadata": {}, "name": "引退会見", "salience": 0.140315, "type": "EVENT" }, { "mentions": [ { "text": { "beginOffset": 21, "content": "投手" }, "type": "COMMON" } ], "metadata": {}, "name": "投手", "salience": 0.11305461, "type": "PERSON" }, { "mentions": [ { "text": { "beginOffset": 132, "content": "会見場" }, "type": "COMMON" }, { "text": { "beginOffset": 231, "content": "会見場" }, "type": "COMMON" } ], "metadata": {}, "name": "会見場", "salience": 0.09740271, "type": "EVENT" }, { "mentions": [ { "text": { "beginOffset": 42, "content": "都" }, "type": "COMMON" } ], "metadata": {}, "name": "都", "salience": 0.085483804, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 216, "content": "現役生活" }, "type": "COMMON" }, { "text": { "beginOffset": 333, "content": "現役生活" }, "type": "COMMON" } ], "metadata": {}, "name": "現役生活", "salience": 0.071077295, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 48, "content": "ホテル" }, "type": "COMMON" } ], "metadata": {}, "name": "ホテル", "salience": 0.06548602, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 255, "content": "上原" }, "type": "PROPER" } ], "metadata": {}, "name": "上原", "salience": 0.048504733, "type": "PERSON" }, { "mentions": [ { "text": { "beginOffset": 108, "content": "突然" }, "type": "PROPER" } ], "metadata": {}, "name": "突然", "salience": 0.04439941, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 117, "content": "引退発表" }, "type": "COMMON" } ], "metadata": {}, "name": "引退発表", "salience": 0.038837597, "type": "EVENT" }, { "mentions": [ { "text": { "beginOffset": 87, "content": "シーズン" }, "type": "COMMON" } ], "metadata": {}, "name": "シーズン", "salience": 0.038837597, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 147, "content": "報道陣" }, "type": "COMMON" } ], "metadata": {}, "name": "報道陣", "salience": 0.026602311, "type": "EVENT" }, { "mentions": [ { "text": { "beginOffset": 264, "content": "冒頭" }, "type": "COMMON" } ], "metadata": {}, "name": "冒頭", "salience": 0.015536341, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 276, "content": "涙" }, "type": "COMMON" } ], "metadata": {}, "name": "涙", "salience": 0.015536341, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 420, "content": "声" }, "type": "COMMON" } ], "metadata": {}, "name": "声", "salience": 0.013333881, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 441, "content": "目" }, "type": "COMMON" } ], "metadata": {}, "name": "目", "salience": 0.013333881, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 510, "content": "人々" }, "type": "COMMON" } ], "metadata": {}, "name": "人々", "salience": 0.011643294, "type": "PERSON" }, { "mentions": [ { "text": { "beginOffset": 30, "content": "20" }, "type": "TYPE_UNKNOWN" } ], "metadata": { "value": "20" }, "name": "20", "salience": 0.0, "type": "NUMBER" }, { "mentions": [ { "text": { "beginOffset": 156, "content": "200" }, "type": "TYPE_UNKNOWN" } ], "metadata": { "value": "200" }, "name": "200", "salience": 0.0, "type": "NUMBER" }, { "mentions": [ { "text": { "beginOffset": 192, "content": "21" }, "type": "TYPE_UNKNOWN" } ], "metadata": { "value": "21" }, "name": "21", "salience": 0.0, "type": "NUMBER" }, { "mentions": [ { "text": { "beginOffset": 318, "content": "21" }, "type": "TYPE_UNKNOWN" } ], "metadata": { "value": "21" }, "name": "21", "salience": 0.0, "type": "NUMBER" } ], "language": "ja" }
テキトーに選んだニュースをエンティティ感情分析
引数を analyze-entity-sentiment にしてみたが、面白い結果にならなかった。使い方が悪い?
$ gcloud ml language analyze-entity-sentiment --content="巨人・上原浩治投手が20日、都内ホテルで引退会見を行った。シーズン序盤、突然の引退発表。会見場には報道陣200人超が詰めかけた。21年間に及んだ現役生活。会見場に上がった上原は冒頭から涙を流し、「本日をもちまして21年間の現役生活を終えたいなと思います」と挨拶すると、「えー…」と声を詰まらせ、目をぬぐった。「これまで自分に関わってもらった人々、方々、みんなに感謝したいと思います、ありがとうございました」と語った。" { "entities": [ { "mentions": [ { "sentiment": { "magnitude": 0.0, "score": 0.0 }, "text": { "beginOffset": 0, "content": "巨人" }, "type": "COMMON" }, { "sentiment": { "magnitude": 0.0, "score": 0.0 }, "text": { "beginOffset": 9, "content": "上原浩治" }, "type": "PROPER" } ], "metadata": { "mid": "/m/0c9lhg", "wikipedia_url": "https://en.wikipedia.org/wiki/Koji_Uehara" }, "name": "上原浩治", "salience": 0.16061519, "sentiment": { "magnitude": 0.0, "score": 0.0 }, "type": "PERSON" }, { "mentions": [ { "sentiment": { "magnitude": 0.0, "score": 0.0 }, "text": { "beginOffset": 60, "content": "引退会見" }, "type": "COMMON" } ], "metadata": {}, "name": "引退会見", "salience": 0.140315, "sentiment": { "magnitude": 0.0, "score": 0.0 }, "type": "EVENT" }, :