allyanonimiser 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stephen Oates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.1
2
+ Name: allyanonimiser
3
+ Version: 0.1.0
4
+ Summary: Australian-focused PII detection and anonymization for the insurance industry
5
+ Home-page: https://github.com/srepho/Allyanonimiser
6
+ Author: Stephen Oates
7
+ Author-email: Stephen Oates <stephen.j.a.oates@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Stephen Oates
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Project-URL: Homepage, https://github.com/srepho/Allyanonimiser
31
+ Project-URL: Bug Tracker, https://github.com/srepho/Allyanonimiser/issues
32
+ Project-URL: Documentation, https://github.com/srepho/Allyanonimiser#readme
33
+ Keywords: pii,anonymization,privacy,insurance,australia
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.8
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Classifier: Operating System :: OS Independent
40
+ Classifier: Topic :: Security
41
+ Classifier: Topic :: Text Processing
42
+ Requires-Python: >=3.8
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: spacy >=3.5.0
46
+ Requires-Dist: presidio-analyzer >=2.2.0
47
+ Requires-Dist: presidio-anonymizer >=2.2.0
48
+ Provides-Extra: dev
49
+ Requires-Dist: pytest >=7.0.0 ; extra == 'dev'
50
+ Requires-Dist: pytest-cov >=4.0.0 ; extra == 'dev'
51
+ Requires-Dist: black >=22.0.0 ; extra == 'dev'
52
+ Requires-Dist: isort >=5.0.0 ; extra == 'dev'
53
+ Requires-Dist: flake8 >=5.0.0 ; extra == 'dev'
54
+ Requires-Dist: mypy >=0.9.0 ; extra == 'dev'
55
+ Provides-Extra: llm
56
+ Requires-Dist: openai >=0.27.0 ; extra == 'llm'
57
+ Requires-Dist: anthropic >=0.3.0 ; extra == 'llm'
58
+
59
+ # Allyanonimiser
60
+
61
+ Australian-focused PII detection and anonymization for the insurance industry.
62
+
63
+ ## Features
64
+
65
+ - **Australian-Specific PII Detection**: Specialized recognizers for Australian TFNs, Medicare numbers, driver's licenses, and other Australian-specific identifiers.
66
+ - **Insurance Industry Focus**: Recognition of policy numbers, claim references, vehicle identifiers, and other insurance-specific data.
67
+ - **Long Text Processing**: Optimized for processing lengthy free-text fields like claim notes, medical reports, and emails.
68
+ - **Custom Pattern Creation**: Easy creation of custom entity recognizers for organization-specific data.
69
+ - **Synthetic Data Generation**: Generate realistic Australian test data for validation.
70
+ - **LLM Integration**: Use Language Models to create challenging datasets for testing.
71
+ - **Extensible Architecture**: Built on Presidio and spaCy with a modular, extensible design.
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ # Install from PyPI
77
+ pip install allyanonimiser
78
+
79
+ # Install the required spaCy model
80
+ python -m spacy download en_core_web_lg
81
+ ```
82
+
83
+ ## Quick Start
84
+
85
+ ```python
86
+ from allyanonimiser import create_au_insurance_analyzer
87
+
88
+ # Create an analyzer with Australian and insurance patterns
89
+ analyzer = create_au_insurance_analyzer()
90
+
91
+ # Analyze text
92
+ results = analyzer.analyze(
93
+ text="Please reference your policy AU-12345678 for claims related to your vehicle rego XYZ123.",
94
+ language="en"
95
+ )
96
+
97
+ # Print results
98
+ for result in results:
99
+ print(f"Entity: {result.entity_type}, Text: {result.text}, Score: {result.score}")
100
+ ```
101
+
102
+ ## Processing Insurance Documents
103
+
104
+ ### Claim Notes
105
+
106
+ ```python
107
+ from allyanonimiser import analyze_claim_notes
108
+
109
+ # Long claim note text
110
+ claim_note = """
111
+ Claim Details:
112
+ Spoke with the insured John Smith (TFN: 123 456 789) regarding damage to his vehicle ABC123.
113
+ The incident occurred on 14/05/2023 when another vehicle collided with the rear of his car.
114
+ Policy number: POL-987654321
115
+
116
+ Vehicle Details:
117
+ Toyota Corolla 2020
118
+ VIN: 1HGCM82633A123456
119
+ Registration: ABC123
120
+
121
+ Contact Information:
122
+ Phone: 0412 345 678
123
+ Email: john.smith@example.com
124
+ Address: 123 Main St, Sydney NSW 2000
125
+ """
126
+
127
+ # Analyze the claim note
128
+ analysis = analyze_claim_notes(claim_note)
129
+
130
+ # Access structured information
131
+ print("Incident Description:", analysis["incident_description"])
132
+ print("\nPII-rich segments:")
133
+ for segment in analysis["pii_segments"]:
134
+ print(f" - {segment['text'][:50]}... (PII likelihood: {segment['pii_likelihood']:.2f})")
135
+
136
+ # Anonymize the text
137
+ from allyanonimiser import EnhancedAnonymizer
138
+ anonymizer = EnhancedAnonymizer(analyzer=create_au_insurance_analyzer())
139
+ anonymized = anonymizer.anonymize(claim_note)
140
+ print("\nAnonymized text:")
141
+ print(anonymized["text"])
142
+ ```
143
+
144
+ ### Processing Emails
145
+
146
+ ```python
147
+ from allyanonimiser.insurance import InsuranceEmailAnalyzer
148
+
149
+ email_text = """
150
+ From: adjuster@insurance.com.au
151
+ To: customer@example.com
152
+ Subject: Your Claim CL-12345678
153
+
154
+ Dear Mr. Smith,
155
+
156
+ Thank you for your recent claim submission regarding your vehicle (Registration: XYZ123).
157
+
158
+ We have assigned your claim number CL-12345678. Please reference this number in all future correspondence.
159
+
160
+ Your policy POL-9876543 covers this type of damage, and we'll need the following information:
161
+ 1. Your Medicare number
162
+ 2. Additional photos of the damage
163
+ 3. The repair quote from the mechanic
164
+
165
+ Please call me at 03 9876 5432 if you have any questions.
166
+
167
+ Kind regards,
168
+ Sarah Johnson
169
+ Claims Assessor
170
+ """
171
+
172
+ email_analyzer = InsuranceEmailAnalyzer()
173
+ analysis = email_analyzer.analyze(email_text)
174
+
175
+ print("Email Subject:", analysis["subject"])
176
+ print("Claim Number:", analysis["claim_number"])
177
+ print("Policy Number:", analysis["policy_number"])
178
+ print("Customer Name:", analysis["customer_name"])
179
+ print("Identified PII:", analysis["pii_entities"])
180
+ ```
181
+
182
+ ## Creating Custom Patterns
183
+
184
+ ```python
185
+ from allyanonimiser import CustomPatternDefinition, create_pattern_from_examples
186
+
187
+ # Create a custom pattern for internal reference numbers
188
+ internal_ref_examples = [
189
+ "Internal reference: REF-12345",
190
+ "Ref Number: REF-98765",
191
+ "Reference: REF-55555"
192
+ ]
193
+
194
+ pattern = create_pattern_from_examples(
195
+ entity_type="INTERNAL_REFERENCE",
196
+ examples=internal_ref_examples,
197
+ context=["internal", "reference", "ref"],
198
+ pattern_type="regex"
199
+ )
200
+
201
+ # Add to an existing analyzer
202
+ analyzer.add_pattern(pattern)
203
+ ```
204
+
205
+ ## Using the Pattern Registry
206
+
207
+ ```python
208
+ from allyanonimiser import PatternRegistry, CustomPatternDefinition
209
+
210
+ # Create a registry
211
+ registry = PatternRegistry()
212
+
213
+ # Register patterns
214
+ registry.register_pattern(CustomPatternDefinition(
215
+ entity_type="BROKER_CODE",
216
+ patterns=["BRK-[0-9]{4}"],
217
+ context=["broker", "agent", "representative"],
218
+ name="broker_code_recognizer"
219
+ ))
220
+
221
+ # Share patterns across applications
222
+ registry.export_patterns("insurance_patterns.json")
223
+
224
+ # Later, in another application
225
+ registry.import_patterns("insurance_patterns.json")
226
+ ```
227
+
228
+ ## Working with Australian Data
229
+
230
+ ```python
231
+ from allyanonimiser.patterns import get_au_pattern_definitions
232
+
233
+ # Get all Australian pattern definitions
234
+ au_patterns = get_au_pattern_definitions()
235
+
236
+ # Print information about each pattern
237
+ for pattern in au_patterns:
238
+ print(f"Entity Type: {pattern['entity_type']}")
239
+ print(f"Description: {pattern['description']}")
240
+ print(f"Example Patterns: {pattern['patterns'][:2]}")
241
+ print("Context Terms:", ", ".join(pattern['context'][:5]))
242
+ print()
243
+ ```
244
+
245
+ ## Generating Australian Test Data
246
+
247
+ ```python
248
+ from allyanonimiser.generators import AustralianSyntheticDataGenerator
249
+
250
+ # Create a data generator
251
+ generator = AustralianSyntheticDataGenerator()
252
+
253
+ # Generate a dataset of Australian insurance documents
254
+ generator.generate_dataset(
255
+ num_documents=50,
256
+ output_dir="au_insurance_dataset",
257
+ include_annotations=True
258
+ )
259
+ ```
260
+
261
+ ## License
262
+
263
+ MIT License
@@ -0,0 +1,27 @@
1
+ generators/__init__.py,sha256=zy3RylUy3c4xxJVd7QmqgaN52ACZLSxq0mwHr43ftBA,240
2
+ generators/au_synthetic_data.py,sha256=95agiZC_is7_rcHy8SUJXnxzE6nTh5BDTQ5-Qy0VskE,26089
3
+ generators/dataset_publisher.py,sha256=kERuRc8l8ldaMvSxUZbiLDXecipw4jpcWlReWBwpqDc,21728
4
+ generators/llm_augmenter.py,sha256=iYIcerhw0BYFhN7CgfqxcpFbT-4SuDDs77MxbRQacnc,36072
5
+ insurance/__init__.py,sha256=tLvXue7gpEiEu2-xpBrzXaMt8VfWkOWBPfpPjJp4plQ,487
6
+ insurance/claim_notes_analyzer.py,sha256=tZbZnbnoylpiWNqJNCEktHNxTtQj7wlHRFspngmkgMQ,11940
7
+ insurance/email_analyzer.py,sha256=AuTifLEwUloSWteNvLnrvzp2uklcI6mtvm-Q0sbdRP8,14882
8
+ insurance/medical_report_analyzer.py,sha256=7dFwdsTswBR0R0ghyiA2cJbwDNV_5hOcTdFkrkHyT00,22679
9
+ patterns/__init__.py,sha256=LxUvC4-FqTXG-g1TvaGZ3LvtDGdp4cqbyKOfqreS3cg,634
10
+ patterns/au_patterns.py,sha256=q8FwEmXKaLzbXwOcNemzNGyyNEcRySs2COtrjoEgBLc,9316
11
+ patterns/general_patterns.py,sha256=cjIhLXjJ7-yYX4ZqtViWPxTgoxxx-hQPxUStvnhOR1Q,5554
12
+ patterns/insurance_patterns.py,sha256=Dg40YCqZryrFmhGkhJc9lhyfH9fAKWC_EjpvyQHbe_I,8025
13
+ tests/__init__.py,sha256=sY6iRnb6hQjgaLuzZkOmO_NiID2nbz4r2AgLTlVAKWI,40
14
+ tests/conftest.py,sha256=E3faqRotQ60lc0hav5iAyFC-ONaIO83yHclHEUIrQdk,6286
15
+ tests/test_analyzer.py,sha256=Oz27nuihY1aBDRhjtWU_prfMcZ5Z3xxVEGpSEXT5sus,5355
16
+ tests/test_anonymizer.py,sha256=8FYfzQFVLu_qLnWBp5_2ga-0s8IsJUevwaXoZIZbMyk,7666
17
+ tests/test_generators.py,sha256=q8dmNqlnkoaoLzR_FvVjuY2FfmGvuE5b8XAoPqXTbZ0,9056
18
+ tests/test_main_interface.py,sha256=_ws3MxVBy5Qop5RdE-2LnNrUlSM6qm45SjvQopUQCIE,6072
19
+ utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ utils/long_text_processor.py,sha256=d0nGLD49dBd67D32jY1ddBO8EbEF7iiOqPi_VgPl1U0,16370
21
+ utils/presidio_helpers.py,sha256=wchxTPl-2Zs8qTNgwygAnCESOMYOVu9vPoqgwTEwDQQ,13217
22
+ utils/spacy_helpers.py,sha256=kDFPF6I9cApewcbhM_WDOzAe-F25icIKo8fLichZlkw,8962
23
+ allyanonimiser-0.1.0.dist-info/LICENSE,sha256=4pozhzqq3l9AX8jz0KiRi-A32rU9LUfe_J0_c92lTmc,1070
24
+ allyanonimiser-0.1.0.dist-info/METADATA,sha256=_jmb3gQgph7mDTHGwnqwUL4oxqeavkrw7rPcbWeMoLc,8552
25
+ allyanonimiser-0.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
26
+ allyanonimiser-0.1.0.dist-info/top_level.txt,sha256=uQS4HtVP1Uu_DwxYEacqxJv1oxxHSU3a5MdQ7ipgYT0,42
27
+ allyanonimiser-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ generators
2
+ insurance
3
+ patterns
4
+ tests
5
+ utils
generators/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ """
2
+ Data generation tools for the Allyanonimiser package.
3
+ """
4
+
5
+ from .au_synthetic_data import AustralianSyntheticDataGenerator
6
+ from .llm_augmenter import LLMAugmenter
7
+
8
+ __all__ = [
9
+ 'AustralianSyntheticDataGenerator',
10
+ 'LLMAugmenter'
11
+ ]