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

import Amazonka.Comprehend.Types.PiiEntityType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides information about a PII entity.
--
-- /See:/ 'newPiiEntity' smart constructor.
data PiiEntity = PiiEntity'
  { -- | A character offset in the input text that shows where the PII entity
    -- begins (the first character is at position 0). The offset returns the
    -- position of each UTF-8 code point in the string. A /code point/ is the
    -- abstract character from a particular graphical representation. For
    -- example, a multi-byte UTF-8 character maps to a single code point.
    PiiEntity -> Maybe Int
beginOffset :: Prelude.Maybe Prelude.Int,
    -- | The level of confidence that Amazon Comprehend has in the accuracy of
    -- the detection.
    PiiEntity -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | A character offset in the input text that shows where the PII entity
    -- ends. The offset returns the position of each UTF-8 code point in the
    -- string. A /code point/ is the abstract character from a particular
    -- graphical representation. For example, a multi-byte UTF-8 character maps
    -- to a single code point.
    PiiEntity -> Maybe Int
endOffset :: Prelude.Maybe Prelude.Int,
    -- | The entity\'s type.
    PiiEntity -> Maybe PiiEntityType
type' :: Prelude.Maybe PiiEntityType
  }
  deriving (PiiEntity -> PiiEntity -> Bool
(PiiEntity -> PiiEntity -> Bool)
-> (PiiEntity -> PiiEntity -> Bool) -> Eq PiiEntity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PiiEntity -> PiiEntity -> Bool
$c/= :: PiiEntity -> PiiEntity -> Bool
== :: PiiEntity -> PiiEntity -> Bool
$c== :: PiiEntity -> PiiEntity -> Bool
Prelude.Eq, ReadPrec [PiiEntity]
ReadPrec PiiEntity
Int -> ReadS PiiEntity
ReadS [PiiEntity]
(Int -> ReadS PiiEntity)
-> ReadS [PiiEntity]
-> ReadPrec PiiEntity
-> ReadPrec [PiiEntity]
-> Read PiiEntity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PiiEntity]
$creadListPrec :: ReadPrec [PiiEntity]
readPrec :: ReadPrec PiiEntity
$creadPrec :: ReadPrec PiiEntity
readList :: ReadS [PiiEntity]
$creadList :: ReadS [PiiEntity]
readsPrec :: Int -> ReadS PiiEntity
$creadsPrec :: Int -> ReadS PiiEntity
Prelude.Read, Int -> PiiEntity -> ShowS
[PiiEntity] -> ShowS
PiiEntity -> String
(Int -> PiiEntity -> ShowS)
-> (PiiEntity -> String)
-> ([PiiEntity] -> ShowS)
-> Show PiiEntity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PiiEntity] -> ShowS
$cshowList :: [PiiEntity] -> ShowS
show :: PiiEntity -> String
$cshow :: PiiEntity -> String
showsPrec :: Int -> PiiEntity -> ShowS
$cshowsPrec :: Int -> PiiEntity -> ShowS
Prelude.Show, (forall x. PiiEntity -> Rep PiiEntity x)
-> (forall x. Rep PiiEntity x -> PiiEntity) -> Generic PiiEntity
forall x. Rep PiiEntity x -> PiiEntity
forall x. PiiEntity -> Rep PiiEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PiiEntity x -> PiiEntity
$cfrom :: forall x. PiiEntity -> Rep PiiEntity x
Prelude.Generic)

-- |
-- Create a value of 'PiiEntity' 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:
--
-- 'beginOffset', 'piiEntity_beginOffset' - A character offset in the input text that shows where the PII entity
-- begins (the first character is at position 0). The offset returns the
-- position of each UTF-8 code point in the string. A /code point/ is the
-- abstract character from a particular graphical representation. For
-- example, a multi-byte UTF-8 character maps to a single code point.
--
-- 'score', 'piiEntity_score' - The level of confidence that Amazon Comprehend has in the accuracy of
-- the detection.
--
-- 'endOffset', 'piiEntity_endOffset' - A character offset in the input text that shows where the PII entity
-- ends. The offset returns the position of each UTF-8 code point in the
-- string. A /code point/ is the abstract character from a particular
-- graphical representation. For example, a multi-byte UTF-8 character maps
-- to a single code point.
--
-- 'type'', 'piiEntity_type' - The entity\'s type.
newPiiEntity ::
  PiiEntity
newPiiEntity :: PiiEntity
newPiiEntity =
  PiiEntity' :: Maybe Int
-> Maybe Double -> Maybe Int -> Maybe PiiEntityType -> PiiEntity
PiiEntity'
    { $sel:beginOffset:PiiEntity' :: Maybe Int
beginOffset = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:score:PiiEntity' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:endOffset:PiiEntity' :: Maybe Int
endOffset = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':PiiEntity' :: Maybe PiiEntityType
type' = Maybe PiiEntityType
forall a. Maybe a
Prelude.Nothing
    }

-- | A character offset in the input text that shows where the PII entity
-- begins (the first character is at position 0). The offset returns the
-- position of each UTF-8 code point in the string. A /code point/ is the
-- abstract character from a particular graphical representation. For
-- example, a multi-byte UTF-8 character maps to a single code point.
piiEntity_beginOffset :: Lens.Lens' PiiEntity (Prelude.Maybe Prelude.Int)
piiEntity_beginOffset :: (Maybe Int -> f (Maybe Int)) -> PiiEntity -> f PiiEntity
piiEntity_beginOffset = (PiiEntity -> Maybe Int)
-> (PiiEntity -> Maybe Int -> PiiEntity)
-> Lens PiiEntity PiiEntity (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PiiEntity' {Maybe Int
beginOffset :: Maybe Int
$sel:beginOffset:PiiEntity' :: PiiEntity -> Maybe Int
beginOffset} -> Maybe Int
beginOffset) (\s :: PiiEntity
s@PiiEntity' {} Maybe Int
a -> PiiEntity
s {$sel:beginOffset:PiiEntity' :: Maybe Int
beginOffset = Maybe Int
a} :: PiiEntity)

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

-- | A character offset in the input text that shows where the PII entity
-- ends. The offset returns the position of each UTF-8 code point in the
-- string. A /code point/ is the abstract character from a particular
-- graphical representation. For example, a multi-byte UTF-8 character maps
-- to a single code point.
piiEntity_endOffset :: Lens.Lens' PiiEntity (Prelude.Maybe Prelude.Int)
piiEntity_endOffset :: (Maybe Int -> f (Maybe Int)) -> PiiEntity -> f PiiEntity
piiEntity_endOffset = (PiiEntity -> Maybe Int)
-> (PiiEntity -> Maybe Int -> PiiEntity)
-> Lens PiiEntity PiiEntity (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PiiEntity' {Maybe Int
endOffset :: Maybe Int
$sel:endOffset:PiiEntity' :: PiiEntity -> Maybe Int
endOffset} -> Maybe Int
endOffset) (\s :: PiiEntity
s@PiiEntity' {} Maybe Int
a -> PiiEntity
s {$sel:endOffset:PiiEntity' :: Maybe Int
endOffset = Maybe Int
a} :: PiiEntity)

-- | The entity\'s type.
piiEntity_type :: Lens.Lens' PiiEntity (Prelude.Maybe PiiEntityType)
piiEntity_type :: (Maybe PiiEntityType -> f (Maybe PiiEntityType))
-> PiiEntity -> f PiiEntity
piiEntity_type = (PiiEntity -> Maybe PiiEntityType)
-> (PiiEntity -> Maybe PiiEntityType -> PiiEntity)
-> Lens
     PiiEntity PiiEntity (Maybe PiiEntityType) (Maybe PiiEntityType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PiiEntity' {Maybe PiiEntityType
type' :: Maybe PiiEntityType
$sel:type':PiiEntity' :: PiiEntity -> Maybe PiiEntityType
type'} -> Maybe PiiEntityType
type') (\s :: PiiEntity
s@PiiEntity' {} Maybe PiiEntityType
a -> PiiEntity
s {$sel:type':PiiEntity' :: Maybe PiiEntityType
type' = Maybe PiiEntityType
a} :: PiiEntity)

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

instance Prelude.Hashable PiiEntity

instance Prelude.NFData PiiEntity