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

import Amazonka.Comprehend.Types.MentionSentiment
import Amazonka.Comprehend.Types.TargetedSentimentEntityType
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

-- | Information about one mention of an entity. The mention information
-- includes the location of the mention in the text and the sentiment of
-- the mention.
--
-- For more information about targeted sentiment, see
-- <https://docs.aws.amazon.com/comprehend/latest/dg/how-targeted-sentiment.html Targeted sentiment>.
--
-- /See:/ 'newTargetedSentimentMention' smart constructor.
data TargetedSentimentMention = TargetedSentimentMention'
  { -- | The offset into the document text where the mention begins.
    TargetedSentimentMention -> Maybe Int
beginOffset :: Prelude.Maybe Prelude.Int,
    -- | The offset into the document text where the mention ends.
    TargetedSentimentMention -> Maybe Int
endOffset :: Prelude.Maybe Prelude.Int,
    -- | The confidence that all the entities mentioned in the group relate to
    -- the same entity.
    TargetedSentimentMention -> Maybe Double
groupScore :: Prelude.Maybe Prelude.Double,
    -- | Contains the sentiment and sentiment score for the mention.
    TargetedSentimentMention -> Maybe MentionSentiment
mentionSentiment :: Prelude.Maybe MentionSentiment,
    -- | Model confidence that the entity is relevant. Value range is zero to
    -- one, where one is highest confidence.
    TargetedSentimentMention -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | The text in the document that identifies the entity.
    TargetedSentimentMention -> Maybe Text
text :: Prelude.Maybe Prelude.Text,
    -- | The type of the entity. Amazon Comprehend supports a variety of
    -- <https://docs.aws.amazon.com/comprehend/latest/dg/how-targeted-sentiment.html#how-targeted-sentiment-entities entity types>.
    TargetedSentimentMention -> Maybe TargetedSentimentEntityType
type' :: Prelude.Maybe TargetedSentimentEntityType
  }
  deriving (TargetedSentimentMention -> TargetedSentimentMention -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetedSentimentMention -> TargetedSentimentMention -> Bool
$c/= :: TargetedSentimentMention -> TargetedSentimentMention -> Bool
== :: TargetedSentimentMention -> TargetedSentimentMention -> Bool
$c== :: TargetedSentimentMention -> TargetedSentimentMention -> Bool
Prelude.Eq, ReadPrec [TargetedSentimentMention]
ReadPrec TargetedSentimentMention
Int -> ReadS TargetedSentimentMention
ReadS [TargetedSentimentMention]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetedSentimentMention]
$creadListPrec :: ReadPrec [TargetedSentimentMention]
readPrec :: ReadPrec TargetedSentimentMention
$creadPrec :: ReadPrec TargetedSentimentMention
readList :: ReadS [TargetedSentimentMention]
$creadList :: ReadS [TargetedSentimentMention]
readsPrec :: Int -> ReadS TargetedSentimentMention
$creadsPrec :: Int -> ReadS TargetedSentimentMention
Prelude.Read, Int -> TargetedSentimentMention -> ShowS
[TargetedSentimentMention] -> ShowS
TargetedSentimentMention -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetedSentimentMention] -> ShowS
$cshowList :: [TargetedSentimentMention] -> ShowS
show :: TargetedSentimentMention -> String
$cshow :: TargetedSentimentMention -> String
showsPrec :: Int -> TargetedSentimentMention -> ShowS
$cshowsPrec :: Int -> TargetedSentimentMention -> ShowS
Prelude.Show, forall x.
Rep TargetedSentimentMention x -> TargetedSentimentMention
forall x.
TargetedSentimentMention -> Rep TargetedSentimentMention x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TargetedSentimentMention x -> TargetedSentimentMention
$cfrom :: forall x.
TargetedSentimentMention -> Rep TargetedSentimentMention x
Prelude.Generic)

-- |
-- Create a value of 'TargetedSentimentMention' 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:
--
-- 'beginOffset', 'targetedSentimentMention_beginOffset' - The offset into the document text where the mention begins.
--
-- 'endOffset', 'targetedSentimentMention_endOffset' - The offset into the document text where the mention ends.
--
-- 'groupScore', 'targetedSentimentMention_groupScore' - The confidence that all the entities mentioned in the group relate to
-- the same entity.
--
-- 'mentionSentiment', 'targetedSentimentMention_mentionSentiment' - Contains the sentiment and sentiment score for the mention.
--
-- 'score', 'targetedSentimentMention_score' - Model confidence that the entity is relevant. Value range is zero to
-- one, where one is highest confidence.
--
-- 'text', 'targetedSentimentMention_text' - The text in the document that identifies the entity.
--
-- 'type'', 'targetedSentimentMention_type' - The type of the entity. Amazon Comprehend supports a variety of
-- <https://docs.aws.amazon.com/comprehend/latest/dg/how-targeted-sentiment.html#how-targeted-sentiment-entities entity types>.
newTargetedSentimentMention ::
  TargetedSentimentMention
newTargetedSentimentMention :: TargetedSentimentMention
newTargetedSentimentMention =
  TargetedSentimentMention'
    { $sel:beginOffset:TargetedSentimentMention' :: Maybe Int
beginOffset =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endOffset:TargetedSentimentMention' :: Maybe Int
endOffset = forall a. Maybe a
Prelude.Nothing,
      $sel:groupScore:TargetedSentimentMention' :: Maybe Double
groupScore = forall a. Maybe a
Prelude.Nothing,
      $sel:mentionSentiment:TargetedSentimentMention' :: Maybe MentionSentiment
mentionSentiment = forall a. Maybe a
Prelude.Nothing,
      $sel:score:TargetedSentimentMention' :: Maybe Double
score = forall a. Maybe a
Prelude.Nothing,
      $sel:text:TargetedSentimentMention' :: Maybe Text
text = forall a. Maybe a
Prelude.Nothing,
      $sel:type':TargetedSentimentMention' :: Maybe TargetedSentimentEntityType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The offset into the document text where the mention begins.
targetedSentimentMention_beginOffset :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe Prelude.Int)
targetedSentimentMention_beginOffset :: Lens' TargetedSentimentMention (Maybe Int)
targetedSentimentMention_beginOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe Int
beginOffset :: Maybe Int
$sel:beginOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
beginOffset} -> Maybe Int
beginOffset) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe Int
a -> TargetedSentimentMention
s {$sel:beginOffset:TargetedSentimentMention' :: Maybe Int
beginOffset = Maybe Int
a} :: TargetedSentimentMention)

-- | The offset into the document text where the mention ends.
targetedSentimentMention_endOffset :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe Prelude.Int)
targetedSentimentMention_endOffset :: Lens' TargetedSentimentMention (Maybe Int)
targetedSentimentMention_endOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe Int
endOffset :: Maybe Int
$sel:endOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
endOffset} -> Maybe Int
endOffset) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe Int
a -> TargetedSentimentMention
s {$sel:endOffset:TargetedSentimentMention' :: Maybe Int
endOffset = Maybe Int
a} :: TargetedSentimentMention)

-- | The confidence that all the entities mentioned in the group relate to
-- the same entity.
targetedSentimentMention_groupScore :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe Prelude.Double)
targetedSentimentMention_groupScore :: Lens' TargetedSentimentMention (Maybe Double)
targetedSentimentMention_groupScore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe Double
groupScore :: Maybe Double
$sel:groupScore:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
groupScore} -> Maybe Double
groupScore) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe Double
a -> TargetedSentimentMention
s {$sel:groupScore:TargetedSentimentMention' :: Maybe Double
groupScore = Maybe Double
a} :: TargetedSentimentMention)

-- | Contains the sentiment and sentiment score for the mention.
targetedSentimentMention_mentionSentiment :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe MentionSentiment)
targetedSentimentMention_mentionSentiment :: Lens' TargetedSentimentMention (Maybe MentionSentiment)
targetedSentimentMention_mentionSentiment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe MentionSentiment
mentionSentiment :: Maybe MentionSentiment
$sel:mentionSentiment:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe MentionSentiment
mentionSentiment} -> Maybe MentionSentiment
mentionSentiment) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe MentionSentiment
a -> TargetedSentimentMention
s {$sel:mentionSentiment:TargetedSentimentMention' :: Maybe MentionSentiment
mentionSentiment = Maybe MentionSentiment
a} :: TargetedSentimentMention)

-- | Model confidence that the entity is relevant. Value range is zero to
-- one, where one is highest confidence.
targetedSentimentMention_score :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe Prelude.Double)
targetedSentimentMention_score :: Lens' TargetedSentimentMention (Maybe Double)
targetedSentimentMention_score = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe Double
score :: Maybe Double
$sel:score:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
score} -> Maybe Double
score) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe Double
a -> TargetedSentimentMention
s {$sel:score:TargetedSentimentMention' :: Maybe Double
score = Maybe Double
a} :: TargetedSentimentMention)

-- | The text in the document that identifies the entity.
targetedSentimentMention_text :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe Prelude.Text)
targetedSentimentMention_text :: Lens' TargetedSentimentMention (Maybe Text)
targetedSentimentMention_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe Text
text :: Maybe Text
$sel:text:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Text
text} -> Maybe Text
text) (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe Text
a -> TargetedSentimentMention
s {$sel:text:TargetedSentimentMention' :: Maybe Text
text = Maybe Text
a} :: TargetedSentimentMention)

-- | The type of the entity. Amazon Comprehend supports a variety of
-- <https://docs.aws.amazon.com/comprehend/latest/dg/how-targeted-sentiment.html#how-targeted-sentiment-entities entity types>.
targetedSentimentMention_type :: Lens.Lens' TargetedSentimentMention (Prelude.Maybe TargetedSentimentEntityType)
targetedSentimentMention_type :: Lens' TargetedSentimentMention (Maybe TargetedSentimentEntityType)
targetedSentimentMention_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetedSentimentMention' {Maybe TargetedSentimentEntityType
type' :: Maybe TargetedSentimentEntityType
$sel:type':TargetedSentimentMention' :: TargetedSentimentMention -> Maybe TargetedSentimentEntityType
type'} -> Maybe TargetedSentimentEntityType
type') (\s :: TargetedSentimentMention
s@TargetedSentimentMention' {} Maybe TargetedSentimentEntityType
a -> TargetedSentimentMention
s {$sel:type':TargetedSentimentMention' :: Maybe TargetedSentimentEntityType
type' = Maybe TargetedSentimentEntityType
a} :: TargetedSentimentMention)

instance Data.FromJSON TargetedSentimentMention where
  parseJSON :: Value -> Parser TargetedSentimentMention
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TargetedSentimentMention"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Double
-> Maybe MentionSentiment
-> Maybe Double
-> Maybe Text
-> Maybe TargetedSentimentEntityType
-> TargetedSentimentMention
TargetedSentimentMention'
            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
"BeginOffset")
            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
"EndOffset")
            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
"GroupScore")
            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
"MentionSentiment")
            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
"Score")
            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
"Text")
            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
"Type")
      )

instance Prelude.Hashable TargetedSentimentMention where
  hashWithSalt :: Int -> TargetedSentimentMention -> Int
hashWithSalt Int
_salt TargetedSentimentMention' {Maybe Double
Maybe Int
Maybe Text
Maybe MentionSentiment
Maybe TargetedSentimentEntityType
type' :: Maybe TargetedSentimentEntityType
text :: Maybe Text
score :: Maybe Double
mentionSentiment :: Maybe MentionSentiment
groupScore :: Maybe Double
endOffset :: Maybe Int
beginOffset :: Maybe Int
$sel:type':TargetedSentimentMention' :: TargetedSentimentMention -> Maybe TargetedSentimentEntityType
$sel:text:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Text
$sel:score:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
$sel:mentionSentiment:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe MentionSentiment
$sel:groupScore:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
$sel:endOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
$sel:beginOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
beginOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
groupScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MentionSentiment
mentionSentiment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
score
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
text
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetedSentimentEntityType
type'

instance Prelude.NFData TargetedSentimentMention where
  rnf :: TargetedSentimentMention -> ()
rnf TargetedSentimentMention' {Maybe Double
Maybe Int
Maybe Text
Maybe MentionSentiment
Maybe TargetedSentimentEntityType
type' :: Maybe TargetedSentimentEntityType
text :: Maybe Text
score :: Maybe Double
mentionSentiment :: Maybe MentionSentiment
groupScore :: Maybe Double
endOffset :: Maybe Int
beginOffset :: Maybe Int
$sel:type':TargetedSentimentMention' :: TargetedSentimentMention -> Maybe TargetedSentimentEntityType
$sel:text:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Text
$sel:score:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
$sel:mentionSentiment:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe MentionSentiment
$sel:groupScore:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Double
$sel:endOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
$sel:beginOffset:TargetedSentimentMention' :: TargetedSentimentMention -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
beginOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
groupScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MentionSentiment
mentionSentiment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
score
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
text
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetedSentimentEntityType
type'