This repository was archived by the owner on Sep 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
samples/snippets/classify_text Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 2727import json
2828import 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
3431import numpy
3532import six
3633# [END classify_text_tutorial_import]
4037def 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
You can’t perform that action at this time.
0 commit comments