Skip to content

Commit f8bb820

Browse files
authored
chore: update samples to include additional region tags (#14)
* Update samples to include additional region tags. * chore: empty commit
1 parent e165292 commit f8bb820

5 files changed

+12
-0
lines changed

language/v1/language_classify_gcs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def sample_classify_text(gcs_content_uri):
4343

4444
# gcs_content_uri = 'gs://cloud-samples-data/language/classify-entertainment.txt'
4545

46+
# [START language_python_migration_document_gcs]
4647
# Available types: PLAIN_TEXT, HTML
4748
type_ = enums.Document.Type.PLAIN_TEXT
4849

@@ -51,6 +52,7 @@ def sample_classify_text(gcs_content_uri):
5152
# https://cloud.google.com/natural-language/docs/languages
5253
language = "en"
5354
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
55+
# [END language_python_migration_document_gcs]
5456

5557
response = client.classify_text(document)
5658
# Loop through classified categories returned from the API

language/v1/language_classify_text.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def sample_classify_text(text_content):
4141

4242
# text_content = 'That actor on TV makes movies in Hollywood and also stars in a variety of popular new TV shows.'
4343

44+
# [START language_python_migration_document_text]
4445
# Available types: PLAIN_TEXT, HTML
4546
type_ = enums.Document.Type.PLAIN_TEXT
4647

@@ -49,6 +50,7 @@ def sample_classify_text(text_content):
4950
# https://cloud.google.com/natural-language/docs/languages
5051
language = "en"
5152
document = {"content": text_content, "type": type_, "language": language}
53+
# [END language_python_migration_document_text]
5254

5355
response = client.classify_text(document)
5456
# Loop through classified categories returned from the API

language/v1/language_entities_text.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def sample_analyze_entities(text_content):
4141

4242
# text_content = 'California is a state.'
4343

44+
# [START language_python_migration_entities_text]
4445
# Available types: PLAIN_TEXT, HTML
4546
type_ = enums.Document.Type.PLAIN_TEXT
4647

@@ -76,6 +77,7 @@ def sample_analyze_entities(text_content):
7677
print(
7778
u"Mention type: {}".format(enums.EntityMention.Type(mention.type).name)
7879
)
80+
# [END language_python_migration_entities_text]
7981

8082
# Get the language of the text, which will be the same as
8183
# the language specified in the request or, if not specified,

language/v1/language_sentiment_text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def sample_analyze_sentiment(text_content):
4141

4242
# text_content = 'I am so happy and joyful.'
4343

44+
# [START language_python_migration_sentiment_text]
4445
# Available types: PLAIN_TEXT, HTML
4546
type_ = enums.Document.Type.PLAIN_TEXT
4647

@@ -61,6 +62,8 @@ def sample_analyze_sentiment(text_content):
6162
response.document_sentiment.magnitude
6263
)
6364
)
65+
# [END language_python_migration_sentiment_text]
66+
6467
# Get sentiment for all sentences in the document
6568
for sentence in response.sentences:
6669
print(u"Sentence text: {}".format(sentence.text.content))

language/v1/language_syntax_text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def sample_analyze_syntax(text_content):
5050
language = "en"
5151
document = {"content": text_content, "type": type_, "language": language}
5252

53+
# [START language_python_migration_syntax_text]
5354
# Available values: NONE, UTF8, UTF16, UTF32
5455
encoding_type = enums.EncodingType.UTF8
5556

@@ -72,6 +73,8 @@ def sample_analyze_syntax(text_content):
7273
enums.PartOfSpeech.Tag(part_of_speech.tag).name
7374
)
7475
)
76+
# [END language_python_migration_syntax_text]
77+
7578
# Get the voice, e.g. ACTIVE or PASSIVE
7679
print(u"Voice: {}".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))
7780
# Get the tense, e.g. PAST, FUTURE, PRESENT, et al.

0 commit comments

Comments
 (0)