Skip to content

Commit

Permalink
chore: update samples to include additional region tags (#14)
Browse files Browse the repository at this point in the history
* Update samples to include additional region tags.

* chore: empty commit
  • Loading branch information
jsimonweb authored Mar 16, 2020
1 parent c135a01 commit b35c7f4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def sample_classify_text(gcs_content_uri):

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

# [START language_python_migration_document_gcs]
# Available types: PLAIN_TEXT, HTML
type_ = enums.Document.Type.PLAIN_TEXT

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

response = client.classify_text(document)
# Loop through classified categories returned from the API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def sample_classify_text(text_content):

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

# [START language_python_migration_document_text]
# Available types: PLAIN_TEXT, HTML
type_ = enums.Document.Type.PLAIN_TEXT

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

response = client.classify_text(document)
# Loop through classified categories returned from the API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def sample_analyze_entities(text_content):

# text_content = 'California is a state.'

# [START language_python_migration_entities_text]
# Available types: PLAIN_TEXT, HTML
type_ = enums.Document.Type.PLAIN_TEXT

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

# Get the language of the text, which will be the same as
# the language specified in the request or, if not specified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def sample_analyze_sentiment(text_content):

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

# [START language_python_migration_sentiment_text]
# Available types: PLAIN_TEXT, HTML
type_ = enums.Document.Type.PLAIN_TEXT

Expand All @@ -61,6 +62,8 @@ def sample_analyze_sentiment(text_content):
response.document_sentiment.magnitude
)
)
# [END language_python_migration_sentiment_text]

# Get sentiment for all sentences in the document
for sentence in response.sentences:
print(u"Sentence text: {}".format(sentence.text.content))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def sample_analyze_syntax(text_content):
language = "en"
document = {"content": text_content, "type": type_, "language": language}

# [START language_python_migration_syntax_text]
# Available values: NONE, UTF8, UTF16, UTF32
encoding_type = enums.EncodingType.UTF8

Expand All @@ -72,6 +73,8 @@ def sample_analyze_syntax(text_content):
enums.PartOfSpeech.Tag(part_of_speech.tag).name
)
)
# [END language_python_migration_syntax_text]

# Get the voice, e.g. ACTIVE or PASSIVE
print(u"Voice: {}".format(enums.PartOfSpeech.Voice(part_of_speech.voice).name))
# Get the tense, e.g. PAST, FUTURE, PRESENT, et al.
Expand Down

0 comments on commit b35c7f4

Please sign in to comment.