【问题标题】:Watson Concept-Insights document list/limit option not working in nodeJSWatson Concept-Insights 文档列表/限制选项在 nodeJS 中不起作用
【发布时间】:2016-05-19 18:34:18
【问题描述】:

我正在使用 Watson Concept-Insights 构建一个新的语料库。到目前为止,我已经使用 nodeJS 创建了大约 100 个文档。如果我使用 curl 列出文档,我可以找到所有文档。但是,当我使用 nodeJS 列出同一组文档时,它始终忽略限制值并返回 20 个文档的默认值。救命!!

基本代码如下(帐户密钥替换为“myAccount”):

 var watson = require('watson-developer-cloud');
 var concept_insights = watson.concept_insights({ yada yada... this all works }

 params = { 'corpus': '/corpora/myAccount/theAdviser', 'limit': 200 };
 concept_insights.corpora.listDocuments(params, function(err,_res) {
    if (err) { console.log(err); }
    else { console.log(JSON.stringify(_res, null, 2)); 
    res.send(JSON.stringify(_res, null, 2)); }
  });

无论为限制选项输入什么值,我总是得到 20 个结果。另一方面,CURL 根据指定的限制返回完整列表或子集。 等效的工作 curl 语句是:

 curl -u "{userID}":"{password}" "https://gateway.watsonplatform.net/concept-insights-beta/api/v2/corpora/myAccount/theAdviser/documents?limit=200"

【问题讨论】:

    标签: node.js ibm-watson concept-insights


    【解决方案1】:

    看起来这是 npm 模块中的疏忽。我刚刚添加了对限制参数的支持,一旦 CI 循环完成,它应该以v1.9.1 的形式发布。

    【讨论】:

    【解决方案2】:

    不幸的是,对于我可以访问的语料库,这似乎无法重现。比如这个卷曲:

    curl -s -u username:password \
    "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/TEDTalks/documents?limit=100"
    

    为我生成一个包含 100 个文档的列表。如果您安装了jq,您可以验证:

    curl -s -u username:password \
    "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/TEDTalks/documents?limit=100" \
    | jq '.[] | length'
    
    100
    

    尝试查看您的语料库的另一种方法是通过单击您的服务实例磁贴(您的应用程序当前正在使用的图标)来检查 Bluemix 中可用的“Concept Insights Dashboard”。仪表板的第一页允许您选择语料库,并报告语料库的高级摘要(包括文档数量)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 2016-08-15
      • 1970-01-01
      • 2018-10-02
      • 2017-01-08
      相关资源
      最近更新 更多