Outputs for real-time analysis - Amazon Comprehend

Outputs for real-time analysis

Outputs for text inputs

If you input text using the Text parameter, the output consists of an array of entities that the analysis detected. The following example shows an analysis that detected two JUDGE entities.

{ "Entities": [ { "BeginOffset": 0, "EndOffset": 22, "Score": 0.9763959646224976, "Text": "John Johnson", "Type": "JUDGE" }, { "BeginOffset": 11, "EndOffset": 15, "Score": 0.9615424871444702, "Text": "Thomas Kincaid", "Type": "JUDGE" } ] }

Outputs for semi-structured inputs

For a semi-structured input document, or a text file, the output can include the following additional fields:

  • DocumentMetadata – Extraction information about the document. The metadata includes a list of pages in the document, with the number of characters extracted from each page. This field is present in the response if the request included the Byte parameter.

  • DocumentType – The document type for each page in the input document. This field is present in the response for a request that included the Byte parameter.

  • Blocks – Information about each block of text in the input document. Blocks are nested. A page block contains a block for each line of text, which contains a block for each word. This field is present in the response for a request that included the Byte parameter.

  • BlockReferences – A reference to each block for this entity. This field is present in the response for a request that included the Byte parameter. The field is not present for text files.

  • Errors – Page-level errors that the system detected while processing the input document. The field is empty if the system encountered no errors.

For descriptions of these output fields, see DetectEntities in the Amazon Comprehend API Reference. For more information about the layout elements, see Amazon Textract analysis objects in the Amazon Textract Developer Guide.

The following example shows the output for a one-page scanned PDF input document.

{ "Entities": [{ "Score": 0.9984670877456665, "Type": "DATE-TIME", "Text": "September 4,", "BlockReferences": [{ "BlockId": "42dcaaee-c484-4b5d-9e3f-ae0be928b3e1", "BeginOffset": 0, "EndOffset": 12, "ChildBlocks": [{ "ChildBlockId": "6e9cbb43-f8be-4da0-9a4b-ff9a6c350a14", "BeginOffset": 0, "EndOffset": 9 }, { "ChildBlockId": "599e0d53-ae9f-491b-a762-459b22c79ff5", "BeginOffset": 0, "EndOffset": 2 }, { "ChildBlockId": "599e0d53-ae9f-491b-a762-459b22c79ff5", "BeginOffset": 0, "EndOffset": 2 } ] }] }], "DocumentMetadata": { "Pages": 1, "ExtractedCharacters": [{ "Page": 1, "Count": 609 }] }, "DocumentType": [{ "Page": 1, "Type": "SCANNED_PDF" }], "Blocks": [{ "Id": "ee82edf3-28de-4d63-8883-40e2e4938ccb", "BlockType": "LINE", "Text": "Your Band", "Page": 1, "Geometry": { "BoundingBox": { "Height": 0.024125460535287857, "Left": 0.11745482683181763, "Top": 0.06821706146001816, "Width": 0.12074867635965347 }, "Polygon": [{ "X": 0.11745482683181763, "Y": 0.06821706146001816 }, { "X": 0.2382034957408905, "Y": 0.06821706146001816 }, { "X": 0.2382034957408905, "Y": 0.09234252572059631 }, { "X": 0.11745482683181763, "Y": 0.09234252572059631 } ] }, "Relationships": [{ "Ids": [ "b105c561-c8d9-485a-a728-7a5b1a308935", "60ecb119-3173-4de2-8c5d-de182a5f86a5" ], "Type": "CHILD" }] }] }

The following example shows the output for analysis of a native PDF document.

Example output from a custom entity recognition analysis of a PDF document
{ "Blocks": [ { "BlockType": "LINE", "Geometry": { "BoundingBox": { "Height": 0.012575757575757575, "Left": 0.0, "Top": 0.0015063131313131314, "Width": 0.02262091503267974 }, "Polygon": [ { "X": 0.0, "Y": 0.0015063131313131314 }, { "X": 0.02262091503267974, "Y": 0.0015063131313131314 }, { "X": 0.02262091503267974, "Y": 0.014082070707070706 }, { "X": 0.0, "Y": 0.014082070707070706 } ] }, "Id": "4330efed-6334-4fc4-ba48-e050afa95c8d", "Page": 1, "Relationships": [ { "ids": [ "f343ce48-583d-4abe-b84b-a232e266450f" ], "type": "CHILD" } ], "Text": "S-3" }, { "BlockType": "WORD", "Geometry": { "BoundingBox": { "Height": 0.012575757575757575, "Left": 0.0, "Top": 0.0015063131313131314, "Width": 0.02262091503267974 }, "Polygon": [ { "X": 0.0, "Y": 0.0015063131313131314 }, { "X": 0.02262091503267974, "Y": 0.0015063131313131314 }, { "X": 0.02262091503267974, "Y": 0.014082070707070706 }, { "X": 0.0, "Y": 0.014082070707070706 } ] }, "Id": "f343ce48-583d-4abe-b84b-a232e266450f", "Page": 1, "Relationships": [], "Text": "S-3" } ], "DocumentMetadata": { "PageNumber": 1, "Pages": 1 }, "DocumentType": "NativePDF", "Entities": [ { "BlockReferences": [ { "BeginOffset": 25, "BlockId": "4330efed-6334-4fc4-ba48-e050afa95c8d", "ChildBlocks": [ { "BeginOffset": 1, "ChildBlockId": "cbba5534-ac69-4bc4-beef-306c659f70a6", "EndOffset": 6 } ], "EndOffset": 30 } ], "Score": 0.9998825926329088, "Text": "0.001", "Type": "OFFERING_PRICE" }, { "BlockReferences": [ { "BeginOffset": 41, "BlockId": "f343ce48-583d-4abe-b84b-a232e266450f", "ChildBlocks": [ { "BeginOffset": 0, "ChildBlockId": "292a2e26-21f0-401b-a2bf-03aa4c47f787", "EndOffset": 9 } ], "EndOffset": 50 } ], "Score": 0.9809727537330395, "Text": "6,097,560", "Type": "OFFERED_SHARES" } ], "File": "example.pdf", "Version": "2021-04-30" }