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
demandé il y a 5 mois144 vues
1 réponse
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
répondu il y a 4 mois
profile picture
EXPERT
vérifié il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions