{-# 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.Prediction
-- 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.Textract.Types.Prediction 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

-- | Contains information regarding predicted values returned by Amazon
-- Textract operations, including the predicted value and the confidence in
-- the predicted value.
--
-- /See:/ 'newPrediction' smart constructor.
data Prediction = Prediction'
  { -- | Amazon Textract\'s confidence in its predicted value.
    Prediction -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The predicted value of a detected object.
    Prediction -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (Prediction -> Prediction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Prediction -> Prediction -> Bool
$c/= :: Prediction -> Prediction -> Bool
== :: Prediction -> Prediction -> Bool
$c== :: Prediction -> Prediction -> Bool
Prelude.Eq, ReadPrec [Prediction]
ReadPrec Prediction
Int -> ReadS Prediction
ReadS [Prediction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Prediction]
$creadListPrec :: ReadPrec [Prediction]
readPrec :: ReadPrec Prediction
$creadPrec :: ReadPrec Prediction
readList :: ReadS [Prediction]
$creadList :: ReadS [Prediction]
readsPrec :: Int -> ReadS Prediction
$creadsPrec :: Int -> ReadS Prediction
Prelude.Read, Int -> Prediction -> ShowS
[Prediction] -> ShowS
Prediction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Prediction] -> ShowS
$cshowList :: [Prediction] -> ShowS
show :: Prediction -> String
$cshow :: Prediction -> String
showsPrec :: Int -> Prediction -> ShowS
$cshowsPrec :: Int -> Prediction -> ShowS
Prelude.Show, forall x. Rep Prediction x -> Prediction
forall x. Prediction -> Rep Prediction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Prediction x -> Prediction
$cfrom :: forall x. Prediction -> Rep Prediction x
Prelude.Generic)

-- |
-- Create a value of 'Prediction' 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:
--
-- 'confidence', 'prediction_confidence' - Amazon Textract\'s confidence in its predicted value.
--
-- 'value', 'prediction_value' - The predicted value of a detected object.
newPrediction ::
  Prediction
newPrediction :: Prediction
newPrediction =
  Prediction'
    { $sel:confidence:Prediction' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Prediction' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | Amazon Textract\'s confidence in its predicted value.
prediction_confidence :: Lens.Lens' Prediction (Prelude.Maybe Prelude.Double)
prediction_confidence :: Lens' Prediction (Maybe Double)
prediction_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Prediction' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Prediction' :: Prediction -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Prediction
s@Prediction' {} Maybe Double
a -> Prediction
s {$sel:confidence:Prediction' :: Maybe Double
confidence = Maybe Double
a} :: Prediction)

-- | The predicted value of a detected object.
prediction_value :: Lens.Lens' Prediction (Prelude.Maybe Prelude.Text)
prediction_value :: Lens' Prediction (Maybe Text)
prediction_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Prediction' {Maybe Text
value :: Maybe Text
$sel:value:Prediction' :: Prediction -> Maybe Text
value} -> Maybe Text
value) (\s :: Prediction
s@Prediction' {} Maybe Text
a -> Prediction
s {$sel:value:Prediction' :: Maybe Text
value = Maybe Text
a} :: Prediction)

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

instance Prelude.Hashable Prediction where
  hashWithSalt :: Int -> Prediction -> Int
hashWithSalt Int
_salt Prediction' {Maybe Double
Maybe Text
value :: Maybe Text
confidence :: Maybe Double
$sel:value:Prediction' :: Prediction -> Maybe Text
$sel:confidence:Prediction' :: Prediction -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData Prediction where
  rnf :: Prediction -> ()
rnf Prediction' {Maybe Double
Maybe Text
value :: Maybe Text
confidence :: Maybe Double
$sel:value:Prediction' :: Prediction -> Maybe Text
$sel:confidence:Prediction' :: Prediction -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value