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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 confidence score that Amazon Comprehend has this label correctly
    -- attributed.
    DocumentLabel -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | The name of the label.
    DocumentLabel -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (DocumentLabel -> DocumentLabel -> Bool
(DocumentLabel -> DocumentLabel -> Bool)
-> (DocumentLabel -> DocumentLabel -> Bool) -> Eq DocumentLabel
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]
(Int -> ReadS DocumentLabel)
-> ReadS [DocumentLabel]
-> ReadPrec DocumentLabel
-> ReadPrec [DocumentLabel]
-> Read 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
(Int -> DocumentLabel -> ShowS)
-> (DocumentLabel -> String)
-> ([DocumentLabel] -> ShowS)
-> Show DocumentLabel
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. DocumentLabel -> Rep DocumentLabel x)
-> (forall x. Rep DocumentLabel x -> DocumentLabel)
-> Generic DocumentLabel
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:
--
-- 'score', 'documentLabel_score' - The confidence score that Amazon Comprehend has this label correctly
-- attributed.
--
-- 'name', 'documentLabel_name' - The name of the label.
newDocumentLabel ::
  DocumentLabel
newDocumentLabel :: DocumentLabel
newDocumentLabel =
  DocumentLabel' :: Maybe Double -> Maybe Text -> DocumentLabel
DocumentLabel'
    { $sel:score:DocumentLabel' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DocumentLabel' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The confidence score that Amazon Comprehend has this label correctly
-- attributed.
documentLabel_score :: Lens.Lens' DocumentLabel (Prelude.Maybe Prelude.Double)
documentLabel_score :: (Maybe Double -> f (Maybe Double))
-> DocumentLabel -> f DocumentLabel
documentLabel_score = (DocumentLabel -> Maybe Double)
-> (DocumentLabel -> Maybe Double -> DocumentLabel)
-> Lens DocumentLabel DocumentLabel (Maybe Double) (Maybe Double)
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)

-- | The name of the label.
documentLabel_name :: Lens.Lens' DocumentLabel (Prelude.Maybe Prelude.Text)
documentLabel_name :: (Maybe Text -> f (Maybe Text)) -> DocumentLabel -> f DocumentLabel
documentLabel_name = (DocumentLabel -> Maybe Text)
-> (DocumentLabel -> Maybe Text -> DocumentLabel)
-> Lens DocumentLabel DocumentLabel (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable DocumentLabel

instance Prelude.NFData DocumentLabel