**サンプル [#lf21d7b3]
*** コマンドラインからcurlで [#lb9cf529]

 $ curl -G -u "xxx":"yyy" \   <- BluemixのID/PASSでなくて APIのソレ。
       "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/xxxxxxxxxxxx-nlc-yyyyyy/classify" \
       --data-urlencode "text=起動してください"

 {
   "classifier_id" : "xxxxxxxxxxxx-nlc-yyyyyy",
   "url" : "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/xxxxxxxxxxxx-nlc-yyyyyy",
   "text" : "起動してください",
   "top_class" : "起動する",
   "classes" : [ {
     "class_name" : "起動する",
     "confidence" : 0.9873605411650144
   }, {
     "class_name" : "起動はしない",
     "confidence" : 0.007393229915454663
   }, {
     "class_name" : "停止する",
     "confidence" : 0.002815870295385915
   }, {
     "class_name" : "停止はしない",
     "confidence" : 0.0024303586241447507
   } ]




*** Node.js から SDKで。 [#hfce02e1]


 "use strict";
 
 const q = 'サーバを起動してください';
 
 const config = require('config');
 const watson_config = config.watson;
 
 const watson = require('watson-developer-cloud');
 
 const nlc = watson.natural_language_classifier({
   username: watson_config.username, <- BluemixのID/PASSでなくて APIのソレ。
   password: watson_config.password, <- BluemixのID/PASSでなくて APIのソレ。
   version: 'v1'
 });
 
 nlc.classify({
   text: q, 
   classifier_id: watson_config.classifier_id  <- curlサンプルでいう xxxxxxxxxxxx-nlc-yyyyyy のこと
 }, function (err, response) {
   if (err) {
     console.log('error:', err);
   } else {
     console.log("入力値: " + response.text);
     const confidence = response.classes[0].confidence;
     if (confidence > 0.95) {
       console.log("認識されました!");
     } else if (confidence > 0.90) {
       console.log("決定的じゃないけどコレかも?");
     } else {
       console.log("よく分からんけど一番近いのはコレ");
     }
     console.log("[" + response.classes[0].class_name + "]  信頼度: " + response.classes[0].confidence);
   }
 });


**関連リンク [#gf7d0ac0]
-[[IBM Watsonを用いて(日本語)自然言語のクラス分類を行ってみた - Qiita>http://qiita.com/shinji1105/items/78640e3516b5ae040a2f]]
Natural Language Classifier(NLC)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS