Skip to content

Commit e135c69

Browse files
[formrecognizer] add testcases for labeled tables - fixed/variable rows (Azure#18214)
* add testcases for labeled tables - fixed/variable rows * fix input param * shorten test variable names * update test-resources.json env var names
1 parent 5ec4667 commit e135c69

9 files changed

+1119
-4
lines changed

sdk/formrecognizer/azure-ai-formrecognizer/tests/preparers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
formrecognizer_multipage_storage_container_sas_url="container_sas_url",
2626
formrecognizer_multipage_storage_container_sas_url_2="container_sas_url",
2727
formrecognizer_selection_mark_storage_container_sas_url="container_sas_url",
28+
formrecognizer_table_variable_rows_container_sas_url="container_sas_url",
29+
formrecognizer_table_fixed_rows_container_sas_url="container_sas_url",
2830
formrecognizer_resource_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.CognitiveServices/accounts/frname",
2931
formrecognizer_region="region"
3032
)
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
interactions:
2+
- request:
3+
body: 'b''{"source": "container_sas_url", "sourceFilter": {"prefix": "", "includeSubFolders":
4+
false}, "useLabelFile": true}'''
5+
headers:
6+
Accept:
7+
- application/json
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Connection:
11+
- keep-alive
12+
Content-Length:
13+
- '302'
14+
Content-Type:
15+
- application/json
16+
User-Agent:
17+
- azsdk-python-ai-formrecognizer/3.1.0b5 Python/3.9.0 (Windows-10-10.0.19041-SP0)
18+
method: POST
19+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models
20+
response:
21+
body:
22+
string: ''
23+
headers:
24+
apim-request-id:
25+
- fb88ba21-8e3e-4a26-a4d2-ca2173ffc2b5
26+
content-length:
27+
- '0'
28+
date:
29+
- Thu, 22 Apr 2021 01:29:38 GMT
30+
location:
31+
- https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621
32+
strict-transport-security:
33+
- max-age=31536000; includeSubDomains; preload
34+
x-content-type-options:
35+
- nosniff
36+
x-envoy-upstream-service-time:
37+
- '533'
38+
status:
39+
code: 201
40+
message: Created
41+
- request:
42+
body: null
43+
headers:
44+
Accept:
45+
- '*/*'
46+
Accept-Encoding:
47+
- gzip, deflate
48+
Connection:
49+
- keep-alive
50+
User-Agent:
51+
- azsdk-python-ai-formrecognizer/3.1.0b5 Python/3.9.0 (Windows-10-10.0.19041-SP0)
52+
method: GET
53+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621?includeKeys=true
54+
response:
55+
body:
56+
string: '{"modelInfo": {"modelId": "d55d7c8d-1f62-43ad-b083-317205e12621", "attributes":
57+
{"isComposed": false}, "status": "ready", "createdDateTime": "2021-04-22T01:29:38Z",
58+
"lastUpdatedDateTime": "2021-04-22T01:29:41Z"}, "trainResult": {"averageModelAccuracy":
59+
0.995, "trainingDocuments": [{"documentName": "label_table_fixed_rows1.pdf",
60+
"pages": 1, "status": "succeeded"}, {"documentName": "label_table_fixed_rows2.pdf",
61+
"pages": 1, "status": "succeeded"}, {"documentName": "label_table_fixed_rows3.pdf",
62+
"pages": 1, "status": "succeeded"}, {"documentName": "label_table_fixed_rows4.pdf",
63+
"pages": 1, "status": "succeeded"}, {"documentName": "label_table_fixed_rows5.pdf",
64+
"pages": 1, "status": "succeeded"}], "fields": [{"fieldName": "table", "accuracy":
65+
0.995}], "errors": []}}'
66+
headers:
67+
apim-request-id:
68+
- 59a83ea2-d358-4620-8d0d-5d569c20b9fd
69+
content-length:
70+
- '720'
71+
content-type:
72+
- application/json; charset=utf-8
73+
date:
74+
- Thu, 22 Apr 2021 01:29:43 GMT
75+
strict-transport-security:
76+
- max-age=31536000; includeSubDomains; preload
77+
x-content-type-options:
78+
- nosniff
79+
x-envoy-upstream-service-time:
80+
- '17'
81+
status:
82+
code: 200
83+
message: OK
84+
- request:
85+
body: 'b''{"source": "blob_sas_url"}'''
86+
headers:
87+
Accept:
88+
- application/json
89+
Accept-Encoding:
90+
- gzip, deflate
91+
Connection:
92+
- keep-alive
93+
Content-Length:
94+
- '230'
95+
Content-Type:
96+
- application/json
97+
User-Agent:
98+
- azsdk-python-ai-formrecognizer/3.1.0b5 Python/3.9.0 (Windows-10-10.0.19041-SP0)
99+
method: POST
100+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621/analyze?includeTextDetails=false
101+
response:
102+
body:
103+
string: ''
104+
headers:
105+
apim-request-id:
106+
- 10f98cd9-0aa5-4987-84b1-9cb206208c54
107+
content-length:
108+
- '0'
109+
date:
110+
- Thu, 22 Apr 2021 01:29:43 GMT
111+
operation-location:
112+
- https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621/analyzeresults/59b6a250-6815-45c3-9029-d67a1a4f6571
113+
strict-transport-security:
114+
- max-age=31536000; includeSubDomains; preload
115+
x-content-type-options:
116+
- nosniff
117+
x-envoy-upstream-service-time:
118+
- '347'
119+
status:
120+
code: 202
121+
message: Accepted
122+
- request:
123+
body: null
124+
headers:
125+
Accept:
126+
- '*/*'
127+
Accept-Encoding:
128+
- gzip, deflate
129+
Connection:
130+
- keep-alive
131+
User-Agent:
132+
- azsdk-python-ai-formrecognizer/3.1.0b5 Python/3.9.0 (Windows-10-10.0.19041-SP0)
133+
method: GET
134+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621/analyzeresults/59b6a250-6815-45c3-9029-d67a1a4f6571
135+
response:
136+
body:
137+
string: '{"status": "notStarted", "createdDateTime": "2021-04-22T01:29:44Z",
138+
"lastUpdatedDateTime": "2021-04-22T01:29:48Z"}'
139+
headers:
140+
apim-request-id:
141+
- 27da524d-3b74-4832-ac70-2fee5d03f1dd
142+
content-length:
143+
- '109'
144+
content-type:
145+
- application/json; charset=utf-8
146+
date:
147+
- Thu, 22 Apr 2021 01:29:49 GMT
148+
strict-transport-security:
149+
- max-age=31536000; includeSubDomains; preload
150+
x-content-type-options:
151+
- nosniff
152+
x-envoy-upstream-service-time:
153+
- '15'
154+
status:
155+
code: 200
156+
message: OK
157+
- request:
158+
body: null
159+
headers:
160+
Accept:
161+
- '*/*'
162+
Accept-Encoding:
163+
- gzip, deflate
164+
Connection:
165+
- keep-alive
166+
User-Agent:
167+
- azsdk-python-ai-formrecognizer/3.1.0b5 Python/3.9.0 (Windows-10-10.0.19041-SP0)
168+
method: GET
169+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1-preview.3/custom/models/d55d7c8d-1f62-43ad-b083-317205e12621/analyzeresults/59b6a250-6815-45c3-9029-d67a1a4f6571
170+
response:
171+
body:
172+
string: '{"status": "succeeded", "createdDateTime": "2021-04-22T01:29:44Z",
173+
"lastUpdatedDateTime": "2021-04-22T01:29:51Z", "analyzeResult": {"version":
174+
"2.1.0", "readResults": [{"page": 1, "angle": 0, "width": 8.5, "height": 11,
175+
"unit": "inch"}], "pageResults": [{"page": 1, "tables": [{"rows": 5, "columns":
176+
4, "cells": [{"rowIndex": 0, "columnIndex": 0, "text": "", "boundingBox":
177+
[0.9904, 1.6215, 2.297, 1.6215, 2.297, 1.8221, 0.9958, 1.8272]}, {"rowIndex":
178+
0, "columnIndex": 1, "text": "Price", "boundingBox": [2.297, 1.6215, 3.5874,
179+
1.6215, 3.5928, 1.8221, 2.297, 1.8221]}, {"rowIndex": 0, "columnIndex": 2,
180+
"text": "Tax", "boundingBox": [3.5874, 1.6215, 4.8994, 1.6215, 4.8994, 1.8221,
181+
3.5928, 1.8221]}, {"rowIndex": 0, "columnIndex": 3, "text": "Total", "boundingBox":
182+
[4.8994, 1.6215, 6.1952, 1.6215, 6.1952, 1.8272, 4.8994, 1.8221]}, {"rowIndex":
183+
1, "columnIndex": 0, "text": "Apple", "boundingBox": [0.9958, 1.8272, 2.297,
184+
1.8221, 2.297, 2.0078, 0.9958, 2.0128]}, {"rowIndex": 1, "columnIndex": 1,
185+
"text": "5.00", "boundingBox": [2.297, 1.8221, 3.5928, 1.8221, 3.5928, 2.0078,
186+
2.297, 2.0078]}, {"rowIndex": 1, "columnIndex": 2, "text": "2.00", "boundingBox":
187+
[3.5928, 1.8221, 4.8994, 1.8221, 4.8994, 2.0078, 3.5928, 2.0078]}, {"rowIndex":
188+
1, "columnIndex": 3, "text": "7.00", "boundingBox": [4.8994, 1.8221, 6.1952,
189+
1.8272, 6.1952, 2.0128, 4.8994, 2.0078]}, {"rowIndex": 2, "columnIndex": 0,
190+
"text": "Orange", "boundingBox": [0.9958, 2.0128, 2.297, 2.0078, 2.297, 2.2034,
191+
0.9958, 2.2084]}, {"rowIndex": 2, "columnIndex": 1, "text": "2.00", "boundingBox":
192+
[2.297, 2.0078, 3.5928, 2.0078, 3.5928, 2.2034, 2.297, 2.2034]}, {"rowIndex":
193+
2, "columnIndex": 2, "text": "1.00", "boundingBox": [3.5928, 2.0078, 4.8994,
194+
2.0078, 4.8994, 2.2034, 3.5928, 2.2034]}, {"rowIndex": 2, "columnIndex": 3,
195+
"text": "3.00", "boundingBox": [4.8994, 2.0078, 6.1952, 2.0128, 6.1952, 2.2034,
196+
4.8994, 2.2034]}, {"rowIndex": 3, "columnIndex": 0, "text": "Grapefruit",
197+
"boundingBox": [0.9958, 2.2084, 2.297, 2.2034, 2.297, 2.3991, 0.9958, 2.3991]},
198+
{"rowIndex": 3, "columnIndex": 1, "text": "1.00", "boundingBox": [2.297, 2.2034,
199+
3.5928, 2.2034, 3.5928, 2.3991, 2.297, 2.3991]}, {"rowIndex": 3, "columnIndex":
200+
2, "text": "4.00", "boundingBox": [3.5928, 2.2034, 4.8994, 2.2034, 4.8994,
201+
2.3991, 3.5928, 2.3991]}, {"rowIndex": 3, "columnIndex": 3, "text": "5.00",
202+
"boundingBox": [4.8994, 2.2034, 6.1952, 2.2034, 6.1952, 2.3991, 4.8994, 2.3991]},
203+
{"rowIndex": 4, "columnIndex": 0, "text": "Pear", "boundingBox": [0.9958,
204+
2.3991, 2.297, 2.3991, 2.297, 2.5947, 0.9958, 2.5947]}, {"rowIndex": 4, "columnIndex":
205+
1, "text": "", "boundingBox": [2.297, 2.3991, 3.5928, 2.3991, 3.5982, 2.5947,
206+
2.297, 2.5947]}, {"rowIndex": 4, "columnIndex": 2, "text": "2.00", "boundingBox":
207+
[3.5928, 2.3991, 4.8994, 2.3991, 4.8994, 2.5947, 3.5982, 2.5947]}, {"rowIndex":
208+
4, "columnIndex": 3, "text": "2.00", "boundingBox": [4.8994, 2.3991, 6.1952,
209+
2.3991, 6.1952, 2.5947, 4.8994, 2.5947]}], "boundingBox": [0.9986, 1.6168,
210+
6.2004, 1.6179, 6.2004, 2.597, 0.9981, 2.5961]}]}], "documentResults": [{"docType":
211+
"custom:d55d7c8d-1f62-43ad-b083-317205e12621", "modelId": "d55d7c8d-1f62-43ad-b083-317205e12621",
212+
"pageRange": [1, 1], "fields": {"table": {"type": "object", "valueObject":
213+
{"Apple": {"type": "object", "valueObject": {"Price": {"type": "string", "valueString":
214+
"5.00", "text": "5.00", "page": 1, "boundingBox": [2.385, 1.87, 2.645, 1.87,
215+
2.645, 1.97, 2.385, 1.97]}, "Tax": {"type": "string", "valueString": "2.00",
216+
"text": "2.00", "page": 1, "boundingBox": [3.685, 1.87, 3.945, 1.87, 3.945,
217+
1.97, 3.685, 1.97]}, "Total": {"type": "string", "valueString": "7.00", "text":
218+
"7.00", "page": 1, "boundingBox": [4.985, 1.87, 5.245, 1.87, 5.245, 1.97,
219+
4.985, 1.97]}}}, "Orange": {"type": "object", "valueObject": {"Price": {"type":
220+
"string", "valueString": "2.00", "text": "2.00", "page": 1, "boundingBox":
221+
[2.385, 2.065, 2.645, 2.065, 2.645, 2.165, 2.385, 2.165]}, "Tax": {"type":
222+
"string", "valueString": "1.00", "text": "1.00", "page": 1, "boundingBox":
223+
[3.69, 2.065, 3.945, 2.065, 3.945, 2.165, 3.69, 2.165]}, "Total": {"type":
224+
"string", "valueString": "3.00", "text": "3.00", "page": 1, "boundingBox":
225+
[4.985, 2.065, 5.245, 2.065, 5.245, 2.165, 4.985, 2.165]}}}, "Grapefruit":
226+
{"type": "object", "valueObject": {"Price": {"type": "string", "valueString":
227+
"1.00", "text": "1.00", "page": 1, "boundingBox": [2.39, 2.26, 2.645, 2.26,
228+
2.645, 2.36, 2.39, 2.36]}, "Tax": {"type": "string", "valueString": "4.00",
229+
"text": "4.00", "page": 1, "boundingBox": [3.68, 2.26, 3.945, 2.26, 3.945,
230+
2.36, 3.68, 2.36]}, "Total": {"type": "string", "valueString": "5.00", "text":
231+
"5.00", "page": 1, "boundingBox": [4.985, 2.26, 5.245, 2.26, 5.245, 2.36,
232+
4.985, 2.36]}}}, "Pear": {"type": "object", "valueObject": {"Price": null,
233+
"Tax": {"type": "string", "valueString": "2.00", "text": "2.00", "page": 1,
234+
"boundingBox": [3.685, 2.45, 3.945, 2.45, 3.945, 2.55, 3.685, 2.55]}, "Total":
235+
{"type": "string", "valueString": "2.00", "text": "2.00", "page": 1, "boundingBox":
236+
[4.985, 2.45, 5.245, 2.45, 5.245, 2.55, 4.985, 2.55]}}}}}}, "docTypeConfidence":
237+
0.979}], "errors": []}}'
238+
headers:
239+
apim-request-id:
240+
- 31eb026f-ea60-4f17-8c92-c6673073fd15
241+
content-length:
242+
- '4533'
243+
content-type:
244+
- application/json; charset=utf-8
245+
date:
246+
- Thu, 22 Apr 2021 01:29:54 GMT
247+
strict-transport-security:
248+
- max-age=31536000; includeSubDomains; preload
249+
x-content-type-options:
250+
- nosniff
251+
x-envoy-upstream-service-time:
252+
- '19'
253+
status:
254+
code: 200
255+
message: OK
256+
version: 1

0 commit comments

Comments
 (0)