【问题标题】:how to query watson discovery api?如何查询 Watson Discovery api?
【发布时间】:2018-01-06 03:03:35
【问题描述】:

我正在试验 IBM watsons 的 Discovery API 以获得数据洞察力。我想使用多个过滤器进行查询。我正在使用 python 来完成任务。我现在已经尝试过,但这不起作用。

qopts = {'filter':[{'enriched_text.entities.text:Recurrent Neural 
         Networks,Machine Learning classifiers'}]}
my_query = discovery.query(env_id, coll_id, qopts)

只有单个实体:'recurrent Neural Networks' 通过发现 UI 和我的 python 查询,我从集合中获得 3 个文档。 但是有两个实体,'Recurrent Neural Networks,Machine Learning classifiers',在 UI 中我得到 2 个文档,但通过我的代码,我得到 2 个文档。

【问题讨论】:

    标签: ibm-watson watson watson-discovery


    【解决方案1】:

    在 Watson 发现文档中,在您将使用的 UI 中(根据文档):

    但显然,第二个text 中没有! 运算符。

    我认为在您的代码中,您需要在值之间使用,

    不确定,因为我没有在过滤器中使用enriched_text.entities.text,只使用字符串。

    另一个测试示例的可能参考:

    filter=field1:some value,field2:another value
    

    官方参考文档:here.

    【讨论】:

    • UI 中给出的整个查询,应该作为一个字符串来过滤键。 qopts = {'filter':{'enriched_text.entities.text:fruits','enriched_text.entities.text:others'}}
    • 当然,就像我的“一个可能的参考”哈哈 :) 恭喜
    【解决方案2】:

    下面是适合我的正确格式。使用多个概念和关键字过滤器,我总共得到 2 个搜索结果,与 UI 查询匹配

    qopts = {'filter':{'enriched_text.concepts.text:"Neural network",enriched_text.keywords.text:"Neural Network",enriched_text.keywords.text:"generative conversational models"'}}
    

    只有实体我得到 3 个匹配结果

    qopts = {'filter':{'enriched_text.concepts.text:"Neural network"'}}
    

    在本例中,我使用 concept 'Neural network' 、keywords 'Neural Network' 和 'generation conversational models' 查询文档

    【讨论】:

      猜你喜欢
      • 2018-01-31
      • 2017-10-23
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2017-11-09
      相关资源
      最近更新 更多