Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1df320d

Browse filesBrowse files
dizcologyJon Wayne Parrott
authored andcommitted
show entity type name (GoogleCloudPlatform#1062)
* show entity type name * update v1beta2 * correct indent
1 parent 1645bf5 commit 1df320d
Copy full SHA for 1df320d

File tree

Expand file treeCollapse file tree

2 files changed

+20
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-4
lines changed

‎language/cloud-client/v1/snippets.py

Copy file name to clipboardExpand all lines: language/cloud-client/v1/snippets.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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',

‎language/cloud-client/v1beta2/snippets.py

Copy file name to clipboardExpand all lines: language/cloud-client/v1beta2/snippets.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ def entities_text(text):
8585
# document.type == enums.Document.Type.HTML
8686
entities = client.analyze_entities(document).entities
8787

88+
# entity types from enums.Entity.Type
89+
entity_type = ('UNKNOWN', 'PERSON', 'LOCATION', 'ORGANIZATION',
90+
'EVENT', 'WORK_OF_ART', 'CONSUMER_GOOD', 'OTHER')
91+
8892
for entity in entities:
8993
print('=' * 20)
9094
print(u'{:<16}: {}'.format('name', entity.name))
91-
print(u'{:<16}: {}'.format('type', entity.type))
95+
print(u'{:<16}: {}'.format('type', entity_type[entity.type]))
9296
print(u'{:<16}: {}'.format('metadata', entity.metadata))
9397
print(u'{:<16}: {}'.format('salience', entity.salience))
9498
print(u'{:<16}: {}'.format('wikipedia_url',
@@ -108,10 +112,14 @@ def entities_file(gcs_uri):
108112
# document.type == enums.Document.Type.HTML
109113
entities = client.analyze_entities(document).entities
110114

115+
# entity types from enums.Entity.Type
116+
entity_type = ('UNKNOWN', 'PERSON', 'LOCATION', 'ORGANIZATION',
117+
'EVENT', 'WORK_OF_ART', 'CONSUMER_GOOD', 'OTHER')
118+
111119
for entity in entities:
112120
print('=' * 20)
113121
print(u'{:<16}: {}'.format('name', entity.name))
114-
print(u'{:<16}: {}'.format('type', entity.type))
122+
print(u'{:<16}: {}'.format('type', entity_type[entity.type]))
115123
print(u'{:<16}: {}'.format('metadata', entity.metadata))
116124
print(u'{:<16}: {}'.format('salience', entity.salience))
117125
print(u'{:<16}: {}'.format('wikipedia_url',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.