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
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠