Skip to content

Error in NL API, 'Sentiment' object has no attribute 'score' #3208

@PrasenjitGiri

Description

@PrasenjitGiri

Upon executing the following code on GCE & locally I'm getting 'score' not found error locally while it works on GCE.

def analyze_text(text):
    language_client = language.Client()
    document = language_client.document_from_text(text)
    annotations = document.annotate_text(include_sentiment=True)
    print(annotations.sentiment.score)
    print (annotations.sentiment.magnitude)

Only difference I can find is on GCE, the gcloud version is different than the local
GCE gcloud
gcloud --version
Google Cloud SDK 145.0.0
alpha 2017.02.21
app-engine-python 1.9.50
beta 2017.02.21
bq 2.0.24
bq-nix 2.0.24
core 2017.02.21
core-nix 2017.02.21
gcloud
gcloud-deps 2017.02.21
gcloud-deps-linux-x86_64 2017.02.21
gsutil 4.22
gsutil-nix 4.22

Local gcloud
gcloud --version
Google Cloud SDK 148.0.1
bq 2.0.24
bq-nix 2.0.24
core 2017.03.24
core-nix 2016.11.07
gcloud
gcloud-deps 2017.03.17
gcloud-deps-darwin-x86_64 2017.02.21
gsutil 4.23
gsutil-nix 4.19

Debugging locally, the response from NL API consist of polarity property and not score.

image

Metadata

Metadata

Labels

api: languageIssues related to the Cloud Natural Language API API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions