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

-- |
-- Create a value of 'DocumentClass' 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', 'documentClass_name' - The name of the class.
--
-- 'page', 'documentClass_page' - Page number in the input document. This field is present in the response
-- only if your request includes the @Byte@ parameter.
--
-- 'score', 'documentClass_score' - The confidence score that Amazon Comprehend has this class correctly
-- attributed.
newDocumentClass ::
  DocumentClass
newDocumentClass :: DocumentClass
newDocumentClass =
  DocumentClass'
    { $sel:name:DocumentClass' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:page:DocumentClass' :: Maybe Int
page = forall a. Maybe a
Prelude.Nothing,
      $sel:score:DocumentClass' :: Maybe Double
score = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Data.FromJSON DocumentClass where
  parseJSON :: Value -> Parser DocumentClass
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentClass"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> Maybe Double -> DocumentClass
DocumentClass'
            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 DocumentClass where
  hashWithSalt :: Int -> DocumentClass -> Int
hashWithSalt Int
_salt DocumentClass' {Maybe Double
Maybe Int
Maybe Text
score :: Maybe Double
page :: Maybe Int
name :: Maybe Text
$sel:score:DocumentClass' :: DocumentClass -> Maybe Double
$sel:page:DocumentClass' :: DocumentClass -> Maybe Int
$sel:name:DocumentClass' :: DocumentClass -> 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 DocumentClass where
  rnf :: DocumentClass -> ()
rnf DocumentClass' {Maybe Double
Maybe Int
Maybe Text
score :: Maybe Double
page :: Maybe Int
name :: Maybe Text
$sel:score:DocumentClass' :: DocumentClass -> Maybe Double
$sel:page:DocumentClass' :: DocumentClass -> Maybe Int
$sel:name:DocumentClass' :: DocumentClass -> 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