Hľadali sme, ale podobné problémy v minulom roku nenájdu. Snažím sa ich sledovať tento návod, ale zdá sa, že sa veci od zverejnenia v apríli zmenili. Vytvoril som moduly PubNub a zaregistroval som si účet Bluemix Watson a zriadil službu Porozumenie prirodzenému jazyku.
Keď sa pokúsim spustiť testovací balík v PubNub, zobrazí sa mi chyba:
23:24:12 js:
["TypeError: Nedá sa prečítať vlastnosť „type“ of undefined at Sentiment / IBM Watson.js: 46: 43 v procese._tickCallback (Internal / process / next_tick.js: 109: 7) "] Chyba v Sentiment / IBM Watson.js: 76: 21 v procese._tickCallback (Vnútorná / proces / 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" }
Výukový kód pre api je tento:
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";
Zdá sa však, že formát API pre Bluemix sa od napísania tutoriálu zmenil. Poverenia spoločnosti Bluemix sú teraz vo formáte:
{
"url": "https://gateway.watsonplatform.net/natural-language-understanding/api",
"username": "x",
"password": "y"
}
Ako niekto, kto pochádza z používania R ako štatistickej kalkulačky a práve naprogramoval svoju prvú (primitívnu) bojovú loď v Pythone minulý týždeň, akákoľvek pomoc sa veľmi ocenila!
odpovede:
1 pre odpoveď č. 1Ako môžeš vidieť:
Spoločnosť IBM Bluemix práve oznámila vyradenie služby AlchemyAPI, Hovoria, že namiesto toho používajú službu Porozumenie prirodzenému jazyku, tiež pod Watsonom.
Pochopenie prirodzeného jazyka nepoužíva API KEY, ako je AlchemyAPI. Keď vytvárate svoju službu v IBM Bluemix, v službe Credentials môžete vidieť svoje username
a password
:
Ak chcete používať program Understruing Natural Language s programom Javascript, musíte postupovať podľa odkazu 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));
});
- Pozri úradníka Odkaz na rozhranie API pomocou Node.js
- demonštrácie aby ste videli, ako funguje rozhranie NLU API.
- Migrácia z AlchemyAPI.