【发布时间】:2017-03-06 21:17:18
【问题描述】:
我的rawdata.json 文件
{"Inputs":[
{"Id":"1","Text":"I loved the food at this restaurant"},
{"Id":"2","Text":"I loved the food at sadthis restaurant"},
{"Id":"3","Text":"I loved the food at tsadhis restaurant"},
......,
{"Id":"100","Text":"I hated the decor"}
],
"StopPhrases":[
"restaurant", “visitor"
]}
我在我的模块中读取了这个文件
file_path = '/home/sujith/pylzdata/rawdata.json'
f = open(file_path, 'r')
input_texts = f.read()
还有这个
print('Starting topic detection.')
uri = base_url + 'text/analytics/v2.0/topics'
req = urllib2.Request(uri, input_texts, headers)
response_headers = urllib2.urlopen(req).info()
uri = response_headers['operation-location']
错误输出
开始主题检测。 Traceback(最近一次调用最后一次):
文件“./lzdata.py”,第 25 行,在
response_headers = urllib2.urlopen(req).info()
文件“/usr/lib/python2.7/urllib2.py”,第 127 行,在 urlopen 中
return _opener.open(url, data, timeout)
文件“/usr/lib/python2.7/urllib2.py”,第 410 行,打开
response = meth(req, response)
文件“/usr/lib/python2.7/urllib2.py”,第 523 行,在 http_response 中
'http', request, response, code, msg, hdrs)
文件“/usr/lib/python2.7/urllib2.py”,第 448 行,出错
return self._call_chain(*args)
文件“/usr/lib/python2.7/urllib2.py”,第 382 行,在 _call_chain 中
result = func(*args)
文件“/usr/lib/python2.7/urllib2.py”,第 531 行,在 http_error_default 中
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP 错误 400: 错误请求
来源:https://text-analytics-demo.azurewebsites.net/Home/SampleCode、https://docs.microsoft.com/en-us/azure/machine-learning/machine-learning-apps-text-analytics#topic-detection-apis
【问题讨论】:
标签: python-2.7 azure-hub text-analytics-api