我正在通过遵循示例 python 代码来学习谷歌自然语言 API,并在谷歌 colab 中运行相同的代码,但是,我遇到了错误。
# 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)
而且我得到以下错误
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'
这似乎是一个直截了当的错误,但在尝试了不同的选项后,比如删除 encoding_type,它仍然不起作用