{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Textract.Types.Block
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Textract.Types.Block where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Textract.Types.BlockType
import Amazonka.Textract.Types.EntityType
import Amazonka.Textract.Types.Geometry
import Amazonka.Textract.Types.Query
import Amazonka.Textract.Types.Relationship
import Amazonka.Textract.Types.SelectionStatus
import Amazonka.Textract.Types.TextType

-- | A @Block@ represents items that are recognized in a document within a
-- group of pixels close to each other. The information returned in a
-- @Block@ object depends on the type of operation. In text detection for
-- documents (for example DetectDocumentText), you get information about
-- the detected words and lines of text. In text analysis (for example
-- AnalyzeDocument), you can also get information about the fields, tables,
-- and selection elements that are detected in the document.
--
-- An array of @Block@ objects is returned by both synchronous and
-- asynchronous operations. In synchronous operations, such as
-- DetectDocumentText, the array of @Block@ objects is the entire set of
-- results. In asynchronous operations, such as GetDocumentAnalysis, the
-- array is returned over one or more responses.
--
-- For more information, see
-- <https://docs.aws.amazon.com/textract/latest/dg/how-it-works.html How Amazon Textract Works>.
--
-- /See:/ 'newBlock' smart constructor.
data Block = Block'
  { -- | The type of text item that\'s recognized. In operations for text
    -- detection, the following types are returned:
    --
    -- -   /PAGE/ - Contains a list of the LINE @Block@ objects that are
    --     detected on a document page.
    --
    -- -   /WORD/ - A word detected on a document page. A word is one or more
    --     ISO basic Latin script characters that aren\'t separated by spaces.
    --
    -- -   /LINE/ - A string of tab-delimited, contiguous words that are
    --     detected on a document page.
    --
    -- In text analysis operations, the following types are returned:
    --
    -- -   /PAGE/ - Contains a list of child @Block@ objects that are detected
    --     on a document page.
    --
    -- -   /KEY_VALUE_SET/ - Stores the KEY and VALUE @Block@ objects for
    --     linked text that\'s detected on a document page. Use the
    --     @EntityType@ field to determine if a KEY_VALUE_SET object is a KEY
    --     @Block@ object or a VALUE @Block@ object.
    --
    -- -   /WORD/ - A word that\'s detected on a document page. A word is one
    --     or more ISO basic Latin script characters that aren\'t separated by
    --     spaces.
    --
    -- -   /LINE/ - A string of tab-delimited, contiguous words that are
    --     detected on a document page.
    --
    -- -   /TABLE/ - A table that\'s detected on a document page. A table is
    --     grid-based information with two or more rows or columns, with a cell
    --     span of one row and one column each.
    --
    -- -   /CELL/ - A cell within a detected table. The cell is the parent of
    --     the block that contains the text in the cell.
    --
    -- -   /SELECTION_ELEMENT/ - A selection element such as an option button
    --     (radio button) or a check box that\'s detected on a document page.
    --     Use the value of @SelectionStatus@ to determine the status of the
    --     selection element.
    --
    -- -   /SIGNATURE/ - The location and confidene score of a signature
    --     detected on a document page. Can be returned as part of a Key-Value
    --     pair or a detected cell.
    --
    -- -   /QUERY/ - A question asked during the call of AnalyzeDocument.
    --     Contains an alias and an ID that attaches it to its answer.
    --
    -- -   /QUERY_RESULT/ - A response to a question asked during the call of
    --     analyze document. Comes with an alias and ID for ease of locating in
    --     a response. Also contains location and confidence score.
    Block -> Maybe BlockType
blockType :: Prelude.Maybe BlockType,
    -- | The column in which a table cell appears. The first column position is
    -- 1. @ColumnIndex@ isn\'t returned by @DetectDocumentText@ and
    -- @GetDocumentTextDetection@.
    Block -> Maybe Natural
columnIndex :: Prelude.Maybe Prelude.Natural,
    -- | The number of columns that a table cell spans. Currently this value is
    -- always 1, even if the number of columns spanned is greater than 1.
    -- @ColumnSpan@ isn\'t returned by @DetectDocumentText@ and
    -- @GetDocumentTextDetection@.
    Block -> Maybe Natural
columnSpan :: Prelude.Maybe Prelude.Natural,
    -- | The confidence score that Amazon Textract has in the accuracy of the
    -- recognized text and the accuracy of the geometry points around the
    -- recognized text.
    Block -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The type of entity. The following can be returned:
    --
    -- -   /KEY/ - An identifier for a field on the document.
    --
    -- -   /VALUE/ - The field text.
    --
    -- @EntityTypes@ isn\'t returned by @DetectDocumentText@ and
    -- @GetDocumentTextDetection@.
    Block -> Maybe [EntityType]
entityTypes :: Prelude.Maybe [EntityType],
    -- | The location of the recognized text on the image. It includes an
    -- axis-aligned, coarse bounding box that surrounds the text, and a
    -- finer-grain polygon for more accurate spatial information.
    Block -> Maybe Geometry
geometry :: Prelude.Maybe Geometry,
    -- | The identifier for the recognized text. The identifier is only unique
    -- for a single operation.
    Block -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The page on which a block was detected. @Page@ is returned by
    -- synchronous and asynchronous operations. Page values greater than 1 are
    -- only returned for multipage documents that are in PDF or TIFF format. A
    -- scanned image (JPEG\/PNG) provided to an asynchronous operation, even if
    -- it contains multiple document pages, is considered a single-page
    -- document. This means that for scanned images the value of @Page@ is
    -- always 1. Synchronous operations operations will also return a @Page@
    -- value of 1 because every input document is considered to be a
    -- single-page document.
    Block -> Maybe Natural
page :: Prelude.Maybe Prelude.Natural,
    Block -> Maybe Query
query :: Prelude.Maybe Query,
    -- | A list of child blocks of the current block. For example, a LINE object
    -- has child blocks for each WORD block that\'s part of the line of text.
    -- There aren\'t Relationship objects in the list for relationships that
    -- don\'t exist, such as when the current block has no child blocks. The
    -- list size can be the following:
    --
    -- -   0 - The block has no child blocks.
    --
    -- -   1 - The block has child blocks.
    Block -> Maybe [Relationship]
relationships :: Prelude.Maybe [Relationship],
    -- | The row in which a table cell is located. The first row position is 1.
    -- @RowIndex@ isn\'t returned by @DetectDocumentText@ and
    -- @GetDocumentTextDetection@.
    Block -> Maybe Natural
rowIndex :: Prelude.Maybe Prelude.Natural,
    -- | The number of rows that a table cell spans. Currently this value is
    -- always 1, even if the number of rows spanned is greater than 1.
    -- @RowSpan@ isn\'t returned by @DetectDocumentText@ and
    -- @GetDocumentTextDetection@.
    Block -> Maybe Natural
rowSpan :: Prelude.Maybe Prelude.Natural,
    -- | The selection status of a selection element, such as an option button or
    -- check box.
    Block -> Maybe SelectionStatus
selectionStatus :: Prelude.Maybe SelectionStatus,
    -- | The word or line of text that\'s recognized by Amazon Textract.
    Block -> Maybe Text
text :: Prelude.Maybe Prelude.Text,
    -- | The kind of text that Amazon Textract has detected. Can check for
    -- handwritten text and printed text.
    Block -> Maybe TextType
textType :: Prelude.Maybe TextType
  }
  deriving (Block -> Block -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Block -> Block -> Bool
$c/= :: Block -> Block -> Bool
== :: Block -> Block -> Bool
$c== :: Block -> Block -> Bool
Prelude.Eq, ReadPrec [Block]
ReadPrec Block
Int -> ReadS Block
ReadS [Block]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Block]
$creadListPrec :: ReadPrec [Block]
readPrec :: ReadPrec Block
$creadPrec :: ReadPrec Block
readList :: ReadS [Block]
$creadList :: ReadS [Block]
readsPrec :: Int -> ReadS Block
$creadsPrec :: Int -> ReadS Block
Prelude.Read, Int -> Block -> ShowS
[Block] -> ShowS
Block -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Block] -> ShowS
$cshowList :: [Block] -> ShowS
show :: Block -> String
$cshow :: Block -> String
showsPrec :: Int -> Block -> ShowS
$cshowsPrec :: Int -> Block -> ShowS
Prelude.Show, forall x. Rep Block x -> Block
forall x. Block -> Rep Block x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Block x -> Block
$cfrom :: forall x. Block -> Rep Block x
Prelude.Generic)

-- |
-- Create a value of 'Block' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'blockType', 'block_blockType' - The type of text item that\'s recognized. In operations for text
-- detection, the following types are returned:
--
-- -   /PAGE/ - Contains a list of the LINE @Block@ objects that are
--     detected on a document page.
--
-- -   /WORD/ - A word detected on a document page. A word is one or more
--     ISO basic Latin script characters that aren\'t separated by spaces.
--
-- -   /LINE/ - A string of tab-delimited, contiguous words that are
--     detected on a document page.
--
-- In text analysis operations, the following types are returned:
--
-- -   /PAGE/ - Contains a list of child @Block@ objects that are detected
--     on a document page.
--
-- -   /KEY_VALUE_SET/ - Stores the KEY and VALUE @Block@ objects for
--     linked text that\'s detected on a document page. Use the
--     @EntityType@ field to determine if a KEY_VALUE_SET object is a KEY
--     @Block@ object or a VALUE @Block@ object.
--
-- -   /WORD/ - A word that\'s detected on a document page. A word is one
--     or more ISO basic Latin script characters that aren\'t separated by
--     spaces.
--
-- -   /LINE/ - A string of tab-delimited, contiguous words that are
--     detected on a document page.
--
-- -   /TABLE/ - A table that\'s detected on a document page. A table is
--     grid-based information with two or more rows or columns, with a cell
--     span of one row and one column each.
--
-- -   /CELL/ - A cell within a detected table. The cell is the parent of
--     the block that contains the text in the cell.
--
-- -   /SELECTION_ELEMENT/ - A selection element such as an option button
--     (radio button) or a check box that\'s detected on a document page.
--     Use the value of @SelectionStatus@ to determine the status of the
--     selection element.
--
-- -   /SIGNATURE/ - The location and confidene score of a signature
--     detected on a document page. Can be returned as part of a Key-Value
--     pair or a detected cell.
--
-- -   /QUERY/ - A question asked during the call of AnalyzeDocument.
--     Contains an alias and an ID that attaches it to its answer.
--
-- -   /QUERY_RESULT/ - A response to a question asked during the call of
--     analyze document. Comes with an alias and ID for ease of locating in
--     a response. Also contains location and confidence score.
--
-- 'columnIndex', 'block_columnIndex' - The column in which a table cell appears. The first column position is
-- 1. @ColumnIndex@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
--
-- 'columnSpan', 'block_columnSpan' - The number of columns that a table cell spans. Currently this value is
-- always 1, even if the number of columns spanned is greater than 1.
-- @ColumnSpan@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
--
-- 'confidence', 'block_confidence' - The confidence score that Amazon Textract has in the accuracy of the
-- recognized text and the accuracy of the geometry points around the
-- recognized text.
--
-- 'entityTypes', 'block_entityTypes' - The type of entity. The following can be returned:
--
-- -   /KEY/ - An identifier for a field on the document.
--
-- -   /VALUE/ - The field text.
--
-- @EntityTypes@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
--
-- 'geometry', 'block_geometry' - The location of the recognized text on the image. It includes an
-- axis-aligned, coarse bounding box that surrounds the text, and a
-- finer-grain polygon for more accurate spatial information.
--
-- 'id', 'block_id' - The identifier for the recognized text. The identifier is only unique
-- for a single operation.
--
-- 'page', 'block_page' - The page on which a block was detected. @Page@ is returned by
-- synchronous and asynchronous operations. Page values greater than 1 are
-- only returned for multipage documents that are in PDF or TIFF format. A
-- scanned image (JPEG\/PNG) provided to an asynchronous operation, even if
-- it contains multiple document pages, is considered a single-page
-- document. This means that for scanned images the value of @Page@ is
-- always 1. Synchronous operations operations will also return a @Page@
-- value of 1 because every input document is considered to be a
-- single-page document.
--
-- 'query', 'block_query' -
--
-- 'relationships', 'block_relationships' - A list of child blocks of the current block. For example, a LINE object
-- has child blocks for each WORD block that\'s part of the line of text.
-- There aren\'t Relationship objects in the list for relationships that
-- don\'t exist, such as when the current block has no child blocks. The
-- list size can be the following:
--
-- -   0 - The block has no child blocks.
--
-- -   1 - The block has child blocks.
--
-- 'rowIndex', 'block_rowIndex' - The row in which a table cell is located. The first row position is 1.
-- @RowIndex@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
--
-- 'rowSpan', 'block_rowSpan' - The number of rows that a table cell spans. Currently this value is
-- always 1, even if the number of rows spanned is greater than 1.
-- @RowSpan@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
--
-- 'selectionStatus', 'block_selectionStatus' - The selection status of a selection element, such as an option button or
-- check box.
--
-- 'text', 'block_text' - The word or line of text that\'s recognized by Amazon Textract.
--
-- 'textType', 'block_textType' - The kind of text that Amazon Textract has detected. Can check for
-- handwritten text and printed text.
newBlock ::
  Block
newBlock :: Block
newBlock =
  Block'
    { $sel:blockType:Block' :: Maybe BlockType
blockType = forall a. Maybe a
Prelude.Nothing,
      $sel:columnIndex:Block' :: Maybe Natural
columnIndex = forall a. Maybe a
Prelude.Nothing,
      $sel:columnSpan:Block' :: Maybe Natural
columnSpan = forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Block' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:entityTypes:Block' :: Maybe [EntityType]
entityTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:geometry:Block' :: Maybe Geometry
geometry = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Block' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:page:Block' :: Maybe Natural
page = forall a. Maybe a
Prelude.Nothing,
      $sel:query:Block' :: Maybe Query
query = forall a. Maybe a
Prelude.Nothing,
      $sel:relationships:Block' :: Maybe [Relationship]
relationships = forall a. Maybe a
Prelude.Nothing,
      $sel:rowIndex:Block' :: Maybe Natural
rowIndex = forall a. Maybe a
Prelude.Nothing,
      $sel:rowSpan:Block' :: Maybe Natural
rowSpan = forall a. Maybe a
Prelude.Nothing,
      $sel:selectionStatus:Block' :: Maybe SelectionStatus
selectionStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:text:Block' :: Maybe Text
text = forall a. Maybe a
Prelude.Nothing,
      $sel:textType:Block' :: Maybe TextType
textType = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of text item that\'s recognized. In operations for text
-- detection, the following types are returned:
--
-- -   /PAGE/ - Contains a list of the LINE @Block@ objects that are
--     detected on a document page.
--
-- -   /WORD/ - A word detected on a document page. A word is one or more
--     ISO basic Latin script characters that aren\'t separated by spaces.
--
-- -   /LINE/ - A string of tab-delimited, contiguous words that are
--     detected on a document page.
--
-- In text analysis operations, the following types are returned:
--
-- -   /PAGE/ - Contains a list of child @Block@ objects that are detected
--     on a document page.
--
-- -   /KEY_VALUE_SET/ - Stores the KEY and VALUE @Block@ objects for
--     linked text that\'s detected on a document page. Use the
--     @EntityType@ field to determine if a KEY_VALUE_SET object is a KEY
--     @Block@ object or a VALUE @Block@ object.
--
-- -   /WORD/ - A word that\'s detected on a document page. A word is one
--     or more ISO basic Latin script characters that aren\'t separated by
--     spaces.
--
-- -   /LINE/ - A string of tab-delimited, contiguous words that are
--     detected on a document page.
--
-- -   /TABLE/ - A table that\'s detected on a document page. A table is
--     grid-based information with two or more rows or columns, with a cell
--     span of one row and one column each.
--
-- -   /CELL/ - A cell within a detected table. The cell is the parent of
--     the block that contains the text in the cell.
--
-- -   /SELECTION_ELEMENT/ - A selection element such as an option button
--     (radio button) or a check box that\'s detected on a document page.
--     Use the value of @SelectionStatus@ to determine the status of the
--     selection element.
--
-- -   /SIGNATURE/ - The location and confidene score of a signature
--     detected on a document page. Can be returned as part of a Key-Value
--     pair or a detected cell.
--
-- -   /QUERY/ - A question asked during the call of AnalyzeDocument.
--     Contains an alias and an ID that attaches it to its answer.
--
-- -   /QUERY_RESULT/ - A response to a question asked during the call of
--     analyze document. Comes with an alias and ID for ease of locating in
--     a response. Also contains location and confidence score.
block_blockType :: Lens.Lens' Block (Prelude.Maybe BlockType)
block_blockType :: Lens' Block (Maybe BlockType)
block_blockType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe BlockType
blockType :: Maybe BlockType
$sel:blockType:Block' :: Block -> Maybe BlockType
blockType} -> Maybe BlockType
blockType) (\s :: Block
s@Block' {} Maybe BlockType
a -> Block
s {$sel:blockType:Block' :: Maybe BlockType
blockType = Maybe BlockType
a} :: Block)

-- | The column in which a table cell appears. The first column position is
-- 1. @ColumnIndex@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
block_columnIndex :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_columnIndex :: Lens' Block (Maybe Natural)
block_columnIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Natural
columnIndex :: Maybe Natural
$sel:columnIndex:Block' :: Block -> Maybe Natural
columnIndex} -> Maybe Natural
columnIndex) (\s :: Block
s@Block' {} Maybe Natural
a -> Block
s {$sel:columnIndex:Block' :: Maybe Natural
columnIndex = Maybe Natural
a} :: Block)

-- | The number of columns that a table cell spans. Currently this value is
-- always 1, even if the number of columns spanned is greater than 1.
-- @ColumnSpan@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
block_columnSpan :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_columnSpan :: Lens' Block (Maybe Natural)
block_columnSpan = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Natural
columnSpan :: Maybe Natural
$sel:columnSpan:Block' :: Block -> Maybe Natural
columnSpan} -> Maybe Natural
columnSpan) (\s :: Block
s@Block' {} Maybe Natural
a -> Block
s {$sel:columnSpan:Block' :: Maybe Natural
columnSpan = Maybe Natural
a} :: Block)

-- | The confidence score that Amazon Textract has in the accuracy of the
-- recognized text and the accuracy of the geometry points around the
-- recognized text.
block_confidence :: Lens.Lens' Block (Prelude.Maybe Prelude.Double)
block_confidence :: Lens' Block (Maybe Double)
block_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Block' :: Block -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Block
s@Block' {} Maybe Double
a -> Block
s {$sel:confidence:Block' :: Maybe Double
confidence = Maybe Double
a} :: Block)

-- | The type of entity. The following can be returned:
--
-- -   /KEY/ - An identifier for a field on the document.
--
-- -   /VALUE/ - The field text.
--
-- @EntityTypes@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
block_entityTypes :: Lens.Lens' Block (Prelude.Maybe [EntityType])
block_entityTypes :: Lens' Block (Maybe [EntityType])
block_entityTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe [EntityType]
entityTypes :: Maybe [EntityType]
$sel:entityTypes:Block' :: Block -> Maybe [EntityType]
entityTypes} -> Maybe [EntityType]
entityTypes) (\s :: Block
s@Block' {} Maybe [EntityType]
a -> Block
s {$sel:entityTypes:Block' :: Maybe [EntityType]
entityTypes = Maybe [EntityType]
a} :: Block) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The location of the recognized text on the image. It includes an
-- axis-aligned, coarse bounding box that surrounds the text, and a
-- finer-grain polygon for more accurate spatial information.
block_geometry :: Lens.Lens' Block (Prelude.Maybe Geometry)
block_geometry :: Lens' Block (Maybe Geometry)
block_geometry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Geometry
geometry :: Maybe Geometry
$sel:geometry:Block' :: Block -> Maybe Geometry
geometry} -> Maybe Geometry
geometry) (\s :: Block
s@Block' {} Maybe Geometry
a -> Block
s {$sel:geometry:Block' :: Maybe Geometry
geometry = Maybe Geometry
a} :: Block)

-- | The identifier for the recognized text. The identifier is only unique
-- for a single operation.
block_id :: Lens.Lens' Block (Prelude.Maybe Prelude.Text)
block_id :: Lens' Block (Maybe Text)
block_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Text
id :: Maybe Text
$sel:id:Block' :: Block -> Maybe Text
id} -> Maybe Text
id) (\s :: Block
s@Block' {} Maybe Text
a -> Block
s {$sel:id:Block' :: Maybe Text
id = Maybe Text
a} :: Block)

-- | The page on which a block was detected. @Page@ is returned by
-- synchronous and asynchronous operations. Page values greater than 1 are
-- only returned for multipage documents that are in PDF or TIFF format. A
-- scanned image (JPEG\/PNG) provided to an asynchronous operation, even if
-- it contains multiple document pages, is considered a single-page
-- document. This means that for scanned images the value of @Page@ is
-- always 1. Synchronous operations operations will also return a @Page@
-- value of 1 because every input document is considered to be a
-- single-page document.
block_page :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_page :: Lens' Block (Maybe Natural)
block_page = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Natural
page :: Maybe Natural
$sel:page:Block' :: Block -> Maybe Natural
page} -> Maybe Natural
page) (\s :: Block
s@Block' {} Maybe Natural
a -> Block
s {$sel:page:Block' :: Maybe Natural
page = Maybe Natural
a} :: Block)

block_query :: Lens.Lens' Block (Prelude.Maybe Query)
block_query :: Lens' Block (Maybe Query)
block_query = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Query
query :: Maybe Query
$sel:query:Block' :: Block -> Maybe Query
query} -> Maybe Query
query) (\s :: Block
s@Block' {} Maybe Query
a -> Block
s {$sel:query:Block' :: Maybe Query
query = Maybe Query
a} :: Block)

-- | A list of child blocks of the current block. For example, a LINE object
-- has child blocks for each WORD block that\'s part of the line of text.
-- There aren\'t Relationship objects in the list for relationships that
-- don\'t exist, such as when the current block has no child blocks. The
-- list size can be the following:
--
-- -   0 - The block has no child blocks.
--
-- -   1 - The block has child blocks.
block_relationships :: Lens.Lens' Block (Prelude.Maybe [Relationship])
block_relationships :: Lens' Block (Maybe [Relationship])
block_relationships = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe [Relationship]
relationships :: Maybe [Relationship]
$sel:relationships:Block' :: Block -> Maybe [Relationship]
relationships} -> Maybe [Relationship]
relationships) (\s :: Block
s@Block' {} Maybe [Relationship]
a -> Block
s {$sel:relationships:Block' :: Maybe [Relationship]
relationships = Maybe [Relationship]
a} :: Block) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The row in which a table cell is located. The first row position is 1.
-- @RowIndex@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
block_rowIndex :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_rowIndex :: Lens' Block (Maybe Natural)
block_rowIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Natural
rowIndex :: Maybe Natural
$sel:rowIndex:Block' :: Block -> Maybe Natural
rowIndex} -> Maybe Natural
rowIndex) (\s :: Block
s@Block' {} Maybe Natural
a -> Block
s {$sel:rowIndex:Block' :: Maybe Natural
rowIndex = Maybe Natural
a} :: Block)

-- | The number of rows that a table cell spans. Currently this value is
-- always 1, even if the number of rows spanned is greater than 1.
-- @RowSpan@ isn\'t returned by @DetectDocumentText@ and
-- @GetDocumentTextDetection@.
block_rowSpan :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_rowSpan :: Lens' Block (Maybe Natural)
block_rowSpan = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Natural
rowSpan :: Maybe Natural
$sel:rowSpan:Block' :: Block -> Maybe Natural
rowSpan} -> Maybe Natural
rowSpan) (\s :: Block
s@Block' {} Maybe Natural
a -> Block
s {$sel:rowSpan:Block' :: Maybe Natural
rowSpan = Maybe Natural
a} :: Block)

-- | The selection status of a selection element, such as an option button or
-- check box.
block_selectionStatus :: Lens.Lens' Block (Prelude.Maybe SelectionStatus)
block_selectionStatus :: Lens' Block (Maybe SelectionStatus)
block_selectionStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe SelectionStatus
selectionStatus :: Maybe SelectionStatus
$sel:selectionStatus:Block' :: Block -> Maybe SelectionStatus
selectionStatus} -> Maybe SelectionStatus
selectionStatus) (\s :: Block
s@Block' {} Maybe SelectionStatus
a -> Block
s {$sel:selectionStatus:Block' :: Maybe SelectionStatus
selectionStatus = Maybe SelectionStatus
a} :: Block)

-- | The word or line of text that\'s recognized by Amazon Textract.
block_text :: Lens.Lens' Block (Prelude.Maybe Prelude.Text)
block_text :: Lens' Block (Maybe Text)
block_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe Text
text :: Maybe Text
$sel:text:Block' :: Block -> Maybe Text
text} -> Maybe Text
text) (\s :: Block
s@Block' {} Maybe Text
a -> Block
s {$sel:text:Block' :: Maybe Text
text = Maybe Text
a} :: Block)

-- | The kind of text that Amazon Textract has detected. Can check for
-- handwritten text and printed text.
block_textType :: Lens.Lens' Block (Prelude.Maybe TextType)
block_textType :: Lens' Block (Maybe TextType)
block_textType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Block' {Maybe TextType
textType :: Maybe TextType
$sel:textType:Block' :: Block -> Maybe TextType
textType} -> Maybe TextType
textType) (\s :: Block
s@Block' {} Maybe TextType
a -> Block
s {$sel:textType:Block' :: Maybe TextType
textType = Maybe TextType
a} :: Block)

instance Data.FromJSON Block where
  parseJSON :: Value -> Parser Block
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Block"
      ( \Object
x ->
          Maybe BlockType
-> Maybe Natural
-> Maybe Natural
-> Maybe Double
-> Maybe [EntityType]
-> Maybe Geometry
-> Maybe Text
-> Maybe Natural
-> Maybe Query
-> Maybe [Relationship]
-> Maybe Natural
-> Maybe Natural
-> Maybe SelectionStatus
-> Maybe Text
-> Maybe TextType
-> Block
Block'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BlockType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ColumnIndex")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ColumnSpan")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Confidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EntityTypes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Geometry")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Page")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Query")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Relationships" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RowIndex")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RowSpan")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SelectionStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Text")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TextType")
      )

instance Prelude.Hashable Block where
  hashWithSalt :: Int -> Block -> Int
hashWithSalt Int
_salt Block' {Maybe Double
Maybe Natural
Maybe [EntityType]
Maybe [Relationship]
Maybe Text
Maybe BlockType
Maybe Geometry
Maybe Query
Maybe SelectionStatus
Maybe TextType
textType :: Maybe TextType
text :: Maybe Text
selectionStatus :: Maybe SelectionStatus
rowSpan :: Maybe Natural
rowIndex :: Maybe Natural
relationships :: Maybe [Relationship]
query :: Maybe Query
page :: Maybe Natural
id :: Maybe Text
geometry :: Maybe Geometry
entityTypes :: Maybe [EntityType]
confidence :: Maybe Double
columnSpan :: Maybe Natural
columnIndex :: Maybe Natural
blockType :: Maybe BlockType
$sel:textType:Block' :: Block -> Maybe TextType
$sel:text:Block' :: Block -> Maybe Text
$sel:selectionStatus:Block' :: Block -> Maybe SelectionStatus
$sel:rowSpan:Block' :: Block -> Maybe Natural
$sel:rowIndex:Block' :: Block -> Maybe Natural
$sel:relationships:Block' :: Block -> Maybe [Relationship]
$sel:query:Block' :: Block -> Maybe Query
$sel:page:Block' :: Block -> Maybe Natural
$sel:id:Block' :: Block -> Maybe Text
$sel:geometry:Block' :: Block -> Maybe Geometry
$sel:entityTypes:Block' :: Block -> Maybe [EntityType]
$sel:confidence:Block' :: Block -> Maybe Double
$sel:columnSpan:Block' :: Block -> Maybe Natural
$sel:columnIndex:Block' :: Block -> Maybe Natural
$sel:blockType:Block' :: Block -> Maybe BlockType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BlockType
blockType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
columnIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
columnSpan
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EntityType]
entityTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Geometry
geometry
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
page
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Query
query
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Relationship]
relationships
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
rowIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
rowSpan
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SelectionStatus
selectionStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
text
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TextType
textType

instance Prelude.NFData Block where
  rnf :: Block -> ()
rnf Block' {Maybe Double
Maybe Natural
Maybe [EntityType]
Maybe [Relationship]
Maybe Text
Maybe BlockType
Maybe Geometry
Maybe Query
Maybe SelectionStatus
Maybe TextType
textType :: Maybe TextType
text :: Maybe Text
selectionStatus :: Maybe SelectionStatus
rowSpan :: Maybe Natural
rowIndex :: Maybe Natural
relationships :: Maybe [Relationship]
query :: Maybe Query
page :: Maybe Natural
id :: Maybe Text
geometry :: Maybe Geometry
entityTypes :: Maybe [EntityType]
confidence :: Maybe Double
columnSpan :: Maybe Natural
columnIndex :: Maybe Natural
blockType :: Maybe BlockType
$sel:textType:Block' :: Block -> Maybe TextType
$sel:text:Block' :: Block -> Maybe Text
$sel:selectionStatus:Block' :: Block -> Maybe SelectionStatus
$sel:rowSpan:Block' :: Block -> Maybe Natural
$sel:rowIndex:Block' :: Block -> Maybe Natural
$sel:relationships:Block' :: Block -> Maybe [Relationship]
$sel:query:Block' :: Block -> Maybe Query
$sel:page:Block' :: Block -> Maybe Natural
$sel:id:Block' :: Block -> Maybe Text
$sel:geometry:Block' :: Block -> Maybe Geometry
$sel:entityTypes:Block' :: Block -> Maybe [EntityType]
$sel:confidence:Block' :: Block -> Maybe Double
$sel:columnSpan:Block' :: Block -> Maybe Natural
$sel:columnIndex:Block' :: Block -> Maybe Natural
$sel:blockType:Block' :: Block -> Maybe BlockType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BlockType
blockType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
columnIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
columnSpan
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EntityType]
entityTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Geometry
geometry
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
page
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Query
query
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Relationship]
relationships
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
rowIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
rowSpan
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SelectionStatus
selectionStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
text
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TextType
textType