Skip to content

Commit 0b3ce25

Browse files
author
Luke Sneeringer
committed
Updates based on @dhermes feedback.
1 parent 4865674 commit 0b3ce25

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

language/google/cloud/language/api_responses.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Classes representing each of the types of responses returned from
16-
the Natural Language API.
17-
"""
15+
"""Response types from the Natural Language API."""
1816

1917
from google.cloud.language.entity import Entity
2018
from google.cloud.language.sentence import Sentence
@@ -76,7 +74,7 @@ def from_api_repr(cls, payload):
7674
"""
7775
return cls(
7876
language=payload.get('language', None),
79-
sentences=[Sentence.from_api_repr(i) for i
77+
sentences=[Sentence.from_api_repr(sentence) for sentence
8078
in payload.get('sentences', ())],
8179
sentiment=Sentiment.from_api_repr(payload['documentSentiment']),
8280
)
@@ -109,8 +107,8 @@ def from_api_repr(cls, payload):
109107
"""
110108
return cls(
111109
language=payload.get('language', None),
112-
sentences=[Sentence.from_api_repr(i) for i in
110+
sentences=[Sentence.from_api_repr(sentence) for sentence in
113111
payload.get('sentences', ())],
114-
tokens=[Token.from_api_repr(i) for i in
112+
tokens=[Token.from_api_repr(token) for token in
115113
payload.get('tokens', ())]
116114
)

language/google/cloud/language/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016-2017 Google Inc.
1+
# Copyright 2016 Google Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

language/google/cloud/language/sentence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def from_api_repr(cls, payload):
5959
# The sentence may or may not have a sentiment; only attempt the
6060
# typecast if one is present.
6161
sentiment = None
62-
if payload.get('sentiment', None):
62+
if payload.get('sentiment', None) is not None:
6363
sentiment = Sentiment.from_api_repr(payload['sentiment'])
6464

6565
# Return a Sentence object.

language/google/cloud/language/sentiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016-2017 Google Inc.
1+
# Copyright 2016 Google Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)