8000 Fix classify text tutorial · johnmanong/python-docs-samples@e99175f · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit e99175f

Browse files
author
Jon Wayne Parrott
committed
Fix classify text tutorial
Change-Id: I7d133862f2e9305c978ec6fb4c8168640f3d08ed
1 parent d770cb5 commit e99175f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

language/classify_text/classify_text_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def index(path, index_file):
8686
categories = classify(text, verbose=False)
8787

8888
result[filename] = categories
89-
except:
89+
except Exception:
9090
print('Failed to process {}'.format(file_path))
9191

9292
with io.open(index_file, 'w') as f:
93-
f.write(unicode(json.dumps(result)))
93+
f.write(json.dumps(result).encode('utf-8'))
9494

9595
print('Texts indexed in file: {}'.format(index_file))
9696
return result

language/classify_text/classify_text_tutorial_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
import os
1515

16-
import classify_text_tutorial
1716
import pytest
1817

18+
import classify_text_tutorial
19+
1920

2021
OUTPUT = 'index.json'
2122
RESOURCES = os.path.join(os.path.dirname(__file__), 'resources')

0 commit comments

Comments
 (0)
0