2017-03-06 2 views
0

meine rawdata.json DateiNicht in der Lage Ausgabeergebnis von Microsoft Textanalyse-Thema Anerkennung

{"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" 
]} 

i lesen Sie diese Datei in meinem Modul

file_path = '/home/sujith/pylzdata/rawdata.json' 
f = open(file_path, 'r') 
input_texts = f.read() 

und dieses

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'] 

Fehler Ausgabe zu erhalten

Startethemenerkennung. Traceback (jüngste Aufforderung zuletzt):

File "./lzdata.py", Zeile 25, in

response_headers = urllib2.urlopen(req).info() 

File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen

return _opener.open(url, data, timeout) 

File "/usr/lib/python2.7/urllib2.py", Linie 410, in offener

response = meth(req, response) 

Datei „/ usr/lib/pyt hon2.7/urllib2.py“, Linie 523, in http_response

'http', request, response, code, msg, hdrs) 

File "/usr/lib/python2.7/urllib2.py", Zeile 448, in Fehler

return self._call_chain(*args) 

Datei "/usr/lib/python2.7/urllib2.py", Linie 382, ​​in _call_chain

result = func(*args) 

File "/usr/lib/python2.7/urllib2.py", Linie 531, in http_error_default

raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) 

urllib2.HTTPError: HTTP-Fehler 400: Bad Request

Quellen: 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

Antwort