我的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']
错误输出
开始主题检测。回溯(最近一次通话最后):
文件“./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)
http_response 中的文件“/usr/lib/python2.7/urllib2.py”,第 523 行
'http', request, response, code, msg, hdrs)
文件“/usr/lib/python2.7/urllib2.py”,第 448 行,错误
return self._call_chain(*args)
_call_chain 中的文件“/usr/lib/python2.7/urllib2.py”,第 382 行
result = func(*args)
http_error_default 中的文件“/usr/lib/python2.7/urllib2.py”,第 531 行
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#主题检测 API