Help us understand the problem. What is going on with this article?

rails でWatson APIを使ってみる。(personality insights編)

More than 3 years have passed since last update.

rails でWatson APIを実装する方法です。

1 IBM Watson Developer Cloudに登録する。

Watson API を使う為にはIBMが提供しているDeveloper Cloudに登録し、
使いたい機能のユーザーIDとパスワードを取得する必要があります。
https://www.ibm.com/watson/developercloud/
Personality Insights の場合、サービス資格情報の表示よりユーザーnameとパスワードを控えてください。

2 rails で使ってみる。

コードを書く前にgemのインストールをしてください。

gem  "watson-api-client"
controller.rb
require 'watson-api-client'
service = WatsonAPIClient::PersonalityInsights.new(:user=>ENV["user_name"],
                                                   :password=>ENV["user_pass"],
                                                   :verify_ssl=>OpenSSL::SSL::VERIFY_NONE)
    data = service.profile(
      'version'          => "2016-10-20",
      'Content-Type'     => "text/plain",
      'Accept'           => "application/json",
      'Accept-Language'  => "ja",
      'Content-Language' => "ja",
      'body'             => '検証したい文章')
      '結果' =  JSON.parse(data.body)

こんな感じで検証結果を取得することができます。

補足

取得した結果を可視化する方法もまとめました。
http://qiita.com/takuya-kodama/items/04702209478982a7e0e1

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした