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 6f0f4f9

Browse filesBrowse files
dizcologyJon Wayne Parrott
authored andcommitted
update to use v1 client (GoogleCloudPlatform#1216)
* update to use v1 client * set ensure_ascii=False
1 parent ee9fb33 commit 6f0f4f9
Copy full SHA for 6f0f4f9

File tree

Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed

‎language/classify_text/classify_text_tutorial.py

Copy file name to clipboardExpand all lines: language/classify_text/classify_text_tutorial.py
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import json
2828
import os
2929

30-
from google.cloud import language_v1beta2
31-
from google.cloud.language_v1beta2 import enums
32-
from google.cloud.language_v1beta2 import types
33-
30+
from google.cloud import language
3431
import numpy
3532
import six
3633
# [END classify_text_tutorial_import]
@@ -40,11 +37,11 @@
4037
def classify(text, verbose=True):
4138
"""Classify the input text into categories. """
4239

43-
language_client = language_v1beta2.LanguageServiceClient()
40+
language_client = language.LanguageServiceClient()
4441

45-
document = types.Document(
42+
document = language.types.Document(
4643
content=text,
47-
type=enums.Document.Type.PLAIN_TEXT)
44+
type=language.enums.Document.Type.PLAIN_TEXT)
4845
response = language_client.classify_text(document)
4946
categories = response.categories
5047

@@ -90,7 +87,7 @@ def index(path, index_file):
9087
print('Failed to process {}'.format(file_path))
9188

9289
with io.open(index_file, 'w', encoding='utf-8') as f:
93-
f.write(json.dumps(result))
90+
f.write(json.dumps(result, ensure_ascii=False))
9491

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.