[英]Bluemix / Watson Natural Language Processing invalid API Key
已搜索,但找不到过去一年中的类似问题。 我正在尝试遵循本教程,但自 4 月发布以来,情况似乎发生了变化。 我已经构建了 PubNub 模块并注册了一个 Bluemix Watson 帐户并设置了一个自然语言理解服务。
当我尝试在 PubNub 中运行测试包时,收到错误消息:
23:24:12 js:
[“类型错误:无法在情绪/IBM Watson.js:46:43 at process._tickCallback (internal/process/next_tick.js:109:7)”处读取未定义的属性“类型”] 情绪/IBM Watson.js 中的错误:76:21 在 process._tickCallback (internal/process/next_tick.js:109:7)
23: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 凭证现在采用以下格式:
{
"url": "https://gateway.watsonplatform.net/natural-language-understanding/api",
"username": "x",
"password": "y"
}
作为一个使用 R 作为统计计算器并且上周刚刚用 Python 编写他的第一个(原始)战舰游戏的人,非常感谢任何帮助!
如你看到的:
IBM Bluemix 刚刚宣布 停用 AlchemyAPI 服务。 他们说改用自然语言理解服务,也在 Watson 下。
自然语言理解不像 AlchemyAPI 那样使用 API KEY。 当您在 IBM Bluemix 中创建您的服务时,您可以在服务凭证中看到您的username
和password
:
因此,要在 Javascript 中使用 Natural Language Understading,您需要遵循 API 参考:
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));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.