I am learning google natural language API by following a sample python code, and running the same in google colab, however, I am getting below error..
# Create the document
document = {
"type_": "PLAIN_TEXT",
"language": "en",
"content": "Hello World. I love you! I hate you!"
}
results = client.analyze_sentiment(
document = document,
encoding_type = language_v1.EncodingType.UTF8)
And I am getting below error
AttributeError Traceback (most recent call last)
<ipython-input-26-17157fa1dfc4> in <module>()
8 results = client.analyze_sentiment(
9 document = document,
---> 10 encoding_type = language_v1.EncodingType.UTF8)
AttributeError: module 'google.cloud.language_v1' has no attribute 'EncodingType'
This seems a straight forward error but after trying different options, like removing encoding_type, it still does not work
I have found root cause. There are 2 issues in the sample code: