Skip to content

Commit 0389ec3

Browse files
gguussbusunkim96
authored andcommitted
Updates client library to version 0.23.0 [(#832)](#832)
1 parent 4f63ac3 commit 0389ec3

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

language/snippets/cloud-client/quickstart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_quickstart():
2828
document = language_client.document_from_text(text)
2929

3030
# Detects the sentiment of the text
31-
sentiment = document.analyze_sentiment()
31+
sentiment = document.analyze_sentiment().sentiment
3232

3333
print('Text: {}'.format(text))
3434
print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-language==0.22.2
1+
google-cloud-language==0.23

language/snippets/cloud-client/snippets.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def sentiment_text(text):
3535

3636
# Detects sentiment in the document. You can also analyze HTML with:
3737
# document.doc_type == language.Document.HTML
38-
sentiment = document.analyze_sentiment()
38+
sentiment = document.analyze_sentiment().sentiment
3939

4040
print('Score: {}'.format(sentiment.score))
4141
print('Magnitude: {}'.format(sentiment.magnitude))
@@ -50,7 +50,7 @@ def sentiment_file(gcs_uri):
5050

5151
# Detects sentiment in the document. You can also analyze HTML with:
5252
# document.doc_type == language.Document.HTML
53-
sentiment = document.analyze_sentiment()
53+
sentiment = document.analyze_sentiment().sentiment
5454

5555
print('Score: {}'.format(sentiment.score))
5656
print('Magnitude: {}'.format(sentiment.magnitude))
@@ -65,15 +65,16 @@ def entities_text(text):
6565

6666
# Detects entities in the document. You can also analyze HTML with:
6767
# document.doc_type == language.Document.HTML
68-
entities = document.analyze_entities()
68+
entities = document.analyze_entities().entities
6969

7070
for entity in entities:
7171
print('=' * 20)
7272
print('{:<16}: {}'.format('name', entity.name))
7373
print('{:<16}: {}'.format('type', entity.entity_type))
74-
print('{:<16}: {}'.format('wikipedia_url', entity.wikipedia_url))
7574
print('{:<16}: {}'.format('metadata', entity.metadata))
7675
print('{:<16}: {}'.format('salience', entity.salience))
76+
print('{:<16}: {}'.format('wikipedia_url',
77+
entity.metadata.get('wikipedia_url', '-')))
7778

7879

7980
def entities_file(gcs_uri):
@@ -85,15 +86,16 @@ def entities_file(gcs_uri):
8586

8687
# Detects sentiment in the document. You can also analyze HTML with:
8788
# document.doc_type == language.Document.HTML
88-
entities = document.analyze_entities()
89+
entities = document.analyze_entities().entities
8990

9091
for entity in entities:
9192
print('=' * 20)
9293
print('{:<16}: {}'.format('name', entity.name))
9394
print('{:<16}: {}'.format('type', entity.entity_type))
94-
print('{:<16}: {}'.format('wikipedia_url', entity.wikipedia_url))
9595
print('{:<16}: {}'.format('metadata', entity.metadata))
9696
print('{:<16}: {}'.format('salience', entity.salience))
97+
print('{:<16}: {}'.format('wikipedia_url',
98+
entity.metadata.get('wikipedia_url', '-')))
9799

98100

99101
def syntax_text(text):
@@ -105,7 +107,7 @@ def syntax_text(text):
105107

106108
# Detects syntax in the document. You can also analyze HTML with:
107109
# document.doc_type == language.Document.HTML
108-
tokens = document.analyze_syntax()
110+
tokens = document.analyze_syntax().tokens
109111

110112
for token in tokens:
111113
print('{}: {}'.format(token.part_of_speech, token.text_content))
@@ -120,7 +122,7 @@ def syntax_file(gcs_uri):
120122

121123
# Detects syntax in the document. You can also analyze HTML with:
122124
# document.doc_type == language.Document.HTML
123-
tokens = document.analyze_syntax()
125+
tokens = document.analyze_syntax().tokens
124126

125127
for token in tokens:
126128
print('{}: {}'.format(token.part_of_speech, token.text_content))

0 commit comments

Comments
 (0)