changed language detector streamer

This commit is contained in:
Jonas Weinz 2018-05-28 14:55:43 +02:00
parent c9e182b5fa
commit 7e1af5ac2c

View File

@ -8,10 +8,9 @@ import sys
# other lines are just passing through so that this script can be used in a shell pipeline
for line in fi.input():
s = str.split(line.lstrip(' '), ":")
if s[0] == '"text"':
if line.startswith(' "text"'):
try:
sys.stdout.write(' "lang": "' + detect(s[1]) + '"\n')
sys.stdout.write(' "lang": "' + detect(line[10:]) + '"\n')
except Exception:
sys.stdout.write(' "lang": "NaN"\n')
sys.stdout.write(line)