{-# 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-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.DocumentClass where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the class that categorizes the document being analyzed
--
-- /See:/ 'newDocumentClass' smart constructor.
data DocumentClass = DocumentClass'
  { -- | The confidence score that Amazon Comprehend has this class correctly
    -- attributed.
    DocumentClass -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | The name of the class.
    DocumentClass -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (DocumentClass -> DocumentClass -> Bool
(DocumentClass -> DocumentClass -> Bool)
-> (DocumentClass -> DocumentClass -> Bool) -> Eq DocumentClass
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]
(Int -> ReadS DocumentClass)
-> ReadS [DocumentClass]
-> ReadPrec DocumentClass
-> ReadPrec [DocumentClass]
-> Read 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
(Int -> DocumentClass -> ShowS)
-> (DocumentClass -> String)
-> ([DocumentClass] -> ShowS)
-> Show DocumentClass
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. DocumentClass -> Rep DocumentClass x)
-> (forall x. Rep DocumentClass x -> DocumentClass)
-> Generic DocumentClass
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:
--
-- 'score', 'documentClass_score' - The confidence score that Amazon Comprehend has this class correctly
-- attributed.
--
-- 'name', 'documentClass_name' - The name of the class.
newDocumentClass ::
  DocumentClass
newDocumentClass :: DocumentClass
newDocumentClass =
  DocumentClass' :: Maybe Double -> Maybe Text -> DocumentClass
DocumentClass'
    { $sel:score:DocumentClass' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DocumentClass' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the class.
documentClass_name :: Lens.Lens' DocumentClass (Prelude.Maybe Prelude.Text)
documentClass_name :: (Maybe Text -> f (Maybe Text)) -> DocumentClass -> f DocumentClass
documentClass_name = (DocumentClass -> Maybe Text)
-> (DocumentClass -> Maybe Text -> DocumentClass)
-> Lens DocumentClass DocumentClass (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData DocumentClass