@@ -166,6 +166,11 @@ def __init__(self, **kwargs):
166
166
self .page_range = kwargs .get ("page_range" , None )
167
167
self .pages = kwargs .get ("pages" , None )
168
168
169
+ def __repr__ (self ):
170
+ return "RecognizedForm(form_type={}, fields={}, page_range={}, pages={})" .format (
171
+ self .form_type , repr (self .fields ), repr (self .page_range ), repr (self .pages )
172
+ )[:1024 ]
173
+
169
174
170
175
class USReceipt (object ): # pylint: disable=too-many-instance-attributes
171
176
"""Extracted fields found on the US sales receipt. Provides
@@ -182,7 +187,7 @@ class USReceipt(object): # pylint: disable=too-many-instance-attributes
182
187
:ivar list[~azure.ai.formrecognizer.USReceiptItem] receipt_items:
183
188
The purchased items found on the receipt.
184
189
:ivar ~azure.ai.formrecognizer.FormField subtotal:
185
- The subtotal found on the receipt.
190
+ The subtotal found on the receipt
186
191
:ivar ~azure.ai.formrecognizer.FormField tax:
187
192
The tax value found on the receipt.
188
193
:ivar ~azure.ai.formrecognizer.FormField tip:
@@ -224,6 +229,17 @@ def __init__(self, **kwargs):
224
229
self .form_type = kwargs .get ("form_type" , None )
225
230
self .receipt_locale = kwargs .get ("receipt_locale" , "en-US" )
226
231
232
+ def __repr__ (self ):
233
+ return "USReceipt(merchant_address={}, merchant_name={}, merchant_phone_number={}, " \
234
+ "receipt_type={}, receipt_items={}, subtotal={}, tax={}, tip={}, total={}, " \
235
+ "transaction_date={}, transaction_time={}, fields={}, page_range={}, pages={}, " \
236
+ "form_type={}, receipt_locale={})" .format (
237
+ repr (self .merchant_address ), repr (self .merchant_name ), repr (self .merchant_phone_number ),
238
+ repr (self .receipt_type ), repr (self .receipt_items ), repr (self .subtotal ), repr (self .tax ),
239
+ repr (self .tip ), repr (self .total ), repr (self .transaction_date ), repr (self .transaction_time ),
240
+ repr (self .fields ), repr (self .page_range ), repr (self .pages ), self .form_type , self .receipt_locale
241
+ )[:1024 ]
242
+
227
243
228
244
class FormField (object ):
229
245
"""Represents a field recognized in an input form.
@@ -263,6 +279,7 @@ def _from_generated(cls, field, value, read_result):
263
279
page_number = value .page if value else None ,
264
280
)
265
281
282
+
266
283
@classmethod
267
284
def _from_generated_unlabeled (cls , field , idx , page , read_result ):
268
285
return cls (
@@ -274,6 +291,11 @@ def _from_generated_unlabeled(cls, field, idx, page, read_result):
274
291
page_number = page ,
275
292
)
276
293
294
+ def __repr__ (self ):
295
+ return "FormField(label_data={}, value_data={}, name={}, value={}, confidence={}, page_number={})" .format (
296
+ repr (self .label_data ), repr (self .value_data ), self .name , repr (self .value ), self .confidence , self .page_number
297
+ )[:1024 ]
298
+
277
299
278
300
class FieldText (FormContent ):
279
301
"""Represents the text that is part of a form field. This includes
@@ -328,6 +350,11 @@ def _from_generated_unlabeled(cls, field, page, read_result):
328
350
text_content = get_elements (field , read_result ) if field .elements else None
329
351
)
330
352
353
+ def __repr__ (self ):
354
+ return "FieldText(page_number={}, text={}, bounding_box={}, text_content={})" .format (
355
+ self .page_number , self .text , self .bounding_box , repr (self .text_content )
356
+ )[:1024 ]
357
+
331
358
332
359
class FormPage (object ):
333
360
"""Represents a page recognized from the input document. Contains lines,
@@ -377,6 +404,11 @@ def _from_generated(cls, read_result):
377
404
lines = [FormLine ._from_generated (line , page = page .page ) for line in page .lines ] if page .lines else None
378
405
) for page in read_result ]
379
406
407
+ def __repr__ (self ):
408
+ return "FormPage(page_number={}, text_angle={}, width={}, height={}, unit={}, tables={}, lines={})" .format (
409
+ self .page_number , self .text_angle , self .width , self .height , self .unit , repr (self .tables ), repr (self .lines )
410
+ )[:1024 ]
411
+
380
412
381
413
class FormLine (FormContent ):
382
414
"""An object representing an extracted line of text.
@@ -411,6 +443,10 @@ def _from_generated(cls, line, page):
411
443
words = [FormWord ._from_generated (word , page ) for word in line .words ] if line .words else None
412
444
)
413
445
446
+ def __repr__ (self ):
447
+ return "FormLine(text={}, bounding_box={}, words={}, page_number={})" .format (
448
+ self .text , self .bounding_box , repr (self .words ), self .page_number
449
+ )[:1024 ]
414
450
415
451
class FormWord (FormContent ):
416
452
"""Represents a word recognized from the input document.
@@ -445,6 +481,11 @@ def _from_generated(cls, word, page):
445
481
page_number = page
446
482
)
447
483
484
+ def __repr__ (self ):
485
+ return "FormWord(text={}, bounding_box={}, confidence={}, page_number={})" .format (
486
+ self .text , self .bounding_box , self .confidence , self .page_number
487
+ )[:1024 ]
488
+
448
489
449
490
class USReceiptType (object ):
450
491
"""The type of the analyzed US receipt and the confidence
@@ -466,6 +507,9 @@ def _from_generated(cls, item):
466
507
type = item .value_string ,
467
508
confidence = item .confidence or 1.0 ) if item else None
468
509
510
+ def __repr__ (self ):
511
+ return "USReceiptType(type={}, confidence={})" .format (self .type , self .confidence )[:1024 ]
512
+
469
513
470
514
class USReceiptItem (object ):
471
515
"""A receipt item on a US sales receipt.
@@ -500,6 +544,11 @@ def _from_generated(cls, items, read_result):
500
544
except AttributeError :
501
545
return []
502
546
547
+ def __repr__ (self ):
548
+ return "USReceiptItem(name={}, quantity={}, price={}, total_price={})" .format (
549
+ repr (self .name ), repr (self .quantity ), repr (self .price ), repr (self .total_price )
550
+ )[:1024 ]
551
+
503
552
504
553
class FormTable (object ):
505
554
"""Information about the extracted table contained on a page.
@@ -517,6 +566,11 @@ def __init__(self, **kwargs):
517
566
self .row_count = kwargs .get ("row_count" , None )
518
567
self .column_count = kwargs .get ("column_count" , None )
519
568
569
+ def __repr__ (self ):
570
+ return "FormTable(cells={}, row_count={}, column_count={})" .format (
571
+ repr (self .cells ), self .row_count , self .column_count
572
+ )[:1024 ]
573
+
520
574
521
575
class FormTableCell (FormContent ):
522
576
"""Represents a cell contained in a table recognized from the input document.
@@ -576,6 +630,13 @@ def _from_generated(cls, cell, page, read_result):
576
630
text_content = get_elements (cell , read_result ) if cell .elements else None
577
631
)
578
632
633
+ def __repr__ (self ):
634
+ return "FormTableCell(text={}, row_index={}, column_index={}, row_span={}, column_span={}, " \
635
+ "bounding_box={}, confidence={}, is_header={}, is_footer={}, page_number={}, text_content={})" .format (
636
+ self .text , self .row_index , self .column_index , self .row_span , self .column_span , self .bounding_box ,
637
+ self .confidence , self .is_header , self .is_footer , self .page_number , repr (self .text_content )
638
+ )[:1024 ]
639
+
579
640
580
641
class CustomFormModel (object ):
581
642
"""Represents a model trained from custom forms.
@@ -621,6 +682,13 @@ def _from_generated(cls, model):
621
682
if model .train_result else None
622
683
)
623
684
685
+ def __repr__ (self ):
686
+ return "CustomFormModel(model_id={}, status={}, created_on={}, last_modified={}, models={}, " \
687
+ "errors={}, training_documents={})" .format (
688
+ self .model_id , self .status , self .created_on , self .last_modified , repr (self .models ),
689
+ repr (self .errors ), repr (self .training_documents )
690
+ )[:1024 ]
691
+
624
692
625
693
class CustomFormSubModel (object ):
626
694
"""Represents a submodel that extracts fields from a specific type of form.
@@ -656,6 +724,11 @@ def _from_generated_labeled(cls, model):
656
724
form_type = "form-" + model .model_info .model_id
657
725
)] if model .train_result else None
658
726
727
+ def __repr__ (self ):
728
+ return "CustomFormSubModel(accuracy={}, fields={}, form_type={})" .format (
729
+ self .accuracy , repr (self .fields ), self .form_type
730
+ )[:1024 ]
731
+
659
732
660
733
class CustomFormModelField (object ):
661
734
"""A field that the model will extract from forms it analyzes.
@@ -685,6 +758,11 @@ def _from_generated_unlabeled(cls, fields):
685
758
) for idx , field_name in enumerate (fields )
686
759
}
687
760
761
+ def __repr__ (self ):
762
+ return "CustomFormModelField(label={}, name={}, accuracy={})" .format (
763
+ self .label , self .name , self .accuracy
764
+ )[:1024 ]
765
+
688
766
689
767
class TrainingDocumentInfo (object ):
690
768
"""Report for an individual document used for training
@@ -717,6 +795,11 @@ def _from_generated(cls, train_result):
717
795
errors = FormRecognizerError ._from_generated (doc .errors )
718
796
) for doc in train_result .training_documents ] if train_result .training_documents else None
719
797
798
+ def __repr__ (self ):
799
+ return "TrainingDocumentInfo(document_name={}, status={}, page_count={}, errors={})" .format (
800
+ self .document_name , self .status , self .page_count , repr (self .errors )
801
+ )[:1024 ]
802
+
720
803
721
804
class FormRecognizerError (object ):
722
805
"""Represents an error that occurred while training.
@@ -733,6 +816,9 @@ def __init__(self, **kwargs):
733
816
def _from_generated (cls , err ):
734
817
return [cls (code = error .code , message = error .message ) for error in err ] if err else []
735
818
819
+ def __repr__ (self ):
820
+ return "FormRecognizerError(code={}, message={})" .format (self .code , self .message )[:1024 ]
821
+
736
822
737
823
class CustomFormModelInfo (object ):
738
824
"""Custom model information.
@@ -762,6 +848,11 @@ def _from_generated(cls, model):
762
848
last_modified = model .last_updated_date_time
763
849
)
764
850
851
+ def __repr__ (self ):
852
+ return "CustomFormModelInfo(model_id={}, status={}, created_on={}, last_modified={})" .format (
853
+ self .model_id , self .status , self .created_on , self .last_modified
854
+ )[:1024 ]
855
+
765
856
766
857
class AccountProperties (object ):
767
858
"""Summary of all the custom models on the account.
@@ -780,3 +871,8 @@ def _from_generated(cls, model):
780
871
custom_model_count = model .count ,
781
872
custom_model_limit = model .limit ,
782
873
)
874
+
875
+ def __repr__ (self ):
876
+ return "AccountProperties(custom_model_count={}, custom_model_limit={})" .format (
877
+ self .custom_model_count , self .custom_model_limit
878
+ )[:1024 ]
0 commit comments