IBM Watson/Natural Language Classifier(NLC)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
**サンプル [#lf21d7b3]
*** コマンドラインからcurlで [#lb9cf529]
$ curl -G -u "xxx":"yyy" \ <- BluemixのID/PASSでなくて...
"https://gateway.watsonplatform.net/natural-langua...
--data-urlencode "text=起動してください"
{
"classifier_id" : "xxxxxxxxxxxx-nlc-yyyyyy",
"url" : "https://gateway.watsonplatform.net/natural-la...
"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...
password: watson_config.password, <- BluemixのID/PASS...
version: 'v1'
});
nlc.classify({
text: q,
classifier_id: watson_config.classifier_id <- curlサ...
}, 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 + "...
}
});
**関連リンク [#gf7d0ac0]
-[[IBM Watsonを用いて(日本語)自然言語のクラス分類を行っ...
終了行:
**サンプル [#lf21d7b3]
*** コマンドラインからcurlで [#lb9cf529]
$ curl -G -u "xxx":"yyy" \ <- BluemixのID/PASSでなくて...
"https://gateway.watsonplatform.net/natural-langua...
--data-urlencode "text=起動してください"
{
"classifier_id" : "xxxxxxxxxxxx-nlc-yyyyyy",
"url" : "https://gateway.watsonplatform.net/natural-la...
"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...
password: watson_config.password, <- BluemixのID/PASS...
version: 'v1'
});
nlc.classify({
text: q,
classifier_id: watson_config.classifier_id <- curlサ...
}, 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 + "...
}
});
**関連リンク [#gf7d0ac0]
-[[IBM Watsonを用いて(日本語)自然言語のクラス分類を行っ...
ページ名: