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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SentimentScore -> SentimentScore -> Bool)
-> (SentimentScore -> SentimentScore -> Bool) -> Eq SentimentScore
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]
(Int -> ReadS SentimentScore)
-> ReadS [SentimentScore]
-> ReadPrec SentimentScore
-> ReadPrec [SentimentScore]
-> Read 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
(Int -> SentimentScore -> ShowS)
-> (SentimentScore -> String)
-> ([SentimentScore] -> ShowS)
-> Show SentimentScore
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. SentimentScore -> Rep SentimentScore x)
-> (forall x. Rep SentimentScore x -> SentimentScore)
-> Generic SentimentScore
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' :: Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore
SentimentScore'
    { $sel:mixed:SentimentScore' :: Maybe Double
mixed = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:negative:SentimentScore' :: Maybe Double
negative = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:neutral:SentimentScore' :: Maybe Double
neutral = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:positive:SentimentScore' :: Maybe Double
positive = Maybe Double
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 :: (Maybe Double -> f (Maybe Double))
-> SentimentScore -> f SentimentScore
sentimentScore_mixed = (SentimentScore -> Maybe Double)
-> (SentimentScore -> Maybe Double -> SentimentScore)
-> Lens SentimentScore SentimentScore (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double))
-> SentimentScore -> f SentimentScore
sentimentScore_negative = (SentimentScore -> Maybe Double)
-> (SentimentScore -> Maybe Double -> SentimentScore)
-> Lens SentimentScore SentimentScore (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double))
-> SentimentScore -> f SentimentScore
sentimentScore_neutral = (SentimentScore -> Maybe Double)
-> (SentimentScore -> Maybe Double -> SentimentScore)
-> Lens SentimentScore SentimentScore (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double))
-> SentimentScore -> f SentimentScore
sentimentScore_positive = (SentimentScore -> Maybe Double)
-> (SentimentScore -> Maybe Double -> SentimentScore)
-> Lens SentimentScore SentimentScore (Maybe Double) (Maybe Double)
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 Core.FromJSON SentimentScore where
  parseJSON :: Value -> Parser SentimentScore
parseJSON =
    String
-> (Object -> Parser SentimentScore)
-> Value
-> Parser SentimentScore
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SentimentScore"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore
SentimentScore'
            (Maybe Double
 -> Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore)
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
"Mixed")
            Parser
  (Maybe Double -> Maybe Double -> Maybe Double -> SentimentScore)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> SentimentScore)
forall (f :: * -> *) a b. Applicative f => 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
"Negative")
            Parser (Maybe Double -> Maybe Double -> SentimentScore)
-> Parser (Maybe Double) -> Parser (Maybe Double -> SentimentScore)
forall (f :: * -> *) a b. Applicative f => 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
"Neutral")
            Parser (Maybe Double -> SentimentScore)
-> Parser (Maybe Double) -> Parser SentimentScore
forall (f :: * -> *) a b. Applicative f => 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
"Positive")
      )

instance Prelude.Hashable SentimentScore

instance Prelude.NFData SentimentScore