12
12
import six
13
13
14
14
15
+ def adjust_value_type (value_type ):
16
+ if value_type == "array" :
17
+ value_type = "list"
18
+ if value_type == "number" :
19
+ value_type = "float"
20
+ if value_type == "object" :
21
+ value_type = "dictionary"
22
+ return value_type
23
+
24
+
15
25
def adjust_confidence (score ):
16
26
"""Adjust confidence when not returned.
17
27
"""
@@ -83,10 +93,10 @@ class FieldValueType(str, Enum):
83
93
DATE = "date"
84
94
TIME = "time"
85
95
PHONE_NUMBER = "phoneNumber"
86
- NUMBER = "number "
96
+ FLOAT = "float "
87
97
INTEGER = "integer"
88
- ARRAY = "array "
89
- OBJECT = "object "
98
+ LIST = "list "
99
+ DICTIONARY = "dictionary "
90
100
91
101
92
102
class LengthUnit (str , Enum ):
@@ -202,9 +212,9 @@ def __repr__(self):
202
212
class FormField (object ):
203
213
"""Represents a field recognized in an input form.
204
214
205
- :ivar value_type: The type of `value` found on FormField. Possible types include: 'string',
206
- 'date', 'time', 'phoneNumber', 'number', 'integer', 'object', or 'array'.
207
- :vartype value_type: str or ~azure.ai.formrecognizer.FieldValueType
215
+ :ivar str value_type: The type of `value` found on FormField. Described in
216
+ :class:`~azure.ai.formrecognizer.FieldValueType`, possible types include: 'string',
217
+ 'date', 'time', 'phoneNumber', 'float', 'integer', 'dictionary', or 'list'.
208
218
:ivar ~azure.ai.formrecognizer.FieldData label_data:
209
219
Contains the text, bounding box, and field elements for the field label.
210
220
:ivar ~azure.ai.formrecognizer.FieldData value_data:
@@ -213,7 +223,7 @@ class FormField(object):
213
223
:ivar value:
214
224
The value for the recognized field. Its semantic data type is described by `value_type`.
215
225
:vartype value: str, int, float, :class:`~datetime.date`, :class:`~datetime.time`,
216
- :class:`~azure.ai.formrecognizer.FormField`, or list[:class:`~azure.ai.formrecognizer.FormField`]
226
+ dict[str, :class:`~azure.ai.formrecognizer.FormField`] , or list[:class:`~azure.ai.formrecognizer.FormField`]
217
227
:ivar float confidence:
218
228
Measures the degree of certainty of the recognition result. Value is between [0.0, 1.0].
219
229
"""
@@ -229,7 +239,7 @@ def __init__(self, **kwargs):
229
239
@classmethod
230
240
def _from_generated (cls , field , value , read_result ):
231
241
return cls (
232
- value_type = value .type if value else None ,
242
+ value_type = adjust_value_type ( value .type ) if value else None ,
233
243
label_data = FieldData ._from_generated (field , read_result ),
234
244
value_data = FieldData ._from_generated (value , read_result ),
235
245
value = get_field_value (field , value , read_result ),
@@ -667,7 +677,7 @@ class TrainingDocumentInfo(object):
667
677
"""Report for an individual document used for training
668
678
a custom model.
669
679
670
- :ivar str document_name :
680
+ :ivar str name :
671
681
The name of the document.
672
682
:ivar str status:
673
683
The :class:`~azure.ai.formrecognizer.TrainingStatus`
@@ -680,23 +690,23 @@ class TrainingDocumentInfo(object):
680
690
"""
681
691
682
692
def __init__ (self , ** kwargs ):
683
- self .document_name = kwargs .get ("document_name " , None )
693
+ self .name = kwargs .get ("name " , None )
684
694
self .status = kwargs .get ("status" , None )
685
695
self .page_count = kwargs .get ("page_count" , None )
686
696
self .errors = kwargs .get ("errors" , [])
687
697
688
698
@classmethod
689
699
def _from_generated (cls , train_result ):
690
700
return [cls (
691
- document_name = doc .document_name ,
701
+ name = doc .document_name ,
692
702
status = doc .status ,
693
703
page_count = doc .pages ,
694
704
errors = FormRecognizerError ._from_generated (doc .errors )
695
705
) for doc in train_result .training_documents ] if train_result .training_documents else None
696
706
697
707
def __repr__ (self ):
698
- return "TrainingDocumentInfo(document_name ={}, status={}, page_count={}, errors={})" .format (
699
- self .document_name , self .status , self .page_count , repr (self .errors )
708
+ return "TrainingDocumentInfo(name ={}, status={}, page_count={}, errors={})" .format (
709
+ self .name , self .status , self .page_count , repr (self .errors )
700
710
)[:1024 ]
701
711
702
712
0 commit comments