{-# 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.SentimentScore
-- 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.SentimentScore 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

-- | Describes the level of confidence that Amazon Comprehend has in the
-- accuracy of its detection of sentiments.
--
-- /See:/ 'newSentimentScore' smart constructor.
data SentimentScore = SentimentScore'
  { -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- its detection of the @MIXED@ sentiment.
    SentimentScore -> Maybe Double
mixed :: Prelude.Maybe Prelude.Double,
    -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- its detection of the @NEGATIVE@ sentiment.
    SentimentScore -> Maybe Double
negative :: Prelude.Maybe Prelude.Double,
    -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- its detection of the @NEUTRAL@ sentiment.
    SentimentScore -> Maybe Double
neutral :: Prelude.Maybe Prelude.Double,
    -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- its detection of the @POSITIVE@ sentiment.
    SentimentScore -> Maybe Double
positive :: Prelude.Maybe Prelude.Double
  }
  deriving (SentimentScore -> SentimentScore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SentimentScore -> SentimentScore -> Bool
$c/= :: SentimentScore -> SentimentScore -> Bool
== :: SentimentScore -> SentimentScore -> Bool
$c== :: SentimentScore -> SentimentScore -> Bool
Prelude.Eq, ReadPrec [SentimentScore]
ReadPrec SentimentScore
Int -> ReadS SentimentScore
ReadS [SentimentScore]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SentimentScore]
$creadListPrec :: ReadPrec [SentimentScore]
readPrec :: ReadPrec SentimentScore
$creadPrec :: ReadPrec SentimentScore
readList :: ReadS [SentimentScore]
$creadList :: ReadS [SentimentScore]
readsPrec :: Int -> ReadS SentimentScore
$creadsPrec :: Int -> ReadS SentimentScore
Prelude.Read, Int -> SentimentScore -> ShowS
[SentimentScore] -> ShowS
SentimentScore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SentimentScore] -> ShowS
$cshowList :: [SentimentScore] -> ShowS
show :: SentimentScore -> String
$cshow :: SentimentScore -> String
showsPrec :: Int -> SentimentScore -> ShowS
$cshowsPrec :: Int -> SentimentScore -> ShowS
Prelude.Show, forall x. Rep SentimentScore x -> SentimentScore
forall x. SentimentScore -> Rep SentimentScore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SentimentScore x -> SentimentScore
$cfrom :: forall x. SentimentScore -> Rep SentimentScore x
Prelude.Generic)

-- |
-- Create a value of 'SentimentScore' 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:
--
-- 'mixed', 'sentimentScore_mixed' - The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @MIXED@ sentiment.
--
-- 'negative', 'sentimentScore_negative' - The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @NEGATIVE@ sentiment.
--
-- 'neutral', 'sentimentScore_neutral' - The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @NEUTRAL@ sentiment.
--
-- 'positive', 'sentimentScore_positive' - The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @POSITIVE@ sentiment.
newSentimentScore ::
  SentimentScore
newSentimentScore :: SentimentScore
newSentimentScore =
  SentimentScore'
    { $sel:mixed:SentimentScore' :: Maybe Double
mixed = forall a. Maybe a
Prelude.Nothing,
      $sel:negative:SentimentScore' :: Maybe Double
negative = forall a. Maybe a
Prelude.Nothing,
      $sel:neutral:SentimentScore' :: Maybe Double
neutral = forall a. Maybe a
Prelude.Nothing,
      $sel:positive:SentimentScore' :: Maybe Double
positive = forall a. Maybe a
Prelude.Nothing
    }

-- | The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @MIXED@ sentiment.
sentimentScore_mixed :: Lens.Lens' SentimentScore (Prelude.Maybe Prelude.Double)
sentimentScore_mixed :: Lens' SentimentScore (Maybe Double)
sentimentScore_mixed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentScore' {Maybe Double
mixed :: Maybe Double
$sel:mixed:SentimentScore' :: SentimentScore -> Maybe Double
mixed} -> Maybe Double
mixed) (\s :: SentimentScore
s@SentimentScore' {} Maybe Double
a -> SentimentScore
s {$sel:mixed:SentimentScore' :: Maybe Double
mixed = Maybe Double
a} :: SentimentScore)

-- | The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @NEGATIVE@ sentiment.
sentimentScore_negative :: Lens.Lens' SentimentScore (Prelude.Maybe Prelude.Double)
sentimentScore_negative :: Lens' SentimentScore (Maybe Double)
sentimentScore_negative = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentScore' {Maybe Double
negative :: Maybe Double
$sel:negative:SentimentScore' :: SentimentScore -> Maybe Double
negative} -> Maybe Double
negative) (\s :: SentimentScore
s@SentimentScore' {} Maybe Double
a -> SentimentScore
s {$sel:negative:SentimentScore' :: Maybe Double
negative = Maybe Double
a} :: SentimentScore)

-- | The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @NEUTRAL@ sentiment.
sentimentScore_neutral :: Lens.Lens' SentimentScore (Prelude.Maybe Prelude.Double)
sentimentScore_neutral :: Lens' SentimentScore (Maybe Double)
sentimentScore_neutral = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentScore' {Maybe Double
neutral :: Maybe Double
$sel:neutral:SentimentScore' :: SentimentScore -> Maybe Double
neutral} -> Maybe Double
neutral) (\s :: SentimentScore
s@SentimentScore' {} Maybe Double
a -> SentimentScore
s {$sel:neutral:SentimentScore' :: Maybe Double
neutral = Maybe Double
a} :: SentimentScore)

-- | The level of confidence that Amazon Comprehend has in the accuracy of
-- its detection of the @POSITIVE@ sentiment.
sentimentScore_positive :: Lens.Lens' SentimentScore (Prelude.Maybe Prelude.Double)
sentimentScore_positive :: Lens' SentimentScore (Maybe Double)
sentimentScore_positive = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentScore' {Maybe Double
positive :: Maybe Double
$sel:positive:SentimentScore' :: SentimentScore -> Maybe Double
positive} -> Maybe Double
positive) (\s :: SentimentScore
s@SentimentScore' {} Maybe Double
a -> SentimentScore
s {$sel:positive:SentimentScore' :: Maybe Double
positive = Maybe Double
a} :: SentimentScore)

instance Data.FromJSON SentimentScore where
  parseJSON :: Value -> Parser SentimentScore
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SentimentScore"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore
SentimentScore'
            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
"Mixed")
            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
"Negative")
            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
"Neutral")
            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
"Positive")
      )

instance Prelude.Hashable SentimentScore where
  hashWithSalt :: Int -> SentimentScore -> Int
hashWithSalt Int
_salt SentimentScore' {Maybe Double
positive :: Maybe Double
neutral :: Maybe Double
negative :: Maybe Double
mixed :: Maybe Double
$sel:positive:SentimentScore' :: SentimentScore -> Maybe Double
$sel:neutral:SentimentScore' :: SentimentScore -> Maybe Double
$sel:negative:SentimentScore' :: SentimentScore -> Maybe Double
$sel:mixed:SentimentScore' :: SentimentScore -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
mixed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
negative
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
neutral
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
positive

instance Prelude.NFData SentimentScore where
  rnf :: SentimentScore -> ()
rnf SentimentScore' {Maybe Double
positive :: Maybe Double
neutral :: Maybe Double
negative :: Maybe Double
mixed :: Maybe Double
$sel:positive:SentimentScore' :: SentimentScore -> Maybe Double
$sel:neutral:SentimentScore' :: SentimentScore -> Maybe Double
$sel:negative:SentimentScore' :: SentimentScore -> Maybe Double
$sel:mixed:SentimentScore' :: SentimentScore -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
mixed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
negative
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
neutral
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
positive