diff --git a/language/classify_text/classify_text_tutorial.py b/language/classify_text/classify_text_tutorial.py index 5d793f50ee4..1ac9e0acb7b 100644 --- a/language/classify_text/classify_text_tutorial.py +++ b/language/classify_text/classify_text_tutorial.py @@ -27,10 +27,7 @@ import json import os -from google.cloud import language_v1beta2 -from google.cloud.language_v1beta2 import enums -from google.cloud.language_v1beta2 import types - +from google.cloud import language import numpy import six # [END classify_text_tutorial_import] @@ -40,11 +37,11 @@ def classify(text, verbose=True): """Classify the input text into categories. """ - language_client = language_v1beta2.LanguageServiceClient() + language_client = language.LanguageServiceClient() - document = types.Document( + document = language.types.Document( content=text, - type=enums.Document.Type.PLAIN_TEXT) + type=language.enums.Document.Type.PLAIN_TEXT) response = language_client.classify_text(document) categories = response.categories @@ -90,7 +87,7 @@ def index(path, index_file): print('Failed to process {}'.format(file_path)) with io.open(index_file, 'w', encoding='utf-8') as f: - f.write(json.dumps(result)) + f.write(json.dumps(result, ensure_ascii=False)) print('Texts indexed in file: {}'.format(index_file)) return result