{-# 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.Comprehend.Types.DocumentLabel
-- 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.Comprehend.Types.DocumentLabel 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

-- | Specifies one of the label or labels that categorize the document being
-- analyzed.
--
-- /See:/ 'newDocumentLabel' smart constructor.
data DocumentLabel = DocumentLabel'
  { -- | The name of the label.
    DocumentLabel -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Page number where the label occurs. This field is present in the
    -- response only if your request includes the @Byte@ parameter.
    DocumentLabel -> Maybe Int
page :: Prelude.Maybe Prelude.Int,
    -- | The confidence score that Amazon Comprehend has this label correctly
    -- attributed.
    DocumentLabel -> Maybe Double
score :: Prelude.Maybe Prelude.Double
  }
  deriving (DocumentLabel -> DocumentLabel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentLabel -> DocumentLabel -> Bool
$c/= :: DocumentLabel -> DocumentLabel -> Bool
== :: DocumentLabel -> DocumentLabel -> Bool
$c== :: DocumentLabel -> DocumentLabel -> Bool
Prelude.Eq, ReadPrec [DocumentLabel]
ReadPrec DocumentLabel
Int -> ReadS DocumentLabel
ReadS [DocumentLabel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentLabel]
$creadListPrec :: ReadPrec [DocumentLabel]
readPrec :: ReadPrec DocumentLabel
$creadPrec :: ReadPrec DocumentLabel
readList :: ReadS [DocumentLabel]
$creadList :: ReadS [DocumentLabel]
readsPrec :: Int -> ReadS DocumentLabel
$creadsPrec :: Int -> ReadS DocumentLabel
Prelude.Read, Int -> DocumentLabel -> ShowS
[DocumentLabel] -> ShowS
DocumentLabel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentLabel] -> ShowS
$cshowList :: [DocumentLabel] -> ShowS
show :: DocumentLabel -> String
$cshow :: DocumentLabel -> String
showsPrec :: Int -> DocumentLabel -> ShowS
$cshowsPrec :: Int -> DocumentLabel -> ShowS
Prelude.Show, forall x. Rep DocumentLabel x -> DocumentLabel
forall x. DocumentLabel -> Rep DocumentLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentLabel x -> DocumentLabel
$cfrom :: forall x. DocumentLabel -> Rep DocumentLabel x
Prelude.Generic)

-- |
-- Create a value of 'DocumentLabel' 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:
--
-- 'name', 'documentLabel_name' - The name of the label.
--
-- 'page', 'documentLabel_page' - Page number where the label occurs. This field is present in the
-- response only if your request includes the @Byte@ parameter.
--
-- 'score', 'documentLabel_score' - The confidence score that Amazon Comprehend has this label correctly
-- attributed.
newDocumentLabel ::
  DocumentLabel
newDocumentLabel :: DocumentLabel
newDocumentLabel =
  DocumentLabel'
    { $sel:name:DocumentLabel' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:page:DocumentLabel' :: Maybe Int
page = forall a. Maybe a
Prelude.Nothing,
      $sel:score:DocumentLabel' :: Maybe Double
score = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the label.
documentLabel_name :: Lens.Lens' DocumentLabel (Prelude.Maybe Prelude.Text)
documentLabel_name :: Lens' DocumentLabel (Maybe Text)
documentLabel_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentLabel' {Maybe Text
name :: Maybe Text
$sel:name:DocumentLabel' :: DocumentLabel -> Maybe Text
name} -> Maybe Text
name) (\s :: DocumentLabel
s@DocumentLabel' {} Maybe Text
a -> DocumentLabel
s {$sel:name:DocumentLabel' :: Maybe Text
name = Maybe Text
a} :: DocumentLabel)

-- | Page number where the label occurs. This field is present in the
-- response only if your request includes the @Byte@ parameter.
documentLabel_page :: Lens.Lens' DocumentLabel (Prelude.Maybe Prelude.Int)
documentLabel_page :: Lens' DocumentLabel (Maybe Int)
documentLabel_page = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentLabel' {Maybe Int
page :: Maybe Int
$sel:page:DocumentLabel' :: DocumentLabel -> Maybe Int
page} -> Maybe Int
page) (\s :: DocumentLabel
s@DocumentLabel' {} Maybe Int
a -> DocumentLabel
s {$sel:page:DocumentLabel' :: Maybe Int
page = Maybe Int
a} :: DocumentLabel)

-- | The confidence score that Amazon Comprehend has this label correctly
-- attributed.
documentLabel_score :: Lens.Lens' DocumentLabel (Prelude.Maybe Prelude.Double)
documentLabel_score :: Lens' DocumentLabel (Maybe Double)
documentLabel_score = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentLabel' {Maybe Double
score :: Maybe Double
$sel:score:DocumentLabel' :: DocumentLabel -> Maybe Double
score} -> Maybe Double
score) (\s :: DocumentLabel
s@DocumentLabel' {} Maybe Double
a -> DocumentLabel
s {$sel:score:DocumentLabel' :: Maybe Double
score = Maybe Double
a} :: DocumentLabel)

instance Data.FromJSON DocumentLabel where
  parseJSON :: Value -> Parser DocumentLabel
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentLabel"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> Maybe Double -> DocumentLabel
DocumentLabel'
            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
"Name")
            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
"Score")
      )

instance Prelude.Hashable DocumentLabel where
  hashWithSalt :: Int -> DocumentLabel -> Int
hashWithSalt Int
_salt DocumentLabel' {Maybe Double
Maybe Int
Maybe Text
score :: Maybe Double
page :: Maybe Int
name :: Maybe Text
$sel:score:DocumentLabel' :: DocumentLabel -> Maybe Double
$sel:page:DocumentLabel' :: DocumentLabel -> Maybe Int
$sel:name:DocumentLabel' :: DocumentLabel -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
page
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
score

instance Prelude.NFData DocumentLabel where
  rnf :: DocumentLabel -> ()
rnf DocumentLabel' {Maybe Double
Maybe Int
Maybe Text
score :: Maybe Double
page :: Maybe Int
name :: Maybe Text
$sel:score:DocumentLabel' :: DocumentLabel -> Maybe Double
$sel:page:DocumentLabel' :: DocumentLabel -> Maybe Int
$sel:name:DocumentLabel' :: DocumentLabel -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
page
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
score