{-# 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.Transcribe.Types.LanguageIdSettings
-- 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.Transcribe.Types.LanguageIdSettings 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

-- | If using automatic language identification in your request and you want
-- to apply a custom language model, a custom vocabulary, or a custom
-- vocabulary filter, include @LanguageIdSettings@ with the relevant
-- sub-parameters (@VocabularyName@, @LanguageModelName@, and
-- @VocabularyFilterName@). Note that multi-language identification
-- (@IdentifyMultipleLanguages@) doesn\'t support custom language models.
--
-- @LanguageIdSettings@ supports two to five language codes. Each language
-- code you include can have an associated custom language model, custom
-- vocabulary, and custom vocabulary filter. The language codes that you
-- specify must match the languages of the associated custom language
-- models, custom vocabularies, and custom vocabulary filters.
--
-- It\'s recommended that you include @LanguageOptions@ when using
-- @LanguageIdSettings@ to ensure that the correct language dialect is
-- identified. For example, if you specify a custom vocabulary that is in
-- @en-US@ but Amazon Transcribe determines that the language spoken in
-- your media is @en-AU@, your custom vocabulary /is not/ applied to your
-- transcription. If you include @LanguageOptions@ and include @en-US@ as
-- the only English language dialect, your custom vocabulary /is/ applied
-- to your transcription.
--
-- If you want to include a custom language model with your request but
-- __do not__ want to use automatic language identification, use instead
-- the parameter with the @LanguageModelName@ sub-parameter. If you want to
-- include a custom vocabulary or a custom vocabulary filter (or both) with
-- your request but __do not__ want to use automatic language
-- identification, use instead the parameter with the @VocabularyName@ or
-- @VocabularyFilterName@ (or both) sub-parameter.
--
-- /See:/ 'newLanguageIdSettings' smart constructor.
data LanguageIdSettings = LanguageIdSettings'
  { -- | The name of the custom language model you want to use when processing
    -- your transcription job. Note that custom language model names are case
    -- sensitive.
    --
    -- The language of the specified custom language model must match the
    -- language code that you specify in your transcription request. If the
    -- languages don\'t match, the custom language model isn\'t applied. There
    -- are no errors or warnings associated with a language mismatch.
    LanguageIdSettings -> Maybe Text
languageModelName :: Prelude.Maybe Prelude.Text,
    -- | The name of the custom vocabulary filter you want to use when processing
    -- your transcription job. Custom vocabulary filter names are case
    -- sensitive.
    --
    -- The language of the specified custom vocabulary filter must match the
    -- language code that you specify in your transcription request. If the
    -- languages don\'t match, the custom vocabulary filter isn\'t applied.
    -- There are no errors or warnings associated with a language mismatch.
    --
    -- Note that if you include @VocabularyFilterName@ in your request, you
    -- must also include @VocabularyFilterMethod@.
    LanguageIdSettings -> Maybe Text
vocabularyFilterName :: Prelude.Maybe Prelude.Text,
    -- | The name of the custom vocabulary you want to use when processing your
    -- transcription job. Custom vocabulary names are case sensitive.
    --
    -- The language of the specified custom vocabulary must match the language
    -- code that you specify in your transcription request. If the languages
    -- don\'t match, the custom vocabulary isn\'t applied. There are no errors
    -- or warnings associated with a language mismatch.
    LanguageIdSettings -> Maybe Text
vocabularyName :: Prelude.Maybe Prelude.Text
  }
  deriving (LanguageIdSettings -> LanguageIdSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LanguageIdSettings -> LanguageIdSettings -> Bool
$c/= :: LanguageIdSettings -> LanguageIdSettings -> Bool
== :: LanguageIdSettings -> LanguageIdSettings -> Bool
$c== :: LanguageIdSettings -> LanguageIdSettings -> Bool
Prelude.Eq, ReadPrec [LanguageIdSettings]
ReadPrec LanguageIdSettings
Int -> ReadS LanguageIdSettings
ReadS [LanguageIdSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LanguageIdSettings]
$creadListPrec :: ReadPrec [LanguageIdSettings]
readPrec :: ReadPrec LanguageIdSettings
$creadPrec :: ReadPrec LanguageIdSettings
readList :: ReadS [LanguageIdSettings]
$creadList :: ReadS [LanguageIdSettings]
readsPrec :: Int -> ReadS LanguageIdSettings
$creadsPrec :: Int -> ReadS LanguageIdSettings
Prelude.Read, Int -> LanguageIdSettings -> ShowS
[LanguageIdSettings] -> ShowS
LanguageIdSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LanguageIdSettings] -> ShowS
$cshowList :: [LanguageIdSettings] -> ShowS
show :: LanguageIdSettings -> String
$cshow :: LanguageIdSettings -> String
showsPrec :: Int -> LanguageIdSettings -> ShowS
$cshowsPrec :: Int -> LanguageIdSettings -> ShowS
Prelude.Show, forall x. Rep LanguageIdSettings x -> LanguageIdSettings
forall x. LanguageIdSettings -> Rep LanguageIdSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LanguageIdSettings x -> LanguageIdSettings
$cfrom :: forall x. LanguageIdSettings -> Rep LanguageIdSettings x
Prelude.Generic)

-- |
-- Create a value of 'LanguageIdSettings' 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:
--
-- 'languageModelName', 'languageIdSettings_languageModelName' - The name of the custom language model you want to use when processing
-- your transcription job. Note that custom language model names are case
-- sensitive.
--
-- The language of the specified custom language model must match the
-- language code that you specify in your transcription request. If the
-- languages don\'t match, the custom language model isn\'t applied. There
-- are no errors or warnings associated with a language mismatch.
--
-- 'vocabularyFilterName', 'languageIdSettings_vocabularyFilterName' - The name of the custom vocabulary filter you want to use when processing
-- your transcription job. Custom vocabulary filter names are case
-- sensitive.
--
-- The language of the specified custom vocabulary filter must match the
-- language code that you specify in your transcription request. If the
-- languages don\'t match, the custom vocabulary filter isn\'t applied.
-- There are no errors or warnings associated with a language mismatch.
--
-- Note that if you include @VocabularyFilterName@ in your request, you
-- must also include @VocabularyFilterMethod@.
--
-- 'vocabularyName', 'languageIdSettings_vocabularyName' - The name of the custom vocabulary you want to use when processing your
-- transcription job. Custom vocabulary names are case sensitive.
--
-- The language of the specified custom vocabulary must match the language
-- code that you specify in your transcription request. If the languages
-- don\'t match, the custom vocabulary isn\'t applied. There are no errors
-- or warnings associated with a language mismatch.
newLanguageIdSettings ::
  LanguageIdSettings
newLanguageIdSettings :: LanguageIdSettings
newLanguageIdSettings =
  LanguageIdSettings'
    { $sel:languageModelName:LanguageIdSettings' :: Maybe Text
languageModelName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:vocabularyFilterName:LanguageIdSettings' :: Maybe Text
vocabularyFilterName = forall a. Maybe a
Prelude.Nothing,
      $sel:vocabularyName:LanguageIdSettings' :: Maybe Text
vocabularyName = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the custom language model you want to use when processing
-- your transcription job. Note that custom language model names are case
-- sensitive.
--
-- The language of the specified custom language model must match the
-- language code that you specify in your transcription request. If the
-- languages don\'t match, the custom language model isn\'t applied. There
-- are no errors or warnings associated with a language mismatch.
languageIdSettings_languageModelName :: Lens.Lens' LanguageIdSettings (Prelude.Maybe Prelude.Text)
languageIdSettings_languageModelName :: Lens' LanguageIdSettings (Maybe Text)
languageIdSettings_languageModelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LanguageIdSettings' {Maybe Text
languageModelName :: Maybe Text
$sel:languageModelName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
languageModelName} -> Maybe Text
languageModelName) (\s :: LanguageIdSettings
s@LanguageIdSettings' {} Maybe Text
a -> LanguageIdSettings
s {$sel:languageModelName:LanguageIdSettings' :: Maybe Text
languageModelName = Maybe Text
a} :: LanguageIdSettings)

-- | The name of the custom vocabulary filter you want to use when processing
-- your transcription job. Custom vocabulary filter names are case
-- sensitive.
--
-- The language of the specified custom vocabulary filter must match the
-- language code that you specify in your transcription request. If the
-- languages don\'t match, the custom vocabulary filter isn\'t applied.
-- There are no errors or warnings associated with a language mismatch.
--
-- Note that if you include @VocabularyFilterName@ in your request, you
-- must also include @VocabularyFilterMethod@.
languageIdSettings_vocabularyFilterName :: Lens.Lens' LanguageIdSettings (Prelude.Maybe Prelude.Text)
languageIdSettings_vocabularyFilterName :: Lens' LanguageIdSettings (Maybe Text)
languageIdSettings_vocabularyFilterName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LanguageIdSettings' {Maybe Text
vocabularyFilterName :: Maybe Text
$sel:vocabularyFilterName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
vocabularyFilterName} -> Maybe Text
vocabularyFilterName) (\s :: LanguageIdSettings
s@LanguageIdSettings' {} Maybe Text
a -> LanguageIdSettings
s {$sel:vocabularyFilterName:LanguageIdSettings' :: Maybe Text
vocabularyFilterName = Maybe Text
a} :: LanguageIdSettings)

-- | The name of the custom vocabulary you want to use when processing your
-- transcription job. Custom vocabulary names are case sensitive.
--
-- The language of the specified custom vocabulary must match the language
-- code that you specify in your transcription request. If the languages
-- don\'t match, the custom vocabulary isn\'t applied. There are no errors
-- or warnings associated with a language mismatch.
languageIdSettings_vocabularyName :: Lens.Lens' LanguageIdSettings (Prelude.Maybe Prelude.Text)
languageIdSettings_vocabularyName :: Lens' LanguageIdSettings (Maybe Text)
languageIdSettings_vocabularyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LanguageIdSettings' {Maybe Text
vocabularyName :: Maybe Text
$sel:vocabularyName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
vocabularyName} -> Maybe Text
vocabularyName) (\s :: LanguageIdSettings
s@LanguageIdSettings' {} Maybe Text
a -> LanguageIdSettings
s {$sel:vocabularyName:LanguageIdSettings' :: Maybe Text
vocabularyName = Maybe Text
a} :: LanguageIdSettings)

instance Data.FromJSON LanguageIdSettings where
  parseJSON :: Value -> Parser LanguageIdSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LanguageIdSettings"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> LanguageIdSettings
LanguageIdSettings'
            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
"LanguageModelName")
            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
"VocabularyFilterName")
            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
"VocabularyName")
      )

instance Prelude.Hashable LanguageIdSettings where
  hashWithSalt :: Int -> LanguageIdSettings -> Int
hashWithSalt Int
_salt LanguageIdSettings' {Maybe Text
vocabularyName :: Maybe Text
vocabularyFilterName :: Maybe Text
languageModelName :: Maybe Text
$sel:vocabularyName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:vocabularyFilterName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:languageModelName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
languageModelName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vocabularyFilterName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vocabularyName

instance Prelude.NFData LanguageIdSettings where
  rnf :: LanguageIdSettings -> ()
rnf LanguageIdSettings' {Maybe Text
vocabularyName :: Maybe Text
vocabularyFilterName :: Maybe Text
languageModelName :: Maybe Text
$sel:vocabularyName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:vocabularyFilterName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:languageModelName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
languageModelName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vocabularyFilterName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vocabularyName

instance Data.ToJSON LanguageIdSettings where
  toJSON :: LanguageIdSettings -> Value
toJSON LanguageIdSettings' {Maybe Text
vocabularyName :: Maybe Text
vocabularyFilterName :: Maybe Text
languageModelName :: Maybe Text
$sel:vocabularyName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:vocabularyFilterName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
$sel:languageModelName:LanguageIdSettings' :: LanguageIdSettings -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"LanguageModelName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
languageModelName,
            (Key
"VocabularyFilterName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vocabularyFilterName,
            (Key
"VocabularyName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vocabularyName
          ]
      )