|
1 | 1 | ---
|
2 | 2 | title: Generated API Python
|
3 | 3 | ---
|
4 |
| - |
5 | 4 | The Python OCR SDK supports generated APIs.
|
6 | 5 | Generated APIs can theoretically support all APIs in a catch-all generic format.
|
7 | 6 |
|
@@ -61,23 +60,31 @@ Since the inner contents can vary, the value isn't accessed through a property,
|
61 | 60 |
|
62 | 61 | - **contents_list()** (`-> List[Union[str, float]]`): returns a list of values for each element.
|
63 | 62 | - **contents_string(separator=" ")** (`-> str`): returns a list of concatenated values, with an optional **separator** `str` between them.
|
64 |
| -- ****str**()**: returns a string representation of all values, appropriate spacing. |
| 63 | +> **Note:** the `str()` method returns a string representation of all values of this object, with an empty space between each of them. |
65 | 64 |
|
66 |
| -#### Generated Object Field |
| 65 | +### Generated Object Field |
67 | 66 |
|
68 | 67 | Unrecognized structures and sometimes values of `ListField`s are stored in a `GeneratedObjectField` structure, which is implemented dynamically depending on the object's structure.
|
69 | 68 |
|
70 |
| -No matter what, the fields will be stored in a dictionary-like structure with a `key: value` pair where `key` is a string and `value` is a nullable string. The object also contains: |
71 |
| - |
72 | 69 | - **page_id** (`Optional[int]`): the ID of the page, is `None` when at document-level.
|
| 70 | +- **raw_value** (`Optional[str]`): an optional field for when some post-processing has been done on fields (e.g. amounts). `None` in most instances. |
| 71 | +- **confidence** (`Optional[float]`): the confidence score of the field prediction. Warning: support isn't guaranteed on all APIs. |
| 72 | + |
| 73 | + |
| 74 | +> **Other fields**:No matter what, other fields will be stored in a dictionary-like structure with a `key: value` pair where `key` is a string and `value` is a nullable string. They can be accessed like any other regular value, but won't be suggested by your IDE. |
| 75 | +
|
| 76 | + |
| 77 | +### StringField |
| 78 | +The text field `StringField` only has one constraint: its **value** is an `Optional[str]`. |
| 79 | + |
73 | 80 |
|
74 | 81 | # Attributes
|
75 | 82 |
|
76 | 83 | Generated builds always have access to at least two attributes:
|
77 | 84 |
|
78 | 85 | ## Fields
|
79 | 86 |
|
80 |
| -**fields** (`Dict[str`: `List[Union[`[GeneratedListField](#generated-list-field)[GeneratedObjectField](#generated-object-field), `StringField]]`): |
| 87 | +**fields** (`Dict[str`: `List[Union[`[GeneratedListField](#generated-list-field)[GeneratedObjectField](#generated-object-field), `(#stringfield)[StringField]]]`): |
81 | 88 |
|
82 | 89 | ```python
|
83 | 90 | print(str(result.document.inference.prediction.fields["my-field"]))
|
|
0 commit comments