{-# 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.CloudSearch.Types.AnalysisOptions
-- 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.CloudSearch.Types.AnalysisOptions where

import Amazonka.CloudSearch.Types.AlgorithmicStemming
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Synonyms, stopwords, and stemming options for an analysis scheme.
-- Includes tokenization dictionary for Japanese.
--
-- /See:/ 'newAnalysisOptions' smart constructor.
data AnalysisOptions = AnalysisOptions'
  { -- | The level of algorithmic stemming to perform: @none@, @minimal@,
    -- @light@, or @full@. The available levels vary depending on the language.
    -- For more information, see
    -- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/text-processing.html#text-processing-settings Language Specific Text Processing Settings>
    -- in the /Amazon CloudSearch Developer Guide/
    AnalysisOptions -> Maybe AlgorithmicStemming
algorithmicStemming :: Prelude.Maybe AlgorithmicStemming,
    -- | A JSON array of terms to ignore during indexing and searching. For
    -- example, @[\"a\", \"an\", \"the\", \"of\"]@. The stopwords dictionary
    -- must explicitly list each word you want to ignore. Wildcards and regular
    -- expressions are not supported.
    AnalysisOptions -> Maybe Text
stopwords :: Prelude.Maybe Prelude.Text,
    -- | A JSON array that contains a collection of terms, tokens, readings and
    -- part of speech for Japanese Tokenizaiton. The Japanese tokenization
    -- dictionary enables you to override the default tokenization for selected
    -- terms. This is only valid for Japanese language fields.
    AnalysisOptions -> Maybe Text
japaneseTokenizationDictionary :: Prelude.Maybe Prelude.Text,
    -- | A JSON object that defines synonym groups and aliases. A synonym group
    -- is an array of arrays, where each sub-array is a group of terms where
    -- each term in the group is considered a synonym of every other term in
    -- the group. The aliases value is an object that contains a collection of
    -- string:value pairs where the string specifies a term and the array of
    -- values specifies each of the aliases for that term. An alias is
    -- considered a synonym of the specified term, but the term is not
    -- considered a synonym of the alias. For more information about specifying
    -- synonyms, see
    -- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-analysis-schemes.html#synonyms Synonyms>
    -- in the /Amazon CloudSearch Developer Guide/.
    AnalysisOptions -> Maybe Text
synonyms :: Prelude.Maybe Prelude.Text,
    -- | A JSON object that contains a collection of string:value pairs that each
    -- map a term to its stem. For example,
    -- @{\"term1\": \"stem1\", \"term2\": \"stem2\", \"term3\": \"stem3\"}@.
    -- The stemming dictionary is applied in addition to any algorithmic
    -- stemming. This enables you to override the results of the algorithmic
    -- stemming to correct specific cases of overstemming or understemming. The
    -- maximum size of a stemming dictionary is 500 KB.
    AnalysisOptions -> Maybe Text
stemmingDictionary :: Prelude.Maybe Prelude.Text
  }
  deriving (AnalysisOptions -> AnalysisOptions -> Bool
(AnalysisOptions -> AnalysisOptions -> Bool)
-> (AnalysisOptions -> AnalysisOptions -> Bool)
-> Eq AnalysisOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalysisOptions -> AnalysisOptions -> Bool
$c/= :: AnalysisOptions -> AnalysisOptions -> Bool
== :: AnalysisOptions -> AnalysisOptions -> Bool
$c== :: AnalysisOptions -> AnalysisOptions -> Bool
Prelude.Eq, ReadPrec [AnalysisOptions]
ReadPrec AnalysisOptions
Int -> ReadS AnalysisOptions
ReadS [AnalysisOptions]
(Int -> ReadS AnalysisOptions)
-> ReadS [AnalysisOptions]
-> ReadPrec AnalysisOptions
-> ReadPrec [AnalysisOptions]
-> Read AnalysisOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalysisOptions]
$creadListPrec :: ReadPrec [AnalysisOptions]
readPrec :: ReadPrec AnalysisOptions
$creadPrec :: ReadPrec AnalysisOptions
readList :: ReadS [AnalysisOptions]
$creadList :: ReadS [AnalysisOptions]
readsPrec :: Int -> ReadS AnalysisOptions
$creadsPrec :: Int -> ReadS AnalysisOptions
Prelude.Read, Int -> AnalysisOptions -> ShowS
[AnalysisOptions] -> ShowS
AnalysisOptions -> String
(Int -> AnalysisOptions -> ShowS)
-> (AnalysisOptions -> String)
-> ([AnalysisOptions] -> ShowS)
-> Show AnalysisOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalysisOptions] -> ShowS
$cshowList :: [AnalysisOptions] -> ShowS
show :: AnalysisOptions -> String
$cshow :: AnalysisOptions -> String
showsPrec :: Int -> AnalysisOptions -> ShowS
$cshowsPrec :: Int -> AnalysisOptions -> ShowS
Prelude.Show, (forall x. AnalysisOptions -> Rep AnalysisOptions x)
-> (forall x. Rep AnalysisOptions x -> AnalysisOptions)
-> Generic AnalysisOptions
forall x. Rep AnalysisOptions x -> AnalysisOptions
forall x. AnalysisOptions -> Rep AnalysisOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalysisOptions x -> AnalysisOptions
$cfrom :: forall x. AnalysisOptions -> Rep AnalysisOptions x
Prelude.Generic)

-- |
-- Create a value of 'AnalysisOptions' 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:
--
-- 'algorithmicStemming', 'analysisOptions_algorithmicStemming' - The level of algorithmic stemming to perform: @none@, @minimal@,
-- @light@, or @full@. The available levels vary depending on the language.
-- For more information, see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/text-processing.html#text-processing-settings Language Specific Text Processing Settings>
-- in the /Amazon CloudSearch Developer Guide/
--
-- 'stopwords', 'analysisOptions_stopwords' - A JSON array of terms to ignore during indexing and searching. For
-- example, @[\"a\", \"an\", \"the\", \"of\"]@. The stopwords dictionary
-- must explicitly list each word you want to ignore. Wildcards and regular
-- expressions are not supported.
--
-- 'japaneseTokenizationDictionary', 'analysisOptions_japaneseTokenizationDictionary' - A JSON array that contains a collection of terms, tokens, readings and
-- part of speech for Japanese Tokenizaiton. The Japanese tokenization
-- dictionary enables you to override the default tokenization for selected
-- terms. This is only valid for Japanese language fields.
--
-- 'synonyms', 'analysisOptions_synonyms' - A JSON object that defines synonym groups and aliases. A synonym group
-- is an array of arrays, where each sub-array is a group of terms where
-- each term in the group is considered a synonym of every other term in
-- the group. The aliases value is an object that contains a collection of
-- string:value pairs where the string specifies a term and the array of
-- values specifies each of the aliases for that term. An alias is
-- considered a synonym of the specified term, but the term is not
-- considered a synonym of the alias. For more information about specifying
-- synonyms, see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-analysis-schemes.html#synonyms Synonyms>
-- in the /Amazon CloudSearch Developer Guide/.
--
-- 'stemmingDictionary', 'analysisOptions_stemmingDictionary' - A JSON object that contains a collection of string:value pairs that each
-- map a term to its stem. For example,
-- @{\"term1\": \"stem1\", \"term2\": \"stem2\", \"term3\": \"stem3\"}@.
-- The stemming dictionary is applied in addition to any algorithmic
-- stemming. This enables you to override the results of the algorithmic
-- stemming to correct specific cases of overstemming or understemming. The
-- maximum size of a stemming dictionary is 500 KB.
newAnalysisOptions ::
  AnalysisOptions
newAnalysisOptions :: AnalysisOptions
newAnalysisOptions =
  AnalysisOptions' :: Maybe AlgorithmicStemming
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AnalysisOptions
AnalysisOptions'
    { $sel:algorithmicStemming:AnalysisOptions' :: Maybe AlgorithmicStemming
algorithmicStemming =
        Maybe AlgorithmicStemming
forall a. Maybe a
Prelude.Nothing,
      $sel:stopwords:AnalysisOptions' :: Maybe Text
stopwords = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:japaneseTokenizationDictionary:AnalysisOptions' :: Maybe Text
japaneseTokenizationDictionary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:synonyms:AnalysisOptions' :: Maybe Text
synonyms = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stemmingDictionary:AnalysisOptions' :: Maybe Text
stemmingDictionary = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The level of algorithmic stemming to perform: @none@, @minimal@,
-- @light@, or @full@. The available levels vary depending on the language.
-- For more information, see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/text-processing.html#text-processing-settings Language Specific Text Processing Settings>
-- in the /Amazon CloudSearch Developer Guide/
analysisOptions_algorithmicStemming :: Lens.Lens' AnalysisOptions (Prelude.Maybe AlgorithmicStemming)
analysisOptions_algorithmicStemming :: (Maybe AlgorithmicStemming -> f (Maybe AlgorithmicStemming))
-> AnalysisOptions -> f AnalysisOptions
analysisOptions_algorithmicStemming = (AnalysisOptions -> Maybe AlgorithmicStemming)
-> (AnalysisOptions
    -> Maybe AlgorithmicStemming -> AnalysisOptions)
-> Lens
     AnalysisOptions
     AnalysisOptions
     (Maybe AlgorithmicStemming)
     (Maybe AlgorithmicStemming)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisOptions' {Maybe AlgorithmicStemming
algorithmicStemming :: Maybe AlgorithmicStemming
$sel:algorithmicStemming:AnalysisOptions' :: AnalysisOptions -> Maybe AlgorithmicStemming
algorithmicStemming} -> Maybe AlgorithmicStemming
algorithmicStemming) (\s :: AnalysisOptions
s@AnalysisOptions' {} Maybe AlgorithmicStemming
a -> AnalysisOptions
s {$sel:algorithmicStemming:AnalysisOptions' :: Maybe AlgorithmicStemming
algorithmicStemming = Maybe AlgorithmicStemming
a} :: AnalysisOptions)

-- | A JSON array of terms to ignore during indexing and searching. For
-- example, @[\"a\", \"an\", \"the\", \"of\"]@. The stopwords dictionary
-- must explicitly list each word you want to ignore. Wildcards and regular
-- expressions are not supported.
analysisOptions_stopwords :: Lens.Lens' AnalysisOptions (Prelude.Maybe Prelude.Text)
analysisOptions_stopwords :: (Maybe Text -> f (Maybe Text))
-> AnalysisOptions -> f AnalysisOptions
analysisOptions_stopwords = (AnalysisOptions -> Maybe Text)
-> (AnalysisOptions -> Maybe Text -> AnalysisOptions)
-> Lens AnalysisOptions AnalysisOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisOptions' {Maybe Text
stopwords :: Maybe Text
$sel:stopwords:AnalysisOptions' :: AnalysisOptions -> Maybe Text
stopwords} -> Maybe Text
stopwords) (\s :: AnalysisOptions
s@AnalysisOptions' {} Maybe Text
a -> AnalysisOptions
s {$sel:stopwords:AnalysisOptions' :: Maybe Text
stopwords = Maybe Text
a} :: AnalysisOptions)

-- | A JSON array that contains a collection of terms, tokens, readings and
-- part of speech for Japanese Tokenizaiton. The Japanese tokenization
-- dictionary enables you to override the default tokenization for selected
-- terms. This is only valid for Japanese language fields.
analysisOptions_japaneseTokenizationDictionary :: Lens.Lens' AnalysisOptions (Prelude.Maybe Prelude.Text)
analysisOptions_japaneseTokenizationDictionary :: (Maybe Text -> f (Maybe Text))
-> AnalysisOptions -> f AnalysisOptions
analysisOptions_japaneseTokenizationDictionary = (AnalysisOptions -> Maybe Text)
-> (AnalysisOptions -> Maybe Text -> AnalysisOptions)
-> Lens AnalysisOptions AnalysisOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisOptions' {Maybe Text
japaneseTokenizationDictionary :: Maybe Text
$sel:japaneseTokenizationDictionary:AnalysisOptions' :: AnalysisOptions -> Maybe Text
japaneseTokenizationDictionary} -> Maybe Text
japaneseTokenizationDictionary) (\s :: AnalysisOptions
s@AnalysisOptions' {} Maybe Text
a -> AnalysisOptions
s {$sel:japaneseTokenizationDictionary:AnalysisOptions' :: Maybe Text
japaneseTokenizationDictionary = Maybe Text
a} :: AnalysisOptions)

-- | A JSON object that defines synonym groups and aliases. A synonym group
-- is an array of arrays, where each sub-array is a group of terms where
-- each term in the group is considered a synonym of every other term in
-- the group. The aliases value is an object that contains a collection of
-- string:value pairs where the string specifies a term and the array of
-- values specifies each of the aliases for that term. An alias is
-- considered a synonym of the specified term, but the term is not
-- considered a synonym of the alias. For more information about specifying
-- synonyms, see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-analysis-schemes.html#synonyms Synonyms>
-- in the /Amazon CloudSearch Developer Guide/.
analysisOptions_synonyms :: Lens.Lens' AnalysisOptions (Prelude.Maybe Prelude.Text)
analysisOptions_synonyms :: (Maybe Text -> f (Maybe Text))
-> AnalysisOptions -> f AnalysisOptions
analysisOptions_synonyms = (AnalysisOptions -> Maybe Text)
-> (AnalysisOptions -> Maybe Text -> AnalysisOptions)
-> Lens AnalysisOptions AnalysisOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisOptions' {Maybe Text
synonyms :: Maybe Text
$sel:synonyms:AnalysisOptions' :: AnalysisOptions -> Maybe Text
synonyms} -> Maybe Text
synonyms) (\s :: AnalysisOptions
s@AnalysisOptions' {} Maybe Text
a -> AnalysisOptions
s {$sel:synonyms:AnalysisOptions' :: Maybe Text
synonyms = Maybe Text
a} :: AnalysisOptions)

-- | A JSON object that contains a collection of string:value pairs that each
-- map a term to its stem. For example,
-- @{\"term1\": \"stem1\", \"term2\": \"stem2\", \"term3\": \"stem3\"}@.
-- The stemming dictionary is applied in addition to any algorithmic
-- stemming. This enables you to override the results of the algorithmic
-- stemming to correct specific cases of overstemming or understemming. The
-- maximum size of a stemming dictionary is 500 KB.
analysisOptions_stemmingDictionary :: Lens.Lens' AnalysisOptions (Prelude.Maybe Prelude.Text)
analysisOptions_stemmingDictionary :: (Maybe Text -> f (Maybe Text))
-> AnalysisOptions -> f AnalysisOptions
analysisOptions_stemmingDictionary = (AnalysisOptions -> Maybe Text)
-> (AnalysisOptions -> Maybe Text -> AnalysisOptions)
-> Lens AnalysisOptions AnalysisOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisOptions' {Maybe Text
stemmingDictionary :: Maybe Text
$sel:stemmingDictionary:AnalysisOptions' :: AnalysisOptions -> Maybe Text
stemmingDictionary} -> Maybe Text
stemmingDictionary) (\s :: AnalysisOptions
s@AnalysisOptions' {} Maybe Text
a -> AnalysisOptions
s {$sel:stemmingDictionary:AnalysisOptions' :: Maybe Text
stemmingDictionary = Maybe Text
a} :: AnalysisOptions)

instance Core.FromXML AnalysisOptions where
  parseXML :: [Node] -> Either String AnalysisOptions
parseXML [Node]
x =
    Maybe AlgorithmicStemming
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AnalysisOptions
AnalysisOptions'
      (Maybe AlgorithmicStemming
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AnalysisOptions)
-> Either String (Maybe AlgorithmicStemming)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> AnalysisOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe AlgorithmicStemming)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AlgorithmicStemming")
      Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> AnalysisOptions)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Maybe Text -> AnalysisOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Stopwords")
      Either
  String (Maybe Text -> Maybe Text -> Maybe Text -> AnalysisOptions)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> AnalysisOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"JapaneseTokenizationDictionary")
      Either String (Maybe Text -> Maybe Text -> AnalysisOptions)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> AnalysisOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Synonyms")
      Either String (Maybe Text -> AnalysisOptions)
-> Either String (Maybe Text) -> Either String AnalysisOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StemmingDictionary")

instance Prelude.Hashable AnalysisOptions

instance Prelude.NFData AnalysisOptions

instance Core.ToQuery AnalysisOptions where
  toQuery :: AnalysisOptions -> QueryString
toQuery AnalysisOptions' {Maybe Text
Maybe AlgorithmicStemming
stemmingDictionary :: Maybe Text
synonyms :: Maybe Text
japaneseTokenizationDictionary :: Maybe Text
stopwords :: Maybe Text
algorithmicStemming :: Maybe AlgorithmicStemming
$sel:stemmingDictionary:AnalysisOptions' :: AnalysisOptions -> Maybe Text
$sel:synonyms:AnalysisOptions' :: AnalysisOptions -> Maybe Text
$sel:japaneseTokenizationDictionary:AnalysisOptions' :: AnalysisOptions -> Maybe Text
$sel:stopwords:AnalysisOptions' :: AnalysisOptions -> Maybe Text
$sel:algorithmicStemming:AnalysisOptions' :: AnalysisOptions -> Maybe AlgorithmicStemming
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"AlgorithmicStemming" ByteString -> Maybe AlgorithmicStemming -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe AlgorithmicStemming
algorithmicStemming,
        ByteString
"Stopwords" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stopwords,
        ByteString
"JapaneseTokenizationDictionary"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
japaneseTokenizationDictionary,
        ByteString
"Synonyms" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
synonyms,
        ByteString
"StemmingDictionary" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stemmingDictionary
      ]