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

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

-- | Identifies the part of speech represented by the token and gives the
-- confidence that Amazon Comprehend has that the part of speech was
-- correctly identified. For more information about the parts of speech
-- that Amazon Comprehend can identify, see
-- <https://docs.aws.amazon.com/comprehend/latest/dg/how-syntax.html Syntax>
-- in the Comprehend Developer Guide.
--
-- /See:/ 'newPartOfSpeechTag' smart constructor.
data PartOfSpeechTag = PartOfSpeechTag'
  { -- | The confidence that Amazon Comprehend has that the part of speech was
    -- correctly identified.
    PartOfSpeechTag -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | Identifies the part of speech that the token represents.
    PartOfSpeechTag -> Maybe PartOfSpeechTagType
tag :: Prelude.Maybe PartOfSpeechTagType
  }
  deriving (PartOfSpeechTag -> PartOfSpeechTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartOfSpeechTag -> PartOfSpeechTag -> Bool
$c/= :: PartOfSpeechTag -> PartOfSpeechTag -> Bool
== :: PartOfSpeechTag -> PartOfSpeechTag -> Bool
$c== :: PartOfSpeechTag -> PartOfSpeechTag -> Bool
Prelude.Eq, ReadPrec [PartOfSpeechTag]
ReadPrec PartOfSpeechTag
Int -> ReadS PartOfSpeechTag
ReadS [PartOfSpeechTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartOfSpeechTag]
$creadListPrec :: ReadPrec [PartOfSpeechTag]
readPrec :: ReadPrec PartOfSpeechTag
$creadPrec :: ReadPrec PartOfSpeechTag
readList :: ReadS [PartOfSpeechTag]
$creadList :: ReadS [PartOfSpeechTag]
readsPrec :: Int -> ReadS PartOfSpeechTag
$creadsPrec :: Int -> ReadS PartOfSpeechTag
Prelude.Read, Int -> PartOfSpeechTag -> ShowS
[PartOfSpeechTag] -> ShowS
PartOfSpeechTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartOfSpeechTag] -> ShowS
$cshowList :: [PartOfSpeechTag] -> ShowS
show :: PartOfSpeechTag -> String
$cshow :: PartOfSpeechTag -> String
showsPrec :: Int -> PartOfSpeechTag -> ShowS
$cshowsPrec :: Int -> PartOfSpeechTag -> ShowS
Prelude.Show, forall x. Rep PartOfSpeechTag x -> PartOfSpeechTag
forall x. PartOfSpeechTag -> Rep PartOfSpeechTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartOfSpeechTag x -> PartOfSpeechTag
$cfrom :: forall x. PartOfSpeechTag -> Rep PartOfSpeechTag x
Prelude.Generic)

-- |
-- Create a value of 'PartOfSpeechTag' 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:
--
-- 'score', 'partOfSpeechTag_score' - The confidence that Amazon Comprehend has that the part of speech was
-- correctly identified.
--
-- 'tag', 'partOfSpeechTag_tag' - Identifies the part of speech that the token represents.
newPartOfSpeechTag ::
  PartOfSpeechTag
newPartOfSpeechTag :: PartOfSpeechTag
newPartOfSpeechTag =
  PartOfSpeechTag'
    { $sel:score:PartOfSpeechTag' :: Maybe Double
score = forall a. Maybe a
Prelude.Nothing,
      $sel:tag:PartOfSpeechTag' :: Maybe PartOfSpeechTagType
tag = forall a. Maybe a
Prelude.Nothing
    }

-- | The confidence that Amazon Comprehend has that the part of speech was
-- correctly identified.
partOfSpeechTag_score :: Lens.Lens' PartOfSpeechTag (Prelude.Maybe Prelude.Double)
partOfSpeechTag_score :: Lens' PartOfSpeechTag (Maybe Double)
partOfSpeechTag_score = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartOfSpeechTag' {Maybe Double
score :: Maybe Double
$sel:score:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe Double
score} -> Maybe Double
score) (\s :: PartOfSpeechTag
s@PartOfSpeechTag' {} Maybe Double
a -> PartOfSpeechTag
s {$sel:score:PartOfSpeechTag' :: Maybe Double
score = Maybe Double
a} :: PartOfSpeechTag)

-- | Identifies the part of speech that the token represents.
partOfSpeechTag_tag :: Lens.Lens' PartOfSpeechTag (Prelude.Maybe PartOfSpeechTagType)
partOfSpeechTag_tag :: Lens' PartOfSpeechTag (Maybe PartOfSpeechTagType)
partOfSpeechTag_tag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartOfSpeechTag' {Maybe PartOfSpeechTagType
tag :: Maybe PartOfSpeechTagType
$sel:tag:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe PartOfSpeechTagType
tag} -> Maybe PartOfSpeechTagType
tag) (\s :: PartOfSpeechTag
s@PartOfSpeechTag' {} Maybe PartOfSpeechTagType
a -> PartOfSpeechTag
s {$sel:tag:PartOfSpeechTag' :: Maybe PartOfSpeechTagType
tag = Maybe PartOfSpeechTagType
a} :: PartOfSpeechTag)

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

instance Prelude.Hashable PartOfSpeechTag where
  hashWithSalt :: Int -> PartOfSpeechTag -> Int
hashWithSalt Int
_salt PartOfSpeechTag' {Maybe Double
Maybe PartOfSpeechTagType
tag :: Maybe PartOfSpeechTagType
score :: Maybe Double
$sel:tag:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe PartOfSpeechTagType
$sel:score:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
score
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PartOfSpeechTagType
tag

instance Prelude.NFData PartOfSpeechTag where
  rnf :: PartOfSpeechTag -> ()
rnf PartOfSpeechTag' {Maybe Double
Maybe PartOfSpeechTagType
tag :: Maybe PartOfSpeechTagType
score :: Maybe Double
$sel:tag:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe PartOfSpeechTagType
$sel:score:PartOfSpeechTag' :: PartOfSpeechTag -> Maybe Double
..} =
    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 PartOfSpeechTagType
tag