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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns the code for the dominant language in the input text and the
-- level of confidence that Amazon Comprehend has in the accuracy of the
-- detection.
--
-- /See:/ 'newDominantLanguage' smart constructor.
data DominantLanguage = DominantLanguage'
  { -- | The RFC 5646 language code for the dominant language. For more
    -- information about RFC 5646, see
    -- <https://tools.ietf.org/html/rfc5646 Tags for Identifying Languages> on
    -- the /IETF Tools/ web site.
    DominantLanguage -> Maybe Text
languageCode :: Prelude.Maybe Prelude.Text,
    -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- the detection.
    DominantLanguage -> Maybe Double
score :: Prelude.Maybe Prelude.Double
  }
  deriving (DominantLanguage -> DominantLanguage -> Bool
(DominantLanguage -> DominantLanguage -> Bool)
-> (DominantLanguage -> DominantLanguage -> Bool)
-> Eq DominantLanguage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DominantLanguage -> DominantLanguage -> Bool
$c/= :: DominantLanguage -> DominantLanguage -> Bool
== :: DominantLanguage -> DominantLanguage -> Bool
$c== :: DominantLanguage -> DominantLanguage -> Bool
Prelude.Eq, ReadPrec [DominantLanguage]
ReadPrec DominantLanguage
Int -> ReadS DominantLanguage
ReadS [DominantLanguage]
(Int -> ReadS DominantLanguage)
-> ReadS [DominantLanguage]
-> ReadPrec DominantLanguage
-> ReadPrec [DominantLanguage]
-> Read DominantLanguage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DominantLanguage]
$creadListPrec :: ReadPrec [DominantLanguage]
readPrec :: ReadPrec DominantLanguage
$creadPrec :: ReadPrec DominantLanguage
readList :: ReadS [DominantLanguage]
$creadList :: ReadS [DominantLanguage]
readsPrec :: Int -> ReadS DominantLanguage
$creadsPrec :: Int -> ReadS DominantLanguage
Prelude.Read, Int -> DominantLanguage -> ShowS
[DominantLanguage] -> ShowS
DominantLanguage -> String
(Int -> DominantLanguage -> ShowS)
-> (DominantLanguage -> String)
-> ([DominantLanguage] -> ShowS)
-> Show DominantLanguage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DominantLanguage] -> ShowS
$cshowList :: [DominantLanguage] -> ShowS
show :: DominantLanguage -> String
$cshow :: DominantLanguage -> String
showsPrec :: Int -> DominantLanguage -> ShowS
$cshowsPrec :: Int -> DominantLanguage -> ShowS
Prelude.Show, (forall x. DominantLanguage -> Rep DominantLanguage x)
-> (forall x. Rep DominantLanguage x -> DominantLanguage)
-> Generic DominantLanguage
forall x. Rep DominantLanguage x -> DominantLanguage
forall x. DominantLanguage -> Rep DominantLanguage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DominantLanguage x -> DominantLanguage
$cfrom :: forall x. DominantLanguage -> Rep DominantLanguage x
Prelude.Generic)

-- |
-- Create a value of 'DominantLanguage' 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:
--
-- 'languageCode', 'dominantLanguage_languageCode' - The RFC 5646 language code for the dominant language. For more
-- information about RFC 5646, see
-- <https://tools.ietf.org/html/rfc5646 Tags for Identifying Languages> on
-- the /IETF Tools/ web site.
--
-- 'score', 'dominantLanguage_score' - The level of confidence that Amazon Comprehend has in the accuracy of
-- the detection.
newDominantLanguage ::
  DominantLanguage
newDominantLanguage :: DominantLanguage
newDominantLanguage =
  DominantLanguage' :: Maybe Text -> Maybe Double -> DominantLanguage
DominantLanguage'
    { $sel:languageCode:DominantLanguage' :: Maybe Text
languageCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:score:DominantLanguage' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The RFC 5646 language code for the dominant language. For more
-- information about RFC 5646, see
-- <https://tools.ietf.org/html/rfc5646 Tags for Identifying Languages> on
-- the /IETF Tools/ web site.
dominantLanguage_languageCode :: Lens.Lens' DominantLanguage (Prelude.Maybe Prelude.Text)
dominantLanguage_languageCode :: (Maybe Text -> f (Maybe Text))
-> DominantLanguage -> f DominantLanguage
dominantLanguage_languageCode = (DominantLanguage -> Maybe Text)
-> (DominantLanguage -> Maybe Text -> DominantLanguage)
-> Lens DominantLanguage DominantLanguage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantLanguage' {Maybe Text
languageCode :: Maybe Text
$sel:languageCode:DominantLanguage' :: DominantLanguage -> Maybe Text
languageCode} -> Maybe Text
languageCode) (\s :: DominantLanguage
s@DominantLanguage' {} Maybe Text
a -> DominantLanguage
s {$sel:languageCode:DominantLanguage' :: Maybe Text
languageCode = Maybe Text
a} :: DominantLanguage)

-- | The level of confidence that Amazon Comprehend has in the accuracy of
-- the detection.
dominantLanguage_score :: Lens.Lens' DominantLanguage (Prelude.Maybe Prelude.Double)
dominantLanguage_score :: (Maybe Double -> f (Maybe Double))
-> DominantLanguage -> f DominantLanguage
dominantLanguage_score = (DominantLanguage -> Maybe Double)
-> (DominantLanguage -> Maybe Double -> DominantLanguage)
-> Lens
     DominantLanguage DominantLanguage (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantLanguage' {Maybe Double
score :: Maybe Double
$sel:score:DominantLanguage' :: DominantLanguage -> Maybe Double
score} -> Maybe Double
score) (\s :: DominantLanguage
s@DominantLanguage' {} Maybe Double
a -> DominantLanguage
s {$sel:score:DominantLanguage' :: Maybe Double
score = Maybe Double
a} :: DominantLanguage)

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

instance Prelude.NFData DominantLanguage