Skip to content

Commit 26ca6f7

Browse files
committed
Added zipcode truncation + foreign zip code fields
1 parent 164ab30 commit 26ca6f7

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

tonic_textual/classes/generator_metadata/hipaa_address_generator_metadata.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class HipaaAddressGeneratorMetadata(BaseMetadata):
2525
realistic_synthetic_values : bool
2626
When ``True``, generates realistic-looking synthetic address values.
2727
Default is ``True``.
28+
use_three_digit_zips : bool
29+
When ``True`` zip codes are always truncated to three digits.
30+
Default is ``False``
31+
replace_foreign_zip_codes_with_zeros : bool
32+
When ``True`` foreign zip codes become all zeros
33+
Default is ``False``
2834
"""
2935

3036
def __init__(
@@ -35,6 +41,8 @@ def __init__(
3541
realistic_synthetic_values: bool = True,
3642
swaps: Optional[Dict[str,str]] = {},
3743
constant_value: Optional[str] = None,
44+
use_three_digit_zips: bool = False,
45+
replace_foreign_zip_codes_with_zeros: bool = False,
3846
):
3947
super().__init__(
4048
custom_generator=GeneratorType.HipaaAddressGenerator,
@@ -45,6 +53,8 @@ def __init__(
4553
self["useNonHipaaAddressGenerator"] = use_non_hipaa_address_generator
4654
self["replaceTruncatedZerosInZipCode"] = replace_truncated_zeros_in_zip_code
4755
self["realisticSyntheticValues"] = realistic_synthetic_values
56+
self["useThreeDigitZips"] = use_three_digit_zips
57+
self["replaceForeignZipCodesWithZeros"] = replace_foreign_zip_codes_with_zeros
4858

4959
@property
5060
def use_non_hipaa_address_generator(self) -> bool:
@@ -70,6 +80,22 @@ def realistic_synthetic_values(self) -> bool:
7080
def realistic_synthetic_values(self, value: bool):
7181
self["realisticSyntheticValues"] = value
7282

83+
@property
84+
def use_three_digit_zips(self) -> bool:
85+
return self["useThreeDigitZips"]
86+
87+
@use_three_digit_zips.setter
88+
def use_three_digit_zips(self, value: bool):
89+
self["useThreeDigitZips"] = value
90+
91+
@property
92+
def replace_foreign_zip_codes_with_zeros(self) -> bool:
93+
return self["replaceForeignZipCodesWithZeros"]
94+
95+
@replace_foreign_zip_codes_with_zeros.setter
96+
def replace_foreign_zip_codes_with_zeros(self, value: bool):
97+
self["replaceForeignZipCodesWithZeros"] = value
98+
7399
def to_payload(self) -> Dict:
74100
return dict(self)
75101

@@ -89,7 +115,9 @@ def from_payload(payload: Dict) -> "HipaaAddressGeneratorMetadata":
89115
replace_truncated_zeros_in_zip_code=payload.get("replaceTruncatedZerosInZipCode", True),
90116
realistic_synthetic_values=payload.get("realisticSyntheticValues", True),
91117
swaps=base_metadata.swaps,
92-
constant_value=base_metadata.constant_value
118+
constant_value=base_metadata.constant_value,
119+
use_three_digit_zips=payload.get("useThreeDigitZips", False),
120+
replace_foreign_zip_codes_with_zeros=payload.get("replaceForeignZipCodesWithZeros", False)
93121
)
94122

95123
default_hipaa_address_generator_metadata = HipaaAddressGeneratorMetadata()

tonic_textual/classes/generator_metadata/person_age_generator_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PersonAgeGeneratorMetadata(BaseDateTimeGeneratorMetadata):
2222
7 years.
2323
use_passthrough_or_group_age_generator : bool
2424
When ``True`` passes through ages 89 or under. Changes other ages to "90+"
25-
Default ``False``
25+
Default is ``False``
2626
"""
2727

2828
def __init__(

0 commit comments

Comments
 (0)