【问题标题】:Adding custom stopwords to IBM Watson Discovery向 IBM Watson Discovery 添加自定义停用词
【发布时间】:2020-02-27 18:40:22
【问题描述】:

我正在尝试在 Watson Discovery 的集合上添加自定义停用词,但我只收到错误 500“创建‘停用词’时出错。”。在 web 和 api (curl) 上都一样。

我试过了:

我已经检查过 (https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts&locale=en):

  • 高级计划 - 好的
  • 大小限制为一百万个字符 - 好的
  • 每个集合只有一个自定义停用词列表 - 好的
  • 所有停用词都应为小写。 - 好的
  • 删除并创建一个新集合 - 好的

另外,我用无效的集合和环境运行 curl 来检查 api 验证(我知道这是不必要的),它按预期返回 404“找不到列出的集合”(好的,它正在工作)。

我错过了什么吗?我还能检查什么?

卷曲命令:

curl -X POST -u "apikey":"..." --data-binary @custom_stopwords_pt.txt "https://gateway.watsonplatform.net/discovery/api/v1/environments/.../collections/.../word_lists/stopwords?version=2019-04-30"

谢谢

【问题讨论】:

    标签: python text-mining ibm-watson stop-words discovery


    【解决方案1】:

    我正在使用python sdk和以下代码上传自定义停用词列表,发现查询似乎使用自定义停用词并更新搜索查询结果没有任何错误,我什至不需要删除并创建新集合。

    authenticator = IAMAuthenticator('<your api key>')
    discovery = DiscoveryV1(
        version='2020-01-15',
        authenticator=authenticator)
    discovery.set_service_url('<service url>')
    
    # get the writable environment id (as eid) and the collection id (as cid) 
    # where you want to upload the stopwords list
    
    discovery.create_stopword_list(environment_id=eid,
                                   collection_id=cid,
                                   stopword_file=stopwords,
                                   stopword_filename ='custom_stopwords.txt')
    
    # it takes some time to update the sotpword list
    # once it's done, the 'status' returned by the next api should be 'active'
    discovery.get_stopword_list_status(environment_id=eid, 
                                       collection_id=cid).get_result()
    # {'status': 'active', 'type': 'stopwords'}
    

    【讨论】:

    • 桑迪潘,感谢您的回复!几天后,代码工作了。我认为这是 Discovery 团队解决的内部问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多