@@ -94,10 +94,14 @@ def entities_text(text):
94
94
# document.type == enums.Document.Type.HTML
95
95
entities = client .analyze_entities (document ).entities
96
96
97
+ # entity types from enums.Entity.Type
98
+ entity_type = ('UNKNOWN' , 'PERSON' , 'LOCATION' , 'ORGANIZATION' ,
99
+ 'EVENT' , 'WORK_OF_ART' , 'CONSUMER_GOOD' , 'OTHER' )
100
+
97
101
for entity in entities :
98
102
print ('=' * 20 )
99
103
print (u'{:<16}: {}' .format ('name' , entity .name ))
100
- print (u'{:<16}: {}' .format ('type' , entity .type ))
104
+ print (u'{:<16}: {}' .format ('type' , entity_type [ entity .type ] ))
101
105
print (u'{:<16}: {}' .format ('metadata' , entity .metadata ))
102
106
print (u'{:<16}: {}' .format ('salience' , entity .salience ))
103
107
print (u'{:<16}: {}' .format ('wikipedia_url' ,
@@ -120,10 +124,14 @@ def entities_file(gcs_uri):
120
124
# document.type == enums.Document.Type.HTML
121
125
entities = client .analyze_entities (document ).entities
122
126
127
+ # entity types from enums.Entity.Type
128
+ entity_type = ('UNKNOWN' , 'PERSON' , 'LOCATION' , 'ORGANIZATION' ,
129
+ 'EVENT' , 'WORK_OF_ART' , 'CONSUMER_GOOD' , 'OTHER' )
130
+
123
131
for entity in entities :
124
132
print ('=' * 20 )
125
133
print (u'{:<16}: {}' .format ('name' , entity .name ))
126
- print (u'{:<16}: {}' .format ('type' , entity .type ))
134
+ print (u'{:<16}: {}' .format ('type' , entity_type [ entity .type ] ))
127
135
print (u'{:<16}: {}' .format ('metadata' , entity .metadata ))
128
136
print (u'{:<16}: {}' .format ('salience' , entity .salience ))
129
137
print (u'{:<16}: {}' .format ('wikipedia_url' ,
0 commit comments