google-cloud-language ValueError: Protocol message Document has no "type" field.
olek-glowka opened this issue · 1 comments
I'm trying to extract named entities from text using Google Cloud Language python package in Python 3.7. When I attempt to run the example named entity extraction Python code from https://cloud.google.com/natural-language/docs/analyzing-entities#language-entities-file-python I get the following error:
ValueError: Protocol message Document has no "type" field.
This is the full stack trace:
File "/Users/user/google/example.py", line 60, in <module>
print(sample_analyze_entities("California is a state."))
File "/Users/user/google/example.py", line 26, in sample_analyze_entities
response = client.analyze_entities(request = {'document': document, 'encoding_type': encoding_type})
File "/Users/user/anaconda3/envs/env/lib/python3.7/site-packages/google/cloud/language_v1/services/language_service/client.py", line 381, in analyze_entities
request = language_service.AnalyzeEntitiesRequest(request)
File "/Users/users/anaconda3/envs/env/lib/python3.7/site-packages/proto/message.py", line 461, in __init__
pb_value = marshal.to_proto(pb_type, value)
File "/Users/user/anaconda3/envs/env/lib/python3.7/site-packages/proto/marshal/marshal.py", line 205, in to_proto
pb_value = rule.to_proto(value)
File "/Users/user/anaconda3/envs/env/lib/python3.7/site-packages/proto/marshal/rules/message.py", line 32, in to_proto
return self._descriptor(**value)
ValueError: Protocol message Document has no "type" field.
The documentation shows that Document
includes a "type" field: https://pub.dev/documentation/googleapis/latest/googleapis.language.v1/Document-class.html
I'm using the most up-to-date versions of google-cloud-language
, setuptools
and protobuf
. The protocol error seems to have something to do with protobuf
, which I am not very familiar with. Has anyone encountered a similar error and knows how to fix it?
Duplicate of #43