Skip to content

Commit e6803e2

Browse files
committed
show more of the response
1 parent 8d4274c commit e6803e2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

vision/cloud-client/detect/detect_pdf.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,29 @@ def async_detect_document(gcs_source_uri, gcs_destination_uri):
9292
first_page_response = response.responses[0]
9393

9494
# Print the full text from the first page.
95-
# The response additionally includes individual detected symbol's
96-
# confidence and bounding box.
9795
print(u'Full text:\n{}'.format(
9896
first_page_response.full_text_annotation.text))
9997

98+
# The response additionally includes individual detected symbol's
99+
# confidence and bounding box.
100+
for page in first_page_response.full_text_annotation.pages:
101+
for block in page.blocks:
102+
print('\nBlock confidence: {}\n'.format(block.confidence))
103+
104+
for paragraph in block.paragraphs:
105+
print('Paragraph confidence: {}'.format(
106+
paragraph.confidence))
107+
108+
for word in paragraph.words:
109+
word_text = ''.join([
110+
symbol.text for symbol in word.symbols
111+
])
112+
print(u'Word text: {} (confidence: {})'.format(
113+
word_text, word.confidence))
114+
115+
for symbol in word.symbols:
116+
print(u'\tSymbol: {} (confidence: {})'.format(
117+
symbol.text, symbol.confidence))
100118
# [END vision_async_detect_document_ocr]
101119

102120

0 commit comments

Comments
 (0)