Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e99175f

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

File tree

Expand file treeCollapse file tree

2 files changed

+4
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-3
lines changed

‎language/classify_text/classify_text_tutorial.py

Copy file name to clipboardExpand all lines: language/classify_text/classify_text_tutorial.py
+2-2Lines 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

Copy file name to clipboardExpand all lines: language/classify_text/classify_text_tutorial_test.py
+2-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.