简体   繁体   English

检索并在Python配置文件类型中排名?

[英]Retrieve and Rank in Python-Configuration File Type?

I'm using the retrieve_and_rank class in Python from the watson_developer_cloud package. 我正在使用watson_developer_cloud软件包中的Python中的retrieve_and_rank类。

Main question: 主要问题:

In the create_config function, what type of object do we pass in for the config argument? create_config函数中,我们为config参数传递哪种类型的对象? A zip folder? 一个zip文件夹?

I'm using IBM's provided example configuration folder just to test, and when I call 我使用IBM提供的示例配置文件夹只是为了测试,以及在我打电话时

retriever_and_ranker.create_config(MY_ID, CONFIG_NAME, 'blank_example_solr_config.zip')

I get this error: 我收到此错误:

WatsonException: unknown error WatsonException:未知错误

The zipped folder is in the same directory as my code. 压缩文件夹与我的代码位于同一目录中。 What should that last argument be? 最后一个论点应该是什么? I'm wondering why it doesn't recognize the zip file from the string I'm passing in. 我想知道为什么它不能从我传入的字符串中识别出zip文件。

I realized the key was that I was incorrectly passing in a string, as opposed to an open file object. 我意识到关键是我错误地传递了一个字符串,而不是一个打开的文件对象。

You need to use the 您需要使用

with open("file.zip", "rb) as fp:
    ...

as in joe's answer. 如乔的回答。

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

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