Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 534c137

Browse filesBrowse files
gguussJon Wayne Parrott
authored andcommitted
Updates client library to version 0.23.0 (GoogleCloudPlatform#832)
1 parent 5abc938 commit 534c137
Copy full SHA for 534c137

File tree

Expand file treeCollapse file tree

3 files changed

+12
-10
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-10
lines changed

‎language/cloud-client/quickstart.py

Copy file name to clipboardExpand all lines: language/cloud-client/quickstart.py
+1-1Lines 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))
+1-1Lines 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/cloud-client/snippets.py

Copy file name to clipboardExpand all lines: language/cloud-client/snippets.py
+10-8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.