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

import Amazonka.Comprehend.Types.PartOfSpeechTagType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 how-syntax.
--
-- /See:/ 'newPartOfSpeechTag' smart constructor.
data PartOfSpeechTag = PartOfSpeechTag'
  { -- | Identifies the part of speech that the token represents.
    PartOfSpeechTag -> Maybe PartOfSpeechTagType
tag :: Prelude.Maybe PartOfSpeechTagType,
    -- | The confidence that Amazon Comprehend has that the part of speech was
    -- correctly identified.
    PartOfSpeechTag -> Maybe Double
score :: Prelude.Maybe Prelude.Double
  }
  deriving (PartOfSpeechTag -> PartOfSpeechTag -> Bool
(PartOfSpeechTag -> PartOfSpeechTag -> Bool)
-> (PartOfSpeechTag -> PartOfSpeechTag -> Bool)
-> Eq PartOfSpeechTag
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]
(Int -> ReadS PartOfSpeechTag)
-> ReadS [PartOfSpeechTag]
-> ReadPrec PartOfSpeechTag
-> ReadPrec [PartOfSpeechTag]
-> Read 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
(Int -> PartOfSpeechTag -> ShowS)
-> (PartOfSpeechTag -> String)
-> ([PartOfSpeechTag] -> ShowS)
-> Show PartOfSpeechTag
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. PartOfSpeechTag -> Rep PartOfSpeechTag x)
-> (forall x. Rep PartOfSpeechTag x -> PartOfSpeechTag)
-> Generic PartOfSpeechTag
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:
--
-- 'tag', 'partOfSpeechTag_tag' - Identifies the part of speech that the token represents.
--
-- 'score', 'partOfSpeechTag_score' - The confidence that Amazon Comprehend has that the part of speech was
-- correctly identified.
newPartOfSpeechTag ::
  PartOfSpeechTag
newPartOfSpeechTag :: PartOfSpeechTag
newPartOfSpeechTag =
  PartOfSpeechTag' :: Maybe PartOfSpeechTagType -> Maybe Double -> PartOfSpeechTag
PartOfSpeechTag'
    { $sel:tag:PartOfSpeechTag' :: Maybe PartOfSpeechTagType
tag = Maybe PartOfSpeechTagType
forall a. Maybe a
Prelude.Nothing,
      $sel:score:PartOfSpeechTag' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Identifies the part of speech that the token represents.
partOfSpeechTag_tag :: Lens.Lens' PartOfSpeechTag (Prelude.Maybe PartOfSpeechTagType)
partOfSpeechTag_tag :: (Maybe PartOfSpeechTagType -> f (Maybe PartOfSpeechTagType))
-> PartOfSpeechTag -> f PartOfSpeechTag
partOfSpeechTag_tag = (PartOfSpeechTag -> Maybe PartOfSpeechTagType)
-> (PartOfSpeechTag
    -> Maybe PartOfSpeechTagType -> PartOfSpeechTag)
-> Lens
     PartOfSpeechTag
     PartOfSpeechTag
     (Maybe PartOfSpeechTagType)
     (Maybe PartOfSpeechTagType)
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)

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> PartOfSpeechTag -> f PartOfSpeechTag
partOfSpeechTag_score = (PartOfSpeechTag -> Maybe Double)
-> (PartOfSpeechTag -> Maybe Double -> PartOfSpeechTag)
-> Lens
     PartOfSpeechTag PartOfSpeechTag (Maybe Double) (Maybe Double)
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)

instance Core.FromJSON PartOfSpeechTag where
  parseJSON :: Value -> Parser PartOfSpeechTag
parseJSON =
    String
-> (Object -> Parser PartOfSpeechTag)
-> Value
-> Parser PartOfSpeechTag
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PartOfSpeechTag"
      ( \Object
x ->
          Maybe PartOfSpeechTagType -> Maybe Double -> PartOfSpeechTag
PartOfSpeechTag'
            (Maybe PartOfSpeechTagType -> Maybe Double -> PartOfSpeechTag)
-> Parser (Maybe PartOfSpeechTagType)
-> Parser (Maybe Double -> PartOfSpeechTag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PartOfSpeechTagType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Tag") Parser (Maybe Double -> PartOfSpeechTag)
-> Parser (Maybe Double) -> Parser PartOfSpeechTag
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
"Score")
      )

instance Prelude.Hashable PartOfSpeechTag

instance Prelude.NFData PartOfSpeechTag