如何使用使用python的发现新闻服务从json生成类似IBM的摘要
qopts = {'nested':'(enriched_text.entities)','filter':'(enriched_text.entities.type::Person)','term':'(enriched_text.entities.text,count:10)','filter':'(enriched_text.concepts.text:infosys)','filter':'(enriched_text.concepts.text:ceo)'}
my_query = discovery.query('system', 'news', qopts)
print(json.dumps(my_query, indent=2))此查询是否适合于查找Infosys的首席执行官?输出以大的json格式出现,即我如何识别答案或创建总结,比如前十名ceo或人物。如何使用使用python的发现新闻服务从json生成摘要。我触发查询,然后输出变成大json格式的..how,以从那个json文件中找到适当的摘要,我的查询是否正确
发布于 2017-09-28 03:41:20
我相信这里有两个问题。
natural_language_query参数,如下所示:
qopts ={“自然_语言_查询”:“谁是Infosys的首席执行官?”,“count”:‘5’} response = discovery.query(environment_id='system',collection_id='news',query_options=qopts) print(响应,indent=2)aggregation参数和filter聚合中指定聚合,如下所示:
qopts ={‘聚合’:'nested(enriched_text.entities).filter(enriched_text.entities.type::Person).term(enriched_text.entities.text,count:10‘,'filter':'enriched_text.entities:(text:Infosys,类型:Company)’,‘count’} response = discovery.query(environment_id='system',collection_id='news',query_options=qopts} print(json.dumps(响应,indent=2))注意,聚合是与.符号链接/组合的。
https://stackoverflow.com/questions/46321937
复制相似问题