gpt4 book ai didi

python - 如何更深入地了解 Watson Discovery Service 中文档摄取失败的原因

转载 作者:行者123 更新时间:2023-11-30 22:33:48 29 4
gpt4 key购买 nike

我正在使用 watson_developer_cloud python 库的 DiscoveryV1 模块将 700 多个文档提取到 WDS 集合中。每次我尝试批量摄取时,许多文档都无法摄取,这是不确定的,通常大约有 100 个文档失败。

每次调用 discovery.add_document(env_id, Cold_id, file_info=file_info) 时,我都会发现响应包含 WDS document_id。对语料库中的所有文档进行此调用后,我使用相应的 document_id 来调用 discovery.get_document(env_id, col_id, doc_id) 并检查文档的状态。其中大约 100 个调用将返回状态文档无法摄取和索引。失败的文件没有规律可循,它们的大小各不相同,并且文件类型有 msword (doc) 和 pdf。

我提取文档的代码是基于 WDS Documentation 编写的,它看起来像这样:

with open(f_path) as file_data:
if f_path.endswith('.doc') or f_path.endswith('.docx'):
re = discovery.add_document(env_id, col_id, file_info=file_data, mime_type='application/msword')
else:
re = discovery.add_document(env_id, col_id, file_info=file_data)

因为我的语料库相对较大,大小约为 3GB,所以我收到来自 discovery.add_document(env_id, Cold_id, file_info=file_info) 的 Service is busyprocessing... 响应 code> 调用,在这种情况下我调用 sleep(5) 并重试。

我已经用尽了 WDS 文档,但没有任何运气。如何更深入地了解这些文件未能被摄取的原因?

最佳答案

您应该能够使用 https://watson-api-explorer.mybluemix.net/apis/discovery-v1#!/Queries/queryNotices API 用于查看提取期间发生的错误/警告以及可能提供有关提取失败原因的更多信息的详细信息。

不幸的是,在发布本文时,Python SDK 似乎还没有包装此 API 的方法,因此您可以使用 Watson Discovery Tooling或使用curl直接查询API(将{}中的值替换为您的集合特定值)

curl -u "{username}:{password}" "https://gateway.watsonplatform.net/discovery/api/v1/environments/{environment_id}/collections/{collection_id}/notices?version=2017-01-01

关于python - 如何更深入地了解 Watson Discovery Service 中文档摄取失败的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45036604/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com