{-# 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.LexRuntime.Types.SentimentResponse
-- 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.LexRuntime.Types.SentimentResponse where

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

-- | The sentiment expressed in an utterance.
--
-- When the bot is configured to send utterances to Amazon Comprehend for
-- sentiment analysis, this field structure contains the result of the
-- analysis.
--
-- /See:/ 'newSentimentResponse' smart constructor.
data SentimentResponse = SentimentResponse'
  { -- | The likelihood that the sentiment was correctly inferred.
    SentimentResponse -> Maybe Text
sentimentScore :: Prelude.Maybe Prelude.Text,
    -- | The inferred sentiment that Amazon Comprehend has the highest confidence
    -- in.
    SentimentResponse -> Maybe Text
sentimentLabel :: Prelude.Maybe Prelude.Text
  }
  deriving (SentimentResponse -> SentimentResponse -> Bool
(SentimentResponse -> SentimentResponse -> Bool)
-> (SentimentResponse -> SentimentResponse -> Bool)
-> Eq SentimentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SentimentResponse -> SentimentResponse -> Bool
$c/= :: SentimentResponse -> SentimentResponse -> Bool
== :: SentimentResponse -> SentimentResponse -> Bool
$c== :: SentimentResponse -> SentimentResponse -> Bool
Prelude.Eq, ReadPrec [SentimentResponse]
ReadPrec SentimentResponse
Int -> ReadS SentimentResponse
ReadS [SentimentResponse]
(Int -> ReadS SentimentResponse)
-> ReadS [SentimentResponse]
-> ReadPrec SentimentResponse
-> ReadPrec [SentimentResponse]
-> Read SentimentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SentimentResponse]
$creadListPrec :: ReadPrec [SentimentResponse]
readPrec :: ReadPrec SentimentResponse
$creadPrec :: ReadPrec SentimentResponse
readList :: ReadS [SentimentResponse]
$creadList :: ReadS [SentimentResponse]
readsPrec :: Int -> ReadS SentimentResponse
$creadsPrec :: Int -> ReadS SentimentResponse
Prelude.Read, Int -> SentimentResponse -> ShowS
[SentimentResponse] -> ShowS
SentimentResponse -> String
(Int -> SentimentResponse -> ShowS)
-> (SentimentResponse -> String)
-> ([SentimentResponse] -> ShowS)
-> Show SentimentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SentimentResponse] -> ShowS
$cshowList :: [SentimentResponse] -> ShowS
show :: SentimentResponse -> String
$cshow :: SentimentResponse -> String
showsPrec :: Int -> SentimentResponse -> ShowS
$cshowsPrec :: Int -> SentimentResponse -> ShowS
Prelude.Show, (forall x. SentimentResponse -> Rep SentimentResponse x)
-> (forall x. Rep SentimentResponse x -> SentimentResponse)
-> Generic SentimentResponse
forall x. Rep SentimentResponse x -> SentimentResponse
forall x. SentimentResponse -> Rep SentimentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SentimentResponse x -> SentimentResponse
$cfrom :: forall x. SentimentResponse -> Rep SentimentResponse x
Prelude.Generic)

-- |
-- Create a value of 'SentimentResponse' 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:
--
-- 'sentimentScore', 'sentimentResponse_sentimentScore' - The likelihood that the sentiment was correctly inferred.
--
-- 'sentimentLabel', 'sentimentResponse_sentimentLabel' - The inferred sentiment that Amazon Comprehend has the highest confidence
-- in.
newSentimentResponse ::
  SentimentResponse
newSentimentResponse :: SentimentResponse
newSentimentResponse =
  SentimentResponse' :: Maybe Text -> Maybe Text -> SentimentResponse
SentimentResponse'
    { $sel:sentimentScore:SentimentResponse' :: Maybe Text
sentimentScore =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sentimentLabel:SentimentResponse' :: Maybe Text
sentimentLabel = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The likelihood that the sentiment was correctly inferred.
sentimentResponse_sentimentScore :: Lens.Lens' SentimentResponse (Prelude.Maybe Prelude.Text)
sentimentResponse_sentimentScore :: (Maybe Text -> f (Maybe Text))
-> SentimentResponse -> f SentimentResponse
sentimentResponse_sentimentScore = (SentimentResponse -> Maybe Text)
-> (SentimentResponse -> Maybe Text -> SentimentResponse)
-> Lens
     SentimentResponse SentimentResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentResponse' {Maybe Text
sentimentScore :: Maybe Text
$sel:sentimentScore:SentimentResponse' :: SentimentResponse -> Maybe Text
sentimentScore} -> Maybe Text
sentimentScore) (\s :: SentimentResponse
s@SentimentResponse' {} Maybe Text
a -> SentimentResponse
s {$sel:sentimentScore:SentimentResponse' :: Maybe Text
sentimentScore = Maybe Text
a} :: SentimentResponse)

-- | The inferred sentiment that Amazon Comprehend has the highest confidence
-- in.
sentimentResponse_sentimentLabel :: Lens.Lens' SentimentResponse (Prelude.Maybe Prelude.Text)
sentimentResponse_sentimentLabel :: (Maybe Text -> f (Maybe Text))
-> SentimentResponse -> f SentimentResponse
sentimentResponse_sentimentLabel = (SentimentResponse -> Maybe Text)
-> (SentimentResponse -> Maybe Text -> SentimentResponse)
-> Lens
     SentimentResponse SentimentResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentResponse' {Maybe Text
sentimentLabel :: Maybe Text
$sel:sentimentLabel:SentimentResponse' :: SentimentResponse -> Maybe Text
sentimentLabel} -> Maybe Text
sentimentLabel) (\s :: SentimentResponse
s@SentimentResponse' {} Maybe Text
a -> SentimentResponse
s {$sel:sentimentLabel:SentimentResponse' :: Maybe Text
sentimentLabel = Maybe Text
a} :: SentimentResponse)

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

instance Prelude.Hashable SentimentResponse

instance Prelude.NFData SentimentResponse