File tree Expand file tree Collapse file tree 8 files changed +32
-22
lines changed Expand file tree Collapse file tree 8 files changed +32
-22
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class ListFieldValueV1(FieldPositionMixin):
99
1010 content : str
1111 """The content text"""
12- confidence : float = 0.0
12+ confidence : float
1313 """Confidence score"""
1414
1515 def __init__ (self , raw_prediction : StringDict ) -> None :
@@ -24,7 +24,7 @@ def __str__(self) -> str:
2424class ListFieldV1 :
2525 """A list of values or words."""
2626
27- confidence : float = 0.0
27+ confidence : float
2828 """Confidence score"""
2929 reconstructed : bool
3030 """Whether the field was reconstructed from other fields."""
Original file line number Diff line number Diff line change 77class AmountField (FieldPositionMixin , BaseField ):
88 """A field containing an amount value."""
99
10- value : Optional [float ] = None
10+ value : Optional [float ]
1111 """The amount value as a float."""
1212
1313 def __init__ (
@@ -23,6 +23,7 @@ def __init__(
2323 :param reconstructed: Bool for reconstructed object (not extracted in the API)
2424 :param page_id: Page number for multi-page document
2525 """
26+ self .value = None
2627 super ().__init__ (
2728 raw_prediction ,
2829 value_key = "value" ,
Original file line number Diff line number Diff line change @@ -25,29 +25,31 @@ def _set_position(self, raw_prediction: StringDict):
2525 pass
2626 if self .polygon :
2727 self .bounding_box = get_bounding_box (self .polygon )
28+ else :
29+ self .bounding_box = None
2830
2931
3032class FieldConfidenceMixin :
3133 """Mixin class to add a confidence score."""
3234
33- confidence : float = 0.0
35+ confidence : float
3436 """The confidence score."""
3537
3638 def _set_confidence (self , raw_prediction : StringDict ):
3739 try :
3840 self .confidence = float (raw_prediction ["confidence" ])
3941 except (KeyError , TypeError ):
40- pass
42+ self . confidence = 0.0
4143
4244
4345class BaseField (FieldConfidenceMixin ):
4446 """Base class for most fields."""
4547
46- value : Optional [Any ] = None
48+ value : Optional [Any ]
4749 """Raw field value"""
4850 reconstructed : bool
4951 """Whether the field was reconstructed from other fields."""
50- page_id : Optional [int ] = None
52+ page_id : Optional [int ]
5153 """The document page on which the information was found."""
5254
5355 def __init__ (
@@ -57,6 +59,8 @@ def __init__(
5759 reconstructed : bool = False ,
5860 page_id : Optional [int ] = None ,
5961 ):
62+ self .value = None
63+ self .confidence = 0.0
6064 """
6165 Base field object.
6266
Original file line number Diff line number Diff line change 1313class DateField (FieldPositionMixin , BaseField ):
1414 """A field containing a date value."""
1515
16- date_object : Optional [date ] = None
16+ date_object : Optional [date ]
1717 """Date as a standard Python ``datetime.date`` object."""
18- value : Optional [str ] = None
18+ value : Optional [str ]
1919 """The raw field value."""
2020
2121 def __init__ (
@@ -49,3 +49,7 @@ def __init__(
4949 except (TypeError , ValueError ):
5050 self .date_object = None
5151 self .confidence = 0.0
52+ else :
53+ self .date_object = None
54+ self .confidence = 0.0
55+ self .value = None
Original file line number Diff line number Diff line change 77class LocaleField (BaseField ):
88 """The locale detected on the document."""
99
10- language : Optional [str ] = None
10+ language : Optional [str ]
1111 """The ISO 639-1 code of the language."""
12- country : Optional [str ] = None
12+ country : Optional [str ]
1313 """The ISO 3166-1 alpha-2 code of the country."""
14- currency : Optional [str ] = None
14+ currency : Optional [str ]
1515 """The ISO 4217 code of the currency."""
1616
1717 def __init__ (
Original file line number Diff line number Diff line change 77class PaymentDetailsField (FieldPositionMixin , BaseField ):
88 """Information on a single payment."""
99
10- account_number : Optional [str ] = None
10+ account_number : Optional [str ]
1111 """Account number"""
12- iban : Optional [str ] = None
12+ iban : Optional [str ]
1313 """Account IBAN"""
14- routing_number : Optional [str ] = None
14+ routing_number : Optional [str ]
1515 """Account routing number"""
16- swift : Optional [str ] = None
16+ swift : Optional [str ]
1717 """Bank's SWIFT code"""
1818
1919 def __init__ (
Original file line number Diff line number Diff line change 1010class PositionField (BaseField ):
1111 """A field indicating a position or area on the document."""
1212
13- value : Optional [Polygon ] = None
13+ value : Optional [Polygon ]
1414 """Polygon of cropped area, identical to the ``polygon`` property."""
15- polygon : Optional [Polygon ] = None
15+ polygon : Optional [Polygon ]
1616 """Polygon of cropped area"""
17- quadrangle : Optional [Quadrilateral ] = None
17+ quadrangle : Optional [Quadrilateral ]
1818 """Quadrangle of cropped area (does not exceed the canvas)"""
19- rectangle : Optional [Quadrilateral ] = None
19+ rectangle : Optional [Quadrilateral ]
2020 """Oriented rectangle of cropped area (may exceed the canvas)"""
21- bounding_box : Optional [Quadrilateral ] = None
21+ bounding_box : Optional [Quadrilateral ]
2222 """Straight rectangle of cropped area (does not exceed the canvas)"""
2323
2424 def __init__ (
Original file line number Diff line number Diff line change 77class StringField (FieldPositionMixin , BaseField ):
88 """A field containing a text value."""
99
10- value : Optional [str ] = None
10+ value : Optional [str ]
1111
1212 def __init__ (
1313 self ,
@@ -24,6 +24,7 @@ def __init__(
2424 :param reconstructed: Bool for reconstructed object (not extracted in the API)
2525 :param page_id: Page number for multi-page document
2626 """
27+ self .value = None
2728 super ().__init__ (
2829 raw_prediction ,
2930 value_key = value_key ,
You can’t perform that action at this time.
0 commit comments