【发布时间】:2018-05-29 03:32:48
【问题描述】:
在阅读了 Watson API 参考并使用了 Watson Discovery News Demo 之后,我得出了下面的代码,试图复制 IBM Watson Discovery News 演示 [Sentiment Analysis] 可以执行的功能。但不幸的是,我的代码无法获得与演示返回相同的响应。
import json
from watson_developer_cloud import DiscoveryV1
# --- Authentication ----
discovery = DiscoveryV1(
username="581xxxx-5c55-xxxx-983f-027xxxxxxxxx",
password="xxxxxxxxxx",
version="2017-11-07"
)
qopts = {"query": "\"tesla\"",
"filter": "language:(english|en),crawl_date>2017-10-14T12:00:00-
0700,crawl_date<2017-12-14T12:00:00-0800",
"aggregations": [
"term(host).term(enriched_text.sentiment.document.label)",
"term(enriched_text.sentiment.document.label)"
]
}
my_query = discovery.query('system', 'news-en', qopts)
print(json.dumps(my_query, indent=2))
有人可以通过显示可以像 IBM 演示那样执行查询的示例 python 代码来帮助我吗?例如,一个简单的代码可以在给定查询“Tesla”的情况下返回与演示 [Sentiment Analysis] 相同的响应?提前致谢。
【问题讨论】: