2017-10-28 11 views
1

過去1年で検索しましたが、類似の問題は見つかりませんでした。私はthis tutorialに従おうとしていますが、4月に出版されて以来、変更されているようです。私はPubNubモジュールを構築し、Bluemix Watsonアカウントを登録し、Natural Language Understanding Serviceを設定しました。Bluemix/Watsonナチュラル言語処理無効APIキー

それは私がPubNubでテストパッケージを実行しようとすると、私はエラーが表示されます。

23時24分12秒JS:

[" TypeError: Cannot read property 'type' of undefined at Sentiment/IBM Watson.js:46:43 at process._tickCallback (internal/process/next_tick.js:109:7)"] Error at Sentiment/IBM Watson.js:76:21 at process._tickCallback (internal/process/next_tick.js:109:7)

夜11時24分13秒JS:

{ "body": "{ \"status\": \"ERROR\", \"statusInfo\": \"invalid-api-key\", \"usage\": \"By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\", \"totalTransactions\": \"1\", \"language\": \"unknown\" } 

APIのチュートリアルコードは以下です:

export default (request) => { 
    // url for sentiment analysis api 
    const apiUrl = 'https://gateway-a.watsonplatform.net/calls/text/TextGetTextSentiment'; 

    // api key 
const apiKey = 'Your_API_Key'; 

しかし、チュートリアルが書かれて以来、BluemixのAPIフォーマットが変更されたようです。 Bluemixの資格情報は、形式に今ある:統計電卓としてRを使用してから来て、ちょうど先週、Pythonで彼の最初の(プリミティブ)戦艦ゲームをプログラムし、誰かとして

{ 
    "url": "https://gateway.watsonplatform.net/natural-language-understanding/api", 
    "username": "x", 
    "password": "y" 
} 

は、任意のヘルプははるかに高く評価します!

答えて

1

あなたが見ることができるように:

IBM Bluemix just announced the retirement of the AlchemyAPI service . They say to use instead the Natural Language Understanding service, also under Watson.

自然言語理解がAlchemyAPIのようなAPIキーを使用していません。

enter image description here

ので、JavaScriptで使用自然言語Understadingのために、あなたはAPIリファレンスを追跡する必要があります:

あなたはIBM Bluemix中にあなたのサービスを作成するときは、サービスの資格情報あなたの usernamepasswordで見たことができます
var NaturalLanguageUnderstandingV1 = require('watson-developer-cloud/natural-language-understanding/v1.js'); 
var natural_language_understanding = new NaturalLanguageUnderstandingV1({ 
    'username': '{username}', //Service Credentials 
    'password': '{password}', //Service Credentials 
    'version_date': '2017-02-27' 
}); 

var parameters = { 
    'text': 'IBM is an American multinational technology company headquartered in Armonk, New York, United States, with operations in over 170 countries.', 
    'features': { 
    'entities': { 
     'emotion': true, 
     'sentiment': true, 
     'limit': 2 
    }, 
    'keywords': { 
     'emotion': true, 
     'sentiment': true, 
     'limit': 2 
    } 
    } 
} 

natural_language_understanding.analyze(parameters, function(err, response) { 
    if (err) 
    console.log('error:', err); 
    else 
    console.log(JSON.stringify(response, null, 2)); 
}); 
  • は、あなたがどのようにNLUのAPIの作品を見に公式API Referenceは、Node.jsの
  • Demoを使用して参照してください。 。
  • AlchemyAPIから移行しています。
関連する問題