How to process FORM data from Analyze Document in the same order that it appears in the demo?

0

When a file is scanned in the Textract Analyze Document demo you can see the scanned FORM data (KEY/VAL pairs) are listed in a specific order which matches the visual layout of the page. I understand that the API result doesn't return the pairs in any specific order. To compensate for this, I have written code to sort the pairs using the page and the top and left coordinates listed in the Geometry/ Bounding Box section of the result for the KEY. Using this method, I am not able to get the results to match the exact order returned in the demo.
For example, in the following image: Enter image description here when ordering based on the top and left coordinates I get the key/val pairs in this order:

NAME= NAME=Aaron Baker
DATE OF BIRTH=
DATE OF BIRTH=01/29/2007
HOME ADDRESS=8550 N 91st Ave Suite 64
HOME ADDRESS=
ZIP= SSN=
ZIP=85345
SSN=666-66-6666
EMAIL=
EMAIL=aaronbaker@gmail.co

whereas the demo returns the correct order. Looking for any tips or tricks or advice on how to replicate the ordering in the demo using the json result provided by the API.

SBee
已提問 5 個月前檢視次數 144 次
1 個回答
0

Hi, thanks for using Textract service! Can you please show me how you implement the code for ordering? I checked the response and the first "Name" key of "Name: Aaron Baker" has below BoundingBox

"BoundingBox": {
          "Width": 0.04194857180118561,
          "Height": 0.045949071645736694,
          "Left": 0.008498849347233772,
          "Top": 0.15230591595172882
        },

and the second "Name" key of "Name:" has below BoundingBox

"BoundingBox": {
          "Width": 0.041789766401052475,
          "Height": 0.04715460538864136,
          "Left": 0.4771515727043152,
          "Top": 0.14284992218017578
        },

So if you sort by "Left" and "Top" value, you should be able to put "Name: Aaron Baker" ahead of "Name:", which should gives you NAME=Aaron Baker NAME=.

AWS
已回答 4 個月前
profile picture
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南