{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Textract.Types.Block where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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.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 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 word or line of text that\'s recognized by Amazon Textract.
    Block -> Maybe Text
text :: Prelude.Maybe Prelude.Text,
    -- | 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 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 page on which a block was detected. @Page@ is returned by
    -- asynchronous operations. Page values greater than 1 are only returned
    -- for multipage documents that are in PDF format. A scanned image
    -- (JPEG\/PNG), even if it contains multiple document pages, is considered
    -- to be a single-page document. The value of @Page@ is always 1.
    -- Synchronous operations don\'t return @Page@ because every input document
    -- is considered to be a single-page document.
    Block -> Maybe Natural
page :: 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 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 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,
    -- | 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 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 kind of text that Amazon Textract has detected. Can check for
    -- handwritten text and printed text.
    Block -> Maybe TextType
textType :: Prelude.Maybe TextType,
    -- | The identifier for the recognized text. The identifier is only unique
    -- for a single operation.
    Block -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | 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.
    Block -> Maybe BlockType
blockType :: Prelude.Maybe BlockType
  }
  deriving (Block -> Block -> Bool
(Block -> Block -> Bool) -> (Block -> Block -> Bool) -> Eq Block
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]
(Int -> ReadS Block)
-> ReadS [Block]
-> ReadPrec Block
-> ReadPrec [Block]
-> Read 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
(Int -> Block -> ShowS)
-> (Block -> String) -> ([Block] -> ShowS) -> Show Block
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. Block -> Rep Block x)
-> (forall x. Rep Block x -> Block) -> Generic Block
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:
--
-- '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@.
--
-- 'text', 'block_text' - The word or line of text that\'s recognized by Amazon Textract.
--
-- '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@.
--
-- '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@.
--
-- 'page', 'block_page' - The page on which a block was detected. @Page@ is returned by
-- asynchronous operations. Page values greater than 1 are only returned
-- for multipage documents that are in PDF format. A scanned image
-- (JPEG\/PNG), even if it contains multiple document pages, is considered
-- to be a single-page document. The value of @Page@ is always 1.
-- Synchronous operations don\'t return @Page@ because every input document
-- is considered to be a single-page document.
--
-- '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.
--
-- '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@.
--
-- '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.
--
-- '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.
--
-- '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.
--
-- 'textType', 'block_textType' - The kind of text that Amazon Textract has detected. Can check for
-- handwritten text and printed text.
--
-- 'id', 'block_id' - The identifier for the recognized text. The identifier is only unique
-- for a single operation.
--
-- '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.
newBlock ::
  Block
newBlock :: Block
newBlock =
  Block' :: Maybe Natural
-> Maybe Text
-> Maybe [EntityType]
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe SelectionStatus
-> Maybe Natural
-> Maybe Double
-> Maybe [Relationship]
-> Maybe Geometry
-> Maybe TextType
-> Maybe Text
-> Maybe BlockType
-> Block
Block'
    { $sel:columnSpan:Block' :: Maybe Natural
columnSpan = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:text:Block' :: Maybe Text
text = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entityTypes:Block' :: Maybe [EntityType]
entityTypes = Maybe [EntityType]
forall a. Maybe a
Prelude.Nothing,
      $sel:columnIndex:Block' :: Maybe Natural
columnIndex = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:page:Block' :: Maybe Natural
page = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:rowSpan:Block' :: Maybe Natural
rowSpan = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:selectionStatus:Block' :: Maybe SelectionStatus
selectionStatus = Maybe SelectionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:rowIndex:Block' :: Maybe Natural
rowIndex = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Block' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:relationships:Block' :: Maybe [Relationship]
relationships = Maybe [Relationship]
forall a. Maybe a
Prelude.Nothing,
      $sel:geometry:Block' :: Maybe Geometry
geometry = Maybe Geometry
forall a. Maybe a
Prelude.Nothing,
      $sel:textType:Block' :: Maybe TextType
textType = Maybe TextType
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Block' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:blockType:Block' :: Maybe BlockType
blockType = Maybe BlockType
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural)) -> Block -> f Block
block_columnSpan = (Block -> Maybe Natural)
-> (Block -> Maybe Natural -> Block)
-> Lens Block Block (Maybe Natural) (Maybe Natural)
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 word or line of text that\'s recognized by Amazon Textract.
block_text :: Lens.Lens' Block (Prelude.Maybe Prelude.Text)
block_text :: (Maybe Text -> f (Maybe Text)) -> Block -> f Block
block_text = (Block -> Maybe Text)
-> (Block -> Maybe Text -> Block)
-> Lens Block Block (Maybe Text) (Maybe 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 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 :: (Maybe [EntityType] -> f (Maybe [EntityType])) -> Block -> f Block
block_entityTypes = (Block -> Maybe [EntityType])
-> (Block -> Maybe [EntityType] -> Block)
-> Lens Block Block (Maybe [EntityType]) (Maybe [EntityType])
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) ((Maybe [EntityType] -> f (Maybe [EntityType]))
 -> Block -> f Block)
-> ((Maybe [EntityType] -> f (Maybe [EntityType]))
    -> Maybe [EntityType] -> f (Maybe [EntityType]))
-> (Maybe [EntityType] -> f (Maybe [EntityType]))
-> Block
-> f Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EntityType] [EntityType] [EntityType] [EntityType]
-> Iso
     (Maybe [EntityType])
     (Maybe [EntityType])
     (Maybe [EntityType])
     (Maybe [EntityType])
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 AnIso [EntityType] [EntityType] [EntityType] [EntityType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Natural -> f (Maybe Natural)) -> Block -> f Block
block_columnIndex = (Block -> Maybe Natural)
-> (Block -> Maybe Natural -> Block)
-> Lens Block Block (Maybe Natural) (Maybe Natural)
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 page on which a block was detected. @Page@ is returned by
-- asynchronous operations. Page values greater than 1 are only returned
-- for multipage documents that are in PDF format. A scanned image
-- (JPEG\/PNG), even if it contains multiple document pages, is considered
-- to be a single-page document. The value of @Page@ is always 1.
-- Synchronous operations don\'t return @Page@ because every input document
-- is considered to be a single-page document.
block_page :: Lens.Lens' Block (Prelude.Maybe Prelude.Natural)
block_page :: (Maybe Natural -> f (Maybe Natural)) -> Block -> f Block
block_page = (Block -> Maybe Natural)
-> (Block -> Maybe Natural -> Block)
-> Lens Block Block (Maybe Natural) (Maybe Natural)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural)) -> Block -> f Block
block_rowSpan = (Block -> Maybe Natural)
-> (Block -> Maybe Natural -> Block)
-> Lens Block Block (Maybe Natural) (Maybe Natural)
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 :: (Maybe SelectionStatus -> f (Maybe SelectionStatus))
-> Block -> f Block
block_selectionStatus = (Block -> Maybe SelectionStatus)
-> (Block -> Maybe SelectionStatus -> Block)
-> Lens Block Block (Maybe SelectionStatus) (Maybe 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 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 :: (Maybe Natural -> f (Maybe Natural)) -> Block -> f Block
block_rowIndex = (Block -> Maybe Natural)
-> (Block -> Maybe Natural -> Block)
-> Lens Block Block (Maybe Natural) (Maybe Natural)
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 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 :: (Maybe Double -> f (Maybe Double)) -> Block -> f Block
block_confidence = (Block -> Maybe Double)
-> (Block -> Maybe Double -> Block)
-> Lens Block Block (Maybe Double) (Maybe Double)
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)

-- | 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 :: (Maybe [Relationship] -> f (Maybe [Relationship]))
-> Block -> f Block
block_relationships = (Block -> Maybe [Relationship])
-> (Block -> Maybe [Relationship] -> Block)
-> Lens Block Block (Maybe [Relationship]) (Maybe [Relationship])
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) ((Maybe [Relationship] -> f (Maybe [Relationship]))
 -> Block -> f Block)
-> ((Maybe [Relationship] -> f (Maybe [Relationship]))
    -> Maybe [Relationship] -> f (Maybe [Relationship]))
-> (Maybe [Relationship] -> f (Maybe [Relationship]))
-> Block
-> f Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Relationship] [Relationship] [Relationship] [Relationship]
-> Iso
     (Maybe [Relationship])
     (Maybe [Relationship])
     (Maybe [Relationship])
     (Maybe [Relationship])
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 AnIso [Relationship] [Relationship] [Relationship] [Relationship]
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 :: (Maybe Geometry -> f (Maybe Geometry)) -> Block -> f Block
block_geometry = (Block -> Maybe Geometry)
-> (Block -> Maybe Geometry -> Block)
-> Lens Block Block (Maybe Geometry) (Maybe 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 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 :: (Maybe TextType -> f (Maybe TextType)) -> Block -> f Block
block_textType = (Block -> Maybe TextType)
-> (Block -> Maybe TextType -> Block)
-> Lens Block Block (Maybe TextType) (Maybe 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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Block -> f Block
block_id = (Block -> Maybe Text)
-> (Block -> Maybe Text -> Block)
-> Lens Block Block (Maybe Text) (Maybe Text)
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 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.
block_blockType :: Lens.Lens' Block (Prelude.Maybe BlockType)
block_blockType :: (Maybe BlockType -> f (Maybe BlockType)) -> Block -> f Block
block_blockType = (Block -> Maybe BlockType)
-> (Block -> Maybe BlockType -> Block)
-> Lens Block Block (Maybe BlockType) (Maybe 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)

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

instance Prelude.Hashable Block

instance Prelude.NFData Block