简体   繁体   English

IBM Watson自然语言理解-请求错误太多

[英]IBM Watson Natural Language Understanding - Too Many Request Error

I am using IBM Watson Natural Language Understanding Service via Node SDK for Text Analysis. 我正在通过Node SDK使用IBM Watson Natural Language了解服务进行文本分析。 I have an Array of sentences with length nearly 20 to 30. When I tried to iterate through the Array and Call NLU Analyze API I am getting Error : Too Many Request . 我有一个长度约为20到30的句子数组。当我尝试遍历数组并调用NLU Analyze API时,出现Error : Too Many Request

There is no API available for Bulk process of text analysis and I don't see any limit in NLU Service Documentation. 没有用于批量文本分析的API,NLU服务文档中没有任何限制。 I am using Standard Plan. 我正在使用标准计划。

Is there any way to get rid of this error? 有什么办法可以摆脱这个错误? I want to analyze an Array of sentences. 我想分析一个句子数组。

Error Log : 错误日志:

Error: Too Many Requests
at Request._callback (/home/vcap/app/node_modules/watson-developer-cloud/lib/requestwrapper.js:99:21)
at Request.self.callback (/home/vcap/app/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/home/vcap/app/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/vcap/app/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Update: 更新:

Adding Source Code : 添加源代码:

segmentList.forEach((segment) => {
    var params = {
        text: segment,
        features: {
            keywords: {
                sentiment: false
            },
            sentiment: {
                document: true
            }
        }
    };
    logger.info("Analyse Segment : " + segment);
    return new Promise((resolve) => {
        NLUService.analyze(params, (err, data) => {
            if (err != null) {
                logger.error(err.stack);
            }
            ctr += 1;
            // Inserting data.sentiment.document.score to Database   
            .
            .
            .           
            if (ctr == callSegments.length)
                resolve();
        });
    }).then(() => resolve());
});

From what I know after using the Natural Language Understanding service, there seems to be a limitation of 20 concurrent requests. 据我了解,使用自然语言理解服务后,似乎限制了20个并发请求。

You need to make sure you don't send more than 20 requests at the same time. 您需要确保同时发送的请求不超过20个。 If you look at this blog post you will see some patterns of how you can run N promises in parallel. 如果查看此博客文章,您将看到一些如何并行运行N promise的模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM