letter_case
letter_case
¶
Letter-case rules shared by structured and free-text replacement.
Functions:
| Name | Description |
|---|---|
case_insensitive_identity |
Return the mapping identity of |
match_letter_case |
Give a shared replacement the letter case of the occurrence it replaces. |
case_insensitive_identity(value)
¶
Return the mapping identity of value, which ignores letter case for strings.
Replacement looks up and reuses mappings by this identity, so Ada, ADA, and ada in one
record or group share a replacement. Values of other types are returned unchanged.
Example
CanonicalValue("string", "Ada") and CanonicalValue("string", "ADA") both map to
CanonicalValue("string", "ada").
Source code in src/nemo_safe_synthesizer/pii_replacer/replacement/letter_case.py
match_letter_case(occurrence, replacement)
¶
Give a shared replacement the letter case of the occurrence it replaces.
Mappings ignore case, so MARGARET and margaret share one generated replacement. An
all-capitals or all-lowercase occurrence gets the replacement in the same case; any other
occurrence keeps the replacement as generated.
Example
match_letter_case("ADA", "Kathleen") is "KATHLEEN"; match_letter_case("Ada", "Kathleen")
is "Kathleen".