{-# 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.Kendra.Types.SpellCorrectedQuery
-- 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.Kendra.Types.SpellCorrectedQuery where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.Correction
import qualified Amazonka.Prelude as Prelude

-- | A query with suggested spell corrections.
--
-- /See:/ 'newSpellCorrectedQuery' smart constructor.
data SpellCorrectedQuery = SpellCorrectedQuery'
  { -- | The corrected misspelled word or words in a query.
    SpellCorrectedQuery -> Maybe [Correction]
corrections :: Prelude.Maybe [Correction],
    -- | The query with the suggested spell corrections.
    SpellCorrectedQuery -> Maybe Text
suggestedQueryText :: Prelude.Maybe Prelude.Text
  }
  deriving (SpellCorrectedQuery -> SpellCorrectedQuery -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpellCorrectedQuery -> SpellCorrectedQuery -> Bool
$c/= :: SpellCorrectedQuery -> SpellCorrectedQuery -> Bool
== :: SpellCorrectedQuery -> SpellCorrectedQuery -> Bool
$c== :: SpellCorrectedQuery -> SpellCorrectedQuery -> Bool
Prelude.Eq, ReadPrec [SpellCorrectedQuery]
ReadPrec SpellCorrectedQuery
Int -> ReadS SpellCorrectedQuery
ReadS [SpellCorrectedQuery]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpellCorrectedQuery]
$creadListPrec :: ReadPrec [SpellCorrectedQuery]
readPrec :: ReadPrec SpellCorrectedQuery
$creadPrec :: ReadPrec SpellCorrectedQuery
readList :: ReadS [SpellCorrectedQuery]
$creadList :: ReadS [SpellCorrectedQuery]
readsPrec :: Int -> ReadS SpellCorrectedQuery
$creadsPrec :: Int -> ReadS SpellCorrectedQuery
Prelude.Read, Int -> SpellCorrectedQuery -> ShowS
[SpellCorrectedQuery] -> ShowS
SpellCorrectedQuery -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpellCorrectedQuery] -> ShowS
$cshowList :: [SpellCorrectedQuery] -> ShowS
show :: SpellCorrectedQuery -> String
$cshow :: SpellCorrectedQuery -> String
showsPrec :: Int -> SpellCorrectedQuery -> ShowS
$cshowsPrec :: Int -> SpellCorrectedQuery -> ShowS
Prelude.Show, forall x. Rep SpellCorrectedQuery x -> SpellCorrectedQuery
forall x. SpellCorrectedQuery -> Rep SpellCorrectedQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpellCorrectedQuery x -> SpellCorrectedQuery
$cfrom :: forall x. SpellCorrectedQuery -> Rep SpellCorrectedQuery x
Prelude.Generic)

-- |
-- Create a value of 'SpellCorrectedQuery' 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:
--
-- 'corrections', 'spellCorrectedQuery_corrections' - The corrected misspelled word or words in a query.
--
-- 'suggestedQueryText', 'spellCorrectedQuery_suggestedQueryText' - The query with the suggested spell corrections.
newSpellCorrectedQuery ::
  SpellCorrectedQuery
newSpellCorrectedQuery :: SpellCorrectedQuery
newSpellCorrectedQuery =
  SpellCorrectedQuery'
    { $sel:corrections:SpellCorrectedQuery' :: Maybe [Correction]
corrections = forall a. Maybe a
Prelude.Nothing,
      $sel:suggestedQueryText:SpellCorrectedQuery' :: Maybe Text
suggestedQueryText = forall a. Maybe a
Prelude.Nothing
    }

-- | The corrected misspelled word or words in a query.
spellCorrectedQuery_corrections :: Lens.Lens' SpellCorrectedQuery (Prelude.Maybe [Correction])
spellCorrectedQuery_corrections :: Lens' SpellCorrectedQuery (Maybe [Correction])
spellCorrectedQuery_corrections = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpellCorrectedQuery' {Maybe [Correction]
corrections :: Maybe [Correction]
$sel:corrections:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe [Correction]
corrections} -> Maybe [Correction]
corrections) (\s :: SpellCorrectedQuery
s@SpellCorrectedQuery' {} Maybe [Correction]
a -> SpellCorrectedQuery
s {$sel:corrections:SpellCorrectedQuery' :: Maybe [Correction]
corrections = Maybe [Correction]
a} :: SpellCorrectedQuery) 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

-- | The query with the suggested spell corrections.
spellCorrectedQuery_suggestedQueryText :: Lens.Lens' SpellCorrectedQuery (Prelude.Maybe Prelude.Text)
spellCorrectedQuery_suggestedQueryText :: Lens' SpellCorrectedQuery (Maybe Text)
spellCorrectedQuery_suggestedQueryText = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpellCorrectedQuery' {Maybe Text
suggestedQueryText :: Maybe Text
$sel:suggestedQueryText:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe Text
suggestedQueryText} -> Maybe Text
suggestedQueryText) (\s :: SpellCorrectedQuery
s@SpellCorrectedQuery' {} Maybe Text
a -> SpellCorrectedQuery
s {$sel:suggestedQueryText:SpellCorrectedQuery' :: Maybe Text
suggestedQueryText = Maybe Text
a} :: SpellCorrectedQuery)

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

instance Prelude.Hashable SpellCorrectedQuery where
  hashWithSalt :: Int -> SpellCorrectedQuery -> Int
hashWithSalt Int
_salt SpellCorrectedQuery' {Maybe [Correction]
Maybe Text
suggestedQueryText :: Maybe Text
corrections :: Maybe [Correction]
$sel:suggestedQueryText:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe Text
$sel:corrections:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe [Correction]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Correction]
corrections
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
suggestedQueryText

instance Prelude.NFData SpellCorrectedQuery where
  rnf :: SpellCorrectedQuery -> ()
rnf SpellCorrectedQuery' {Maybe [Correction]
Maybe Text
suggestedQueryText :: Maybe Text
corrections :: Maybe [Correction]
$sel:suggestedQueryText:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe Text
$sel:corrections:SpellCorrectedQuery' :: SpellCorrectedQuery -> Maybe [Correction]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Correction]
corrections
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
suggestedQueryText