Skip to content

Commit 05c4402

Browse files
authored
fix: adds underscore to "type" to NL API samples (#49)
* fix: adds underscore to "type" in entity sentiment sample * fix: other language samples missing type with underscore
1 parent bd3f41b commit 05c4402

10 files changed

+19
-19
lines changed

language/v1/language_classify_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def sample_classify_text(gcs_content_uri):
4848
# For list of supported languages:
4949
# https://cloud.google.com/natural-language/docs/languages
5050
language = "en"
51-
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
51+
document = {"gcs_content_uri": gcs_content_uri, "type_": type_, "language": language}
5252

5353
response = client.classify_text(request = {'document': document})
5454
# Loop through classified categories returned from the API

language/v1/language_classify_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def sample_classify_text(text_content):
4646
# For list of supported languages:
4747
# https://cloud.google.com/natural-language/docs/languages
4848
language = "en"
49-
document = {"content": text_content, "type": type_, "language": language}
49+
document = {"content": text_content, "type_": type_, "language": language}
5050

5151
response = client.classify_text(request = {'document': document})
5252
# Loop through classified categories returned from the API

language/v1/language_entities_gcs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def sample_analyze_entities(gcs_content_uri):
4747
# For list of supported languages:
4848
# https://cloud.google.com/natural-language/docs/languages
4949
language = "en"
50-
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
50+
document = {"gcs_content_uri": gcs_content_uri, "type_": type_, "language": language}
5151

5252
# Available values: NONE, UTF8, UTF16, UTF32
53-
encoding_type = language_v1..EncodingType.UTF8
53+
encoding_type = language_v1.EncodingType.UTF8
5454

5555
response = client.analyze_entities(request = {'document': document, 'encoding_type': encoding_type})
5656
# Loop through entitites returned from the API
5757
for entity in response.entities:
5858
print(u"Representative name for the entity: {}".format(entity.name))
5959
# Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al
60-
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type).name))
60+
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type_).name))
6161
# Get the salience score associated with the entity in the [0, 1.0] range
6262
print(u"Salience score: {}".format(entity.salience))
6363
# Loop over the metadata associated with entity. For many known entities,
@@ -73,7 +73,7 @@ def sample_analyze_entities(gcs_content_uri):
7373
print(u"Mention text: {}".format(mention.text.content))
7474
# Get the mention type, e.g. PROPER for proper noun
7575
print(
76-
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type).name)
76+
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type_).name)
7777
)
7878

7979
# Get the language of the text, which will be the same as

language/v1/language_entities_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def sample_analyze_entities(text_content):
4646
# For list of supported languages:
4747
# https://cloud.google.com/natural-language/docs/languages
4848
language = "en"
49-
document = {"content": text_content, "type": type_, "language": language}
49+
document = {"content": text_content, "type_": type_, "language": language}
5050

5151
# Available values: NONE, UTF8, UTF16, UTF32
5252
encoding_type = language_v1.EncodingType.UTF8
@@ -58,7 +58,7 @@ def sample_analyze_entities(text_content):
5858
print(u"Representative name for the entity: {}".format(entity.name))
5959

6060
# Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al
61-
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type).name))
61+
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type_).name))
6262

6363
# Get the salience score associated with the entity in the [0, 1.0] range
6464
print(u"Salience score: {}".format(entity.salience))
@@ -77,7 +77,7 @@ def sample_analyze_entities(text_content):
7777

7878
# Get the mention type, e.g. PROPER for proper noun
7979
print(
80-
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type).name)
80+
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type_).name)
8181
)
8282

8383
# Get the language of the text, which will be the same as

language/v1/language_entity_sentiment_gcs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def sample_analyze_entity_sentiment(gcs_content_uri):
4747
# For list of supported languages:
4848
# https://cloud.google.com/natural-language/docs/languages
4949
language = "en"
50-
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
50+
document = {"gcs_content_uri": gcs_content_uri, "type_": type_, "language": language}
5151

5252
# Available values: NONE, UTF8, UTF16, UTF32
5353
encoding_type = language_v1.EncodingType.UTF8
@@ -57,7 +57,7 @@ def sample_analyze_entity_sentiment(gcs_content_uri):
5757
for entity in response.entities:
5858
print(u"Representative name for the entity: {}".format(entity.name))
5959
# Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al
60-
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type).name))
60+
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type_).name))
6161
# Get the salience score associated with the entity in the [0, 1.0] range
6262
print(u"Salience score: {}".format(entity.salience))
6363
# Get the aggregate sentiment expressed for this entity in the provided document.
@@ -77,7 +77,7 @@ def sample_analyze_entity_sentiment(gcs_content_uri):
7777
print(u"Mention text: {}".format(mention.text.content))
7878
# Get the mention type, e.g. PROPER for proper noun
7979
print(
80-
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type).name)
80+
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type_).name)
8181
)
8282

8383
# Get the language of the text, which will be the same as

language/v1/language_entity_sentiment_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def sample_analyze_entity_sentiment(text_content):
4646
# For list of supported languages:
4747
# https://cloud.google.com/natural-language/docs/languages
4848
language = "en"
49-
document = {"content": text_content, "type": type_, "language": language}
49+
document = {"content": text_content, "type_": type_, "language": language}
5050

5151
# Available values: NONE, UTF8, UTF16, UTF32
5252
encoding_type = language_v1.EncodingType.UTF8
@@ -56,7 +56,7 @@ def sample_analyze_entity_sentiment(text_content):
5656
for entity in response.entities:
5757
print(u"Representative name for the entity: {}".format(entity.name))
5858
# Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al
59-
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type).name))
59+
print(u"Entity type: {}".format(language_v1.Entity.Type(entity.type_).name))
6060
# Get the salience score associated with the entity in the [0, 1.0] range
6161
print(u"Salience score: {}".format(entity.salience))
6262
# Get the aggregate sentiment expressed for this entity in the provided document.
@@ -76,7 +76,7 @@ def sample_analyze_entity_sentiment(text_content):
7676
print(u"Mention text: {}".format(mention.text.content))
7777
# Get the mention type, e.g. PROPER for proper noun
7878
print(
79-
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type).name)
79+
u"Mention type: {}".format(language_v1.EntityMention.Type(mention.type_).name)
8080
)
8181

8282
# Get the language of the text, which will be the same as

language/v1/language_sentiment_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def sample_analyze_sentiment(gcs_content_uri):
4747
# For list of supported languages:
4848
# https://cloud.google.com/natural-language/docs/languages
4949
language = "en"
50-
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
50+
document = {"gcs_content_uri": gcs_content_uri, "type_": type_, "language": language}
5151

5252
# Available values: NONE, UTF8, UTF16, UTF32
5353
encoding_type = language_v1.EncodingType.UTF8

language/v1/language_sentiment_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def sample_analyze_sentiment(text_content):
4646
# For list of supported languages:
4747
# https://cloud.google.com/natural-language/docs/languages
4848
language = "en"
49-
document = {"content": text_content, "type": type_, "language": language}
49+
document = {"content": text_content, "type_": type_, "language": language}
5050

5151
# Available values: NONE, UTF8, UTF16, UTF32
5252
encoding_type = language_v1.EncodingType.UTF8

language/v1/language_syntax_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def sample_analyze_syntax(gcs_content_uri):
4747
# For list of supported languages:
4848
# https://cloud.google.com/natural-language/docs/languages
4949
language = "en"
50-
document = {"gcs_content_uri": gcs_content_uri, "type": type_, "language": language}
50+
document = {"gcs_content_uri": gcs_content_uri, "type_": type_, "language": language}
5151

5252
# Available values: NONE, UTF8, UTF16, UTF32
5353
encoding_type = language_v1.EncodingType.UTF8

language/v1/language_syntax_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def sample_analyze_syntax(text_content):
4646
# For list of supported languages:
4747
# https://cloud.google.com/natural-language/docs/languages
4848
language = "en"
49-
document = {"content": text_content, "type": type_, "language": language}
49+
document = {"content": text_content, "type_": type_, "language": language}
5050

5151
# Available values: NONE, UTF8, UTF16, UTF32
5252
encoding_type = language_v1.EncodingType.UTF8

0 commit comments

Comments
 (0)