Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PrasenjitGiri opened this issue Mar 26, 2017 · 2 comments
Closed

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

PrasenjitGiri opened this issue Mar 26, 2017 · 2 comments
Assignees
Labels
api: language Issues related to the Cloud Natural Language API API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@PrasenjitGiri
Copy link

PrasenjitGiri commented Mar 26, 2017

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

@daspecster daspecster added the api: language Issues related to the Cloud Natural Language API API. label Mar 27, 2017
@lukesneeringer lukesneeringer self-assigned this Mar 30, 2017
@lukesneeringer lukesneeringer added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 30, 2017
@PrasenjitGiri
Copy link
Author

So, any idea about this?

@lukesneeringer
Copy link
Contributor

That most likely means that the API is inconsistent. I can make it not KeyError; you will just get a None. I will do that now while I am thinking about it.

lukesneeringer added a commit to lukesneeringer/google-cloud-python that referenced this issue Apr 10, 2017
lukesneeringer added a commit that referenced this issue Apr 11, 2017
richkadel pushed a commit to richkadel/google-cloud-python that referenced this issue May 6, 2017
parthea pushed a commit that referenced this issue Jul 6, 2023
parthea pushed a commit that referenced this issue Sep 22, 2023
…v1 [(#3208)](GoogleCloudPlatform/python-docs-samples#3208)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [google-cloud-bigquery-datatransfer](https://togithub.com/googleapis/python-bigquery-datatransfer) | major | `==0.4.1` -> `==1.0.0` |

---

### Release Notes

<details>
<summary>googleapis/python-bigquery-datatransfer</summary>

### [`v1.0.0`](https://togithub.com/googleapis/python-bigquery-datatransfer/blob/master/CHANGELOG.md#&#8203;100-httpswwwgithubcomgoogleapispython-bigquery-datatransfercomparev041v100-2020-03-04)

[Compare Source](https://togithub.com/googleapis/python-bigquery-datatransfer/compare/v0.4.1...v1.0.0)

##### Features

-   **bigquerydatatransfer:** add `service_account_name` option to transfer configs ([#&#8203;10013](https://www.github.com/googleapis/python-bigquery-datatransfer/issues/10013)) ([9ca090a](https://www.github.com/googleapis/python-bigquery-datatransfer/commit/9ca090af431092bc4286fa4443dd0dc0141f6de6))
-   **bigquerydatatransfer:** undeprecate resource name helper methods; add py2 deprecation warning; bump copyright year to 2020 (via synth) ([#&#8203;10226](https://www.github.com/googleapis/python-bigquery-datatransfer/issues/10226)) ([c0f9cc3](https://www.github.com/googleapis/python-bigquery-datatransfer/commit/c0f9cc398e5558002c79a875809bb6cd1a98a8a4))
-   set release_status to production/stable ([#&#8203;15](https://www.github.com/googleapis/python-bigquery-datatransfer/issues/15)) ([a9c1160](https://www.github.com/googleapis/python-bigquery-datatransfer/commit/a9c1160475dbc327e8cc5da3b5aee3ceaa618bd3))

##### Bug Fixes

-   **bigquery_datatransfer:** deprecate resource name helper methods (via synth) ([#&#8203;9829](https://www.github.com/googleapis/python-bigquery-datatransfer/issues/9829)) ([fc06995](https://www.github.com/googleapis/python-bigquery-datatransfer/commit/fc0699549479cc3e34e217f9e588f5128107ba89))

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Never, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#GoogleCloudPlatform/python-docs-samples).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: language Issues related to the Cloud Natural Language API API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants