@@ -140,7 +140,7 @@ def process_parse(args: Namespace, client: Client, doc_class) -> None:
140140 parsed_data = input_doc .parse (
141141 doc_class , include_words = args .include_words , page_options = page_options
142142 )
143- display_doc (args .output_type , parsed_data )
143+ display_doc (args .output_type , args . include_words , parsed_data )
144144
145145
146146def process_parse_queued (args : Namespace , client : Client , doc_class ) -> None :
@@ -158,20 +158,25 @@ def process_parse_queued(args: Namespace, client: Client, doc_class) -> None:
158158 document_class = doc_class , queue_id = args .queue_id
159159 )
160160 if parsed_data .job .status == "completed" and parsed_data .document is not None :
161- display_doc (args .output_type , parsed_data .document )
161+ display_doc (args .output_type , args . include_words , parsed_data .document )
162162 else :
163163 print (parsed_data .job )
164164
165165
166- def display_doc (output_type : str , document_response : PredictResponse ):
166+ def display_doc (output_type : str , include_words : bool , response : PredictResponse ):
167167 """Display the parsed document."""
168168 if output_type == "raw" :
169- print (json .dumps (document_response .http_response , indent = 2 ))
169+ print (json .dumps (response .http_response , indent = 2 ))
170170 elif output_type == "parsed" :
171- doc = document_response .document
172- print (json .dumps (doc , indent = 2 , default = serialize_for_json ))
171+ if include_words :
172+ print (json .dumps (response .ocr , indent = 2 , default = serialize_for_json ))
173+ print (json .dumps (response .document , indent = 2 , default = serialize_for_json ))
173174 else :
174- print (document_response .document )
175+ if include_words :
176+ print ("OCR Begin >>>>>>>>>>\n " )
177+ print (response .ocr )
178+ print ("<<<<<<<<<< OCR End\n " )
179+ print (response .document )
175180
176181
177182def process_parse_enqueue (args : Namespace , client : Client , doc_class ) -> None :
0 commit comments