@@ -94,10 +94,14 @@ def entities_text(text):
9494 # document.type == enums.Document.Type.HTML
9595 entities = client .analyze_entities (document ).entities
9696
97+ # entity types from enums.Entity.Type
98+ entity_type = ('UNKNOWN' , 'PERSON' , 'LOCATION' , 'ORGANIZATION' ,
99+ 'EVENT' , 'WORK_OF_ART' , 'CONSUMER_GOOD' , 'OTHER' )
100+
97101 for entity in entities :
98102 print ('=' * 20 )
99103 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 ] ))
101105 print (u'{:<16}: {}' .format ('metadata' , entity .metadata ))
102106 print (u'{:<16}: {}' .format ('salience' , entity .salience ))
103107 print (u'{:<16}: {}' .format ('wikipedia_url' ,
@@ -120,10 +124,14 @@ def entities_file(gcs_uri):
120124 # document.type == enums.Document.Type.HTML
121125 entities = client .analyze_entities (document ).entities
122126
127+ # entity types from enums.Entity.Type
128+ entity_type = ('UNKNOWN' , 'PERSON' , 'LOCATION' , 'ORGANIZATION' ,
129+ 'EVENT' , 'WORK_OF_ART' , 'CONSUMER_GOOD' , 'OTHER' )
130+
123131 for entity in entities :
124132 print ('=' * 20 )
125133 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 ] ))
127135 print (u'{:<16}: {}' .format ('metadata' , entity .metadata ))
128136 print (u'{:<16}: {}' .format ('salience' , entity .salience ))
129137 print (u'{:<16}: {}' .format ('wikipedia_url' ,
0 commit comments