{-# 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.Translate.Types.AppliedTerminology
-- 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.Translate.Types.AppliedTerminology 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
import Amazonka.Translate.Types.Term

-- | The custom terminology applied to the input text by Amazon Translate for
-- the translated text response. This is optional in the response and will
-- only be present if you specified terminology input in the request.
-- Currently, only one terminology can be applied per TranslateText
-- request.
--
-- /See:/ 'newAppliedTerminology' smart constructor.
data AppliedTerminology = AppliedTerminology'
  { -- | The name of the custom terminology applied to the input text by Amazon
    -- Translate for the translated text response.
    AppliedTerminology -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The specific terms of the custom terminology applied to the input text
    -- by Amazon Translate for the translated text response. A maximum of 250
    -- terms will be returned, and the specific terms applied will be the first
    -- 250 terms in the source text.
    AppliedTerminology -> Maybe [Term]
terms :: Prelude.Maybe [Term]
  }
  deriving (AppliedTerminology -> AppliedTerminology -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppliedTerminology -> AppliedTerminology -> Bool
$c/= :: AppliedTerminology -> AppliedTerminology -> Bool
== :: AppliedTerminology -> AppliedTerminology -> Bool
$c== :: AppliedTerminology -> AppliedTerminology -> Bool
Prelude.Eq, ReadPrec [AppliedTerminology]
ReadPrec AppliedTerminology
Int -> ReadS AppliedTerminology
ReadS [AppliedTerminology]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppliedTerminology]
$creadListPrec :: ReadPrec [AppliedTerminology]
readPrec :: ReadPrec AppliedTerminology
$creadPrec :: ReadPrec AppliedTerminology
readList :: ReadS [AppliedTerminology]
$creadList :: ReadS [AppliedTerminology]
readsPrec :: Int -> ReadS AppliedTerminology
$creadsPrec :: Int -> ReadS AppliedTerminology
Prelude.Read, Int -> AppliedTerminology -> ShowS
[AppliedTerminology] -> ShowS
AppliedTerminology -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppliedTerminology] -> ShowS
$cshowList :: [AppliedTerminology] -> ShowS
show :: AppliedTerminology -> String
$cshow :: AppliedTerminology -> String
showsPrec :: Int -> AppliedTerminology -> ShowS
$cshowsPrec :: Int -> AppliedTerminology -> ShowS
Prelude.Show, forall x. Rep AppliedTerminology x -> AppliedTerminology
forall x. AppliedTerminology -> Rep AppliedTerminology x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AppliedTerminology x -> AppliedTerminology
$cfrom :: forall x. AppliedTerminology -> Rep AppliedTerminology x
Prelude.Generic)

-- |
-- Create a value of 'AppliedTerminology' 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:
--
-- 'name', 'appliedTerminology_name' - The name of the custom terminology applied to the input text by Amazon
-- Translate for the translated text response.
--
-- 'terms', 'appliedTerminology_terms' - The specific terms of the custom terminology applied to the input text
-- by Amazon Translate for the translated text response. A maximum of 250
-- terms will be returned, and the specific terms applied will be the first
-- 250 terms in the source text.
newAppliedTerminology ::
  AppliedTerminology
newAppliedTerminology :: AppliedTerminology
newAppliedTerminology =
  AppliedTerminology'
    { $sel:name:AppliedTerminology' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:terms:AppliedTerminology' :: Maybe [Term]
terms = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the custom terminology applied to the input text by Amazon
-- Translate for the translated text response.
appliedTerminology_name :: Lens.Lens' AppliedTerminology (Prelude.Maybe Prelude.Text)
appliedTerminology_name :: Lens' AppliedTerminology (Maybe Text)
appliedTerminology_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppliedTerminology' {Maybe Text
name :: Maybe Text
$sel:name:AppliedTerminology' :: AppliedTerminology -> Maybe Text
name} -> Maybe Text
name) (\s :: AppliedTerminology
s@AppliedTerminology' {} Maybe Text
a -> AppliedTerminology
s {$sel:name:AppliedTerminology' :: Maybe Text
name = Maybe Text
a} :: AppliedTerminology)

-- | The specific terms of the custom terminology applied to the input text
-- by Amazon Translate for the translated text response. A maximum of 250
-- terms will be returned, and the specific terms applied will be the first
-- 250 terms in the source text.
appliedTerminology_terms :: Lens.Lens' AppliedTerminology (Prelude.Maybe [Term])
appliedTerminology_terms :: Lens' AppliedTerminology (Maybe [Term])
appliedTerminology_terms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppliedTerminology' {Maybe [Term]
terms :: Maybe [Term]
$sel:terms:AppliedTerminology' :: AppliedTerminology -> Maybe [Term]
terms} -> Maybe [Term]
terms) (\s :: AppliedTerminology
s@AppliedTerminology' {} Maybe [Term]
a -> AppliedTerminology
s {$sel:terms:AppliedTerminology' :: Maybe [Term]
terms = Maybe [Term]
a} :: AppliedTerminology) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AppliedTerminology where
  parseJSON :: Value -> Parser AppliedTerminology
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AppliedTerminology"
      ( \Object
x ->
          Maybe Text -> Maybe [Term] -> AppliedTerminology
AppliedTerminology'
            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
"Name")
            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
"Terms" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AppliedTerminology where
  hashWithSalt :: Int -> AppliedTerminology -> Int
hashWithSalt Int
_salt AppliedTerminology' {Maybe [Term]
Maybe Text
terms :: Maybe [Term]
name :: Maybe Text
$sel:terms:AppliedTerminology' :: AppliedTerminology -> Maybe [Term]
$sel:name:AppliedTerminology' :: AppliedTerminology -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Term]
terms

instance Prelude.NFData AppliedTerminology where
  rnf :: AppliedTerminology -> ()
rnf AppliedTerminology' {Maybe [Term]
Maybe Text
terms :: Maybe [Term]
name :: Maybe Text
$sel:terms:AppliedTerminology' :: AppliedTerminology -> Maybe [Term]
$sel:name:AppliedTerminology' :: AppliedTerminology -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Term]
terms