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
asked 4 months ago135 views
1 Answer
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
answered 4 months ago
profile picture
EXPERT
reviewed 23 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions