presidio-analyzer 2.2.363__tar.gz

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.
Files changed (178) hide show
  1. presidio_analyzer-2.2.363/PKG-INFO +153 -0
  2. presidio_analyzer-2.2.363/README.md +96 -0
  3. presidio_analyzer-2.2.363/presidio_analyzer/__init__.py +54 -0
  4. presidio_analyzer-2.2.363/presidio_analyzer/analysis_explanation.py +65 -0
  5. presidio_analyzer-2.2.363/presidio_analyzer/analyzer_engine.py +442 -0
  6. presidio_analyzer-2.2.363/presidio_analyzer/analyzer_engine_provider.py +181 -0
  7. presidio_analyzer-2.2.363/presidio_analyzer/analyzer_request.py +42 -0
  8. presidio_analyzer-2.2.363/presidio_analyzer/app_tracer.py +27 -0
  9. presidio_analyzer-2.2.363/presidio_analyzer/batch_analyzer_engine.py +159 -0
  10. presidio_analyzer-2.2.363/presidio_analyzer/chunkers/__init__.py +15 -0
  11. presidio_analyzer-2.2.363/presidio_analyzer/chunkers/base_chunker.py +146 -0
  12. presidio_analyzer-2.2.363/presidio_analyzer/chunkers/character_based_text_chunker.py +123 -0
  13. presidio_analyzer-2.2.363/presidio_analyzer/chunkers/text_chunker_provider.py +60 -0
  14. presidio_analyzer-2.2.363/presidio_analyzer/conf/default.yaml +35 -0
  15. presidio_analyzer-2.2.363/presidio_analyzer/conf/default_analyzer.yaml +3 -0
  16. presidio_analyzer-2.2.363/presidio_analyzer/conf/default_analyzer_full.yaml +158 -0
  17. presidio_analyzer-2.2.363/presidio_analyzer/conf/default_recognizers.yaml +497 -0
  18. presidio_analyzer-2.2.363/presidio_analyzer/conf/example_recognizers.yaml +39 -0
  19. presidio_analyzer-2.2.363/presidio_analyzer/conf/langextract_config_azureopenai.yaml +58 -0
  20. presidio_analyzer-2.2.363/presidio_analyzer/conf/langextract_config_basic.yaml +77 -0
  21. presidio_analyzer-2.2.363/presidio_analyzer/conf/langextract_prompts/default_pii_phi_examples.yaml +160 -0
  22. presidio_analyzer-2.2.363/presidio_analyzer/conf/langextract_prompts/default_pii_phi_prompt.j2 +27 -0
  23. presidio_analyzer-2.2.363/presidio_analyzer/conf/slim.yaml +124 -0
  24. presidio_analyzer-2.2.363/presidio_analyzer/conf/slim_nlp.yaml +5 -0
  25. presidio_analyzer-2.2.363/presidio_analyzer/conf/spacy.yaml +36 -0
  26. presidio_analyzer-2.2.363/presidio_analyzer/conf/spacy_multilingual.yaml +30 -0
  27. presidio_analyzer-2.2.363/presidio_analyzer/conf/stanza.yaml +19 -0
  28. presidio_analyzer-2.2.363/presidio_analyzer/conf/stanza_multilingual.yaml +22 -0
  29. presidio_analyzer-2.2.363/presidio_analyzer/conf/transformers.yaml +45 -0
  30. presidio_analyzer-2.2.363/presidio_analyzer/context_aware_enhancers/__init__.py +6 -0
  31. presidio_analyzer-2.2.363/presidio_analyzer/context_aware_enhancers/context_aware_enhancer.py +66 -0
  32. presidio_analyzer-2.2.363/presidio_analyzer/context_aware_enhancers/lemma_context_aware_enhancer.py +370 -0
  33. presidio_analyzer-2.2.363/presidio_analyzer/dict_analyzer_result.py +29 -0
  34. presidio_analyzer-2.2.363/presidio_analyzer/entity_recognizer.py +303 -0
  35. presidio_analyzer-2.2.363/presidio_analyzer/input_validation/__init__.py +25 -0
  36. presidio_analyzer-2.2.363/presidio_analyzer/input_validation/language_validation.py +18 -0
  37. presidio_analyzer-2.2.363/presidio_analyzer/input_validation/schemas.py +149 -0
  38. presidio_analyzer-2.2.363/presidio_analyzer/input_validation/yaml_recognizer_models.py +537 -0
  39. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/__init__.py +61 -0
  40. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/azure_auth_helper.py +98 -0
  41. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/config_loader.py +127 -0
  42. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/entity_mapper.py +212 -0
  43. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/examples_loader.py +56 -0
  44. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/langextract_helper.py +208 -0
  45. presidio_analyzer-2.2.363/presidio_analyzer/llm_utils/prompt_loader.py +60 -0
  46. presidio_analyzer-2.2.363/presidio_analyzer/lm_recognizer.py +161 -0
  47. presidio_analyzer-2.2.363/presidio_analyzer/local_recognizer.py +7 -0
  48. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/__init__.py +24 -0
  49. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/device_detector.py +92 -0
  50. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/ner_model_configuration.py +128 -0
  51. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/nlp_artifacts.py +88 -0
  52. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/nlp_engine.py +65 -0
  53. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/nlp_engine_provider.py +128 -0
  54. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/slim_spacy_nlp_engine.py +269 -0
  55. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/spacy_nlp_engine.py +290 -0
  56. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/stanza_nlp_engine.py +517 -0
  57. presidio_analyzer-2.2.363/presidio_analyzer/nlp_engine/transformers_nlp_engine.py +137 -0
  58. presidio_analyzer-2.2.363/presidio_analyzer/pattern.py +66 -0
  59. presidio_analyzer-2.2.363/presidio_analyzer/pattern_recognizer.py +324 -0
  60. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/__init__.py +273 -0
  61. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/__init__.py +7 -0
  62. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/australia/__init__.py +13 -0
  63. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/australia/au_abn_recognizer.py +91 -0
  64. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/australia/au_acn_recognizer.py +91 -0
  65. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/australia/au_medicare_recognizer.py +87 -0
  66. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/australia/au_tfn_recognizer.py +93 -0
  67. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/canada/__init__.py +7 -0
  68. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/canada/ca_sin_recognizer.py +86 -0
  69. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/finland/__init__.py +7 -0
  70. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/finland/fi_personal_identity_code_recognizer.py +70 -0
  71. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/__init__.py +1 -0
  72. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_bsnr_recognizer.py +147 -0
  73. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_fuehrerschein_recognizer.py +100 -0
  74. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_handelsregister_recognizer.py +89 -0
  75. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_health_insurance_recognizer.py +136 -0
  76. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_id_card_recognizer.py +123 -0
  77. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_kfz_recognizer.py +109 -0
  78. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_lanr_recognizer.py +118 -0
  79. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_passport_recognizer.py +129 -0
  80. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_plz_recognizer.py +88 -0
  81. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_social_security_recognizer.py +162 -0
  82. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_tax_id_recognizer.py +112 -0
  83. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_tax_number_recognizer.py +88 -0
  84. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/germany/de_vat_id_recognizer.py +179 -0
  85. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/__init__.py +17 -0
  86. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_aadhaar_recognizer.py +132 -0
  87. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_gstin_recognizer.py +174 -0
  88. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_pan_recognizer.py +71 -0
  89. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_passport_recognizer.py +49 -0
  90. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_vehicle_registration_recognizer.py +397 -0
  91. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/india/in_voter_recognizer.py +58 -0
  92. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/__init__.py +15 -0
  93. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/it_driver_license_recognizer.py +46 -0
  94. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/it_fiscal_code_recognizer.py +191 -0
  95. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/it_identity_card_recognizer.py +74 -0
  96. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/it_passport_recognizer.py +53 -0
  97. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/italy/it_vat_code.py +96 -0
  98. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/__init__.py +17 -0
  99. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/kr_brn_recognizer.py +126 -0
  100. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/kr_driver_license_recognizer.py +109 -0
  101. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/kr_frn_recognizer.py +90 -0
  102. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/kr_passport_recognizer.py +61 -0
  103. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/korea/kr_rrn_recognizer.py +143 -0
  104. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/nigeria/__init__.py +9 -0
  105. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/nigeria/ng_nin_recognizer.py +106 -0
  106. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/nigeria/ng_vehicle_registration_recognizer.py +60 -0
  107. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/philippines/__init__.py +5 -0
  108. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/philippines/ph_tin_recognizer.py +106 -0
  109. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/poland/__init__.py +7 -0
  110. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/poland/pl_pesel_recognizer.py +60 -0
  111. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/singapore/__init__.py +9 -0
  112. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/singapore/sg_fin_recognizer.py +45 -0
  113. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/singapore/sg_uen_recognizer.py +190 -0
  114. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/south_africa/__init__.py +7 -0
  115. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/south_africa/za_id_number_recognizer.py +124 -0
  116. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/spain/__init__.py +11 -0
  117. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/spain/es_nie_recognizer.py +77 -0
  118. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/spain/es_nif_recognizer.py +60 -0
  119. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/spain/es_passport_recognizer.py +52 -0
  120. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/sweden/__init__.py +9 -0
  121. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/sweden/se_organisationsnummer_recognizer.py +109 -0
  122. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/sweden/se_personnummer_recognizer.py +135 -0
  123. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/thai/__init__.py +7 -0
  124. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/thai/th_tnin_recognizer.py +143 -0
  125. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/turkey/__init__.py +9 -0
  126. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/turkey/tr_license_plate_recognizer.py +96 -0
  127. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/turkey/tr_national_id_recognizer.py +110 -0
  128. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/__init__.py +17 -0
  129. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_driving_licence_recognizer.py +93 -0
  130. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_nhs_recognizer.py +73 -0
  131. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_nino_recognizer.py +44 -0
  132. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_passport_recognizer.py +57 -0
  133. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_postcode_recognizer.py +66 -0
  134. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/uk/uk_vehicle_registration_recognizer.py +111 -0
  135. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/__init__.py +23 -0
  136. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/aba_routing_recognizer.py +76 -0
  137. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/medical_license_recognizer.py +75 -0
  138. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_bank_recognizer.py +54 -0
  139. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_driver_license_recognizer.py +70 -0
  140. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_itin_recognizer.py +54 -0
  141. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_mbi_recognizer.py +101 -0
  142. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_npi_recognizer.py +119 -0
  143. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_passport_recognizer.py +41 -0
  144. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/country_specific/us/us_ssn_recognizer.py +84 -0
  145. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/__init__.py +21 -0
  146. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/credit_card_recognizer.py +82 -0
  147. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/crypto_recognizer.py +141 -0
  148. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/date_recognizer.py +102 -0
  149. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/email_recognizer.py +53 -0
  150. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/iban_patterns.py +185 -0
  151. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/iban_recognizer.py +243 -0
  152. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/ip_recognizer.py +75 -0
  153. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/mac_recognizer.py +73 -0
  154. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/phone_recognizer.py +105 -0
  155. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/generic/url_recognizer.py +50 -0
  156. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/ner/__init__.py +11 -0
  157. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/ner/gliner_recognizer.py +228 -0
  158. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/ner/huggingface_ner_recognizer.py +439 -0
  159. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/ner/medical_ner_recognizer.py +68 -0
  160. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/nlp_engine_recognizers/__init__.py +11 -0
  161. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/nlp_engine_recognizers/spacy_recognizer.py +139 -0
  162. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/nlp_engine_recognizers/stanza_recognizer.py +19 -0
  163. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/nlp_engine_recognizers/transformers_recognizer.py +37 -0
  164. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/__init__.py +13 -0
  165. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/ahds_recognizer.py +149 -0
  166. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/azure_ai_language.py +160 -0
  167. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/azure_openai_langextract_recognizer.py +159 -0
  168. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/azure_openai_provider.py +200 -0
  169. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/basic_langextract_recognizer.py +91 -0
  170. presidio_analyzer-2.2.363/presidio_analyzer/predefined_recognizers/third_party/langextract_recognizer.py +186 -0
  171. presidio_analyzer-2.2.363/presidio_analyzer/py.typed +1 -0
  172. presidio_analyzer-2.2.363/presidio_analyzer/recognizer_registry/__init__.py +6 -0
  173. presidio_analyzer-2.2.363/presidio_analyzer/recognizer_registry/recognizer_registry.py +391 -0
  174. presidio_analyzer-2.2.363/presidio_analyzer/recognizer_registry/recognizer_registry_provider.py +241 -0
  175. presidio_analyzer-2.2.363/presidio_analyzer/recognizer_registry/recognizers_loader_utils.py +817 -0
  176. presidio_analyzer-2.2.363/presidio_analyzer/recognizer_result.py +188 -0
  177. presidio_analyzer-2.2.363/presidio_analyzer/remote_recognizer.py +56 -0
  178. presidio_analyzer-2.2.363/pyproject.toml +87 -0
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: presidio_analyzer
3
+ Version: 2.2.363
4
+ Summary: Presidio Analyzer package
5
+ License-Expression: MIT
6
+ Keywords: presidio_analyzer
7
+ Author: Presidio
8
+ Author-email: presidio@microsoft.com
9
+ Requires-Python: >=3.10,<3.15
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Provides-Extra: ahds
18
+ Provides-Extra: azure-ai-language
19
+ Provides-Extra: gliner
20
+ Provides-Extra: langextract
21
+ Provides-Extra: server
22
+ Provides-Extra: stanza
23
+ Provides-Extra: transformers
24
+ Requires-Dist: accelerate (>=0.20.0,<2.0.0) ; extra == "transformers"
25
+ Requires-Dist: azure-ai-textanalytics (>=5.4.0,<6.0.0) ; extra == "azure-ai-language"
26
+ Requires-Dist: azure-core (>=1.39.0,<2.0.0) ; extra == "azure-ai-language"
27
+ Requires-Dist: azure-health-deidentification (>=1.1.0b1,<2.0.0) ; extra == "ahds"
28
+ Requires-Dist: azure-identity (>=1.18.0,<2.0.0) ; extra == "langextract"
29
+ Requires-Dist: azure-identity (>=1.25.3,<2.0.0) ; extra == "ahds"
30
+ Requires-Dist: click (>=8.1.0,<9.0.0)
31
+ Requires-Dist: flask (>=1.1,<4.0.0) ; extra == "server"
32
+ Requires-Dist: gliner (>=0.2.26,<1.0.0) ; extra == "gliner"
33
+ Requires-Dist: gunicorn (>=20.0.0,<26.0.0) ; (platform_system != "Windows") and (extra == "server")
34
+ Requires-Dist: huggingface_hub (>=0.20.0,<2.0.0) ; extra == "transformers"
35
+ Requires-Dist: huggingface_hub ; extra == "gliner"
36
+ Requires-Dist: jinja2 (>=3.0.0,<4.0.0) ; extra == "langextract"
37
+ Requires-Dist: langextract (>=1.0.0,<2.0.0) ; extra == "langextract"
38
+ Requires-Dist: more-itertools (>=10.0.0,<12.0.0) ; extra == "langextract"
39
+ Requires-Dist: numpy (>=1.19.0,<2.5.0)
40
+ Requires-Dist: onnxruntime (>=1.19) ; (python_version > "3.10") and (extra == "gliner")
41
+ Requires-Dist: onnxruntime (>=1.19,<1.24.1) ; (python_version == "3.10") and (extra == "gliner")
42
+ Requires-Dist: openai (>=1.50.0,<3.0.0) ; extra == "langextract"
43
+ Requires-Dist: phonenumbers (>=9.0.28,<10.0.0)
44
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0)
45
+ Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
46
+ Requires-Dist: regex (>=2023.0.0)
47
+ Requires-Dist: spacy (>=3.4.4,!=3.7.0,!=3.8.14,<4.0.0)
48
+ Requires-Dist: spacy_huggingface_pipelines (>=0.0.4,<1.0.0) ; extra == "transformers"
49
+ Requires-Dist: stanza (>=1.11.1,<2.0.0) ; extra == "stanza"
50
+ Requires-Dist: tldextract (>=5.3.1,<6.0.0)
51
+ Requires-Dist: transformers (>=4.0.0,<6.0.0) ; extra == "transformers"
52
+ Requires-Dist: transformers ; extra == "gliner"
53
+ Requires-Dist: waitress (>=2.0.0,<4.0.0) ; (platform_system == "Windows") and (extra == "server")
54
+ Project-URL: Homepage, https://github.com/data-privacy-stack/presidio
55
+ Description-Content-Type: text/markdown
56
+
57
+ # Presidio analyzer
58
+
59
+ ## Description
60
+
61
+ The Presidio analyzer is a Python based service for detecting PII entities in text.
62
+
63
+ During analysis, it runs a set of different _PII Recognizers_,
64
+ each one in charge of detecting one or more PII entities using different mechanisms.
65
+
66
+ Presidio analyzer comes with a set of predefined recognizers,
67
+ but can easily be extended with other types of custom recognizers.
68
+ Predefined and custom recognizers leverage regex,
69
+ Named Entity Recognition and other types of logic to detect PII in unstructured text.
70
+
71
+ ### Language Model-based PII/PHI Detection
72
+
73
+ Presidio analyzer supports language model-based PII/PHI detection (LLMs, SLMs) for flexible entity recognition. The current implementation uses [LangExtract](https://github.com/google/langextract) with support for multiple providers:
74
+
75
+ - **Ollama** - Local model deployment for privacy-sensitive environments
76
+ - **Azure OpenAI** - Cloud-based deployment with enterprise features
77
+
78
+ ```bash
79
+ pip install presidio-analyzer[langextract]
80
+ ```
81
+
82
+ #### Quick Usage
83
+
84
+ **Ollama** (local models):
85
+
86
+ ```python
87
+ from presidio_analyzer.predefined_recognizers import BasicLangExtractRecognizer
88
+ recognizer = BasicLangExtractRecognizer() # Uses default config
89
+ ```
90
+
91
+ **Azure OpenAI** (cloud models):
92
+
93
+ ```python
94
+ from presidio_analyzer.predefined_recognizers import AzureOpenAILangExtractRecognizer
95
+
96
+ # Simple usage - pass everything as parameters
97
+ recognizer = AzureOpenAILangExtractRecognizer(
98
+ model_id="gpt-4", # Your Azure deployment name
99
+ azure_endpoint="https://your-resource.openai.azure.com/",
100
+ api_key="your-api-key"
101
+ )
102
+
103
+ # Or use environment variables (AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY):
104
+ recognizer = AzureOpenAILangExtractRecognizer(
105
+ model_id="gpt-4" # Your Azure deployment name
106
+ )
107
+
108
+ # Advanced: Customize entities/prompts with config file
109
+ recognizer = AzureOpenAILangExtractRecognizer(
110
+ model_id="gpt-4",
111
+ config_path="./custom_config.yaml", # Optional: for custom entities/prompts
112
+ azure_endpoint="https://your-resource.openai.azure.com/",
113
+ api_key="your-api-key"
114
+ )
115
+ ```
116
+
117
+ **Note:** LangExtract recognizers do not validate connectivity during initialization. Connection errors or missing models will be reported when `analyze()` is first called.
118
+
119
+ See the [Language Model-based PII/PHI Detection guide](https://presidio.dataprivacystack.org/samples/python/langextract/) for complete setup and usage instructions.
120
+
121
+ ## Deploy Presidio analyzer to Azure
122
+
123
+ Use the following button to deploy presidio analyzer to your Azure subscription.
124
+
125
+ [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2Fpresidio%2Fmain%2Fpresidio-analyzer%2Fdeploytoazure.json)
126
+
127
+ ## Simple usage example
128
+
129
+ ```python
130
+ from presidio_analyzer import AnalyzerEngine
131
+
132
+ # Set up the engine, loads the NLP module (spaCy model by default) and other PII recognizers
133
+ analyzer = AnalyzerEngine()
134
+
135
+ # Call analyzer to get results
136
+ results = analyzer.analyze(text="My phone number is 212-555-5555",
137
+ entities=["PHONE_NUMBER"],
138
+ language='en')
139
+ print(results)
140
+
141
+ ```
142
+
143
+ ## GPU Acceleration
144
+
145
+ For GPU acceleration, install the appropriate dependencies for your hardware:
146
+
147
+ - **Linux with NVIDIA GPU**: cupy-cuda12x (or the version matching your CUDA installation)
148
+ - **macOS with Apple Silicon**: MPS (Metal Performance Shaders) is currently not supported. The analyzer will use CPU for PyTorch operations.
149
+
150
+ ## Documentation
151
+
152
+ Additional documentation on installation, usage and extending the Analyzer can be found under the [Analyzer](https://presidio.dataprivacystack.org/analyzer/) section of [Presidio Documentation](https://presidio.dataprivacystack.org)
153
+
@@ -0,0 +1,96 @@
1
+ # Presidio analyzer
2
+
3
+ ## Description
4
+
5
+ The Presidio analyzer is a Python based service for detecting PII entities in text.
6
+
7
+ During analysis, it runs a set of different _PII Recognizers_,
8
+ each one in charge of detecting one or more PII entities using different mechanisms.
9
+
10
+ Presidio analyzer comes with a set of predefined recognizers,
11
+ but can easily be extended with other types of custom recognizers.
12
+ Predefined and custom recognizers leverage regex,
13
+ Named Entity Recognition and other types of logic to detect PII in unstructured text.
14
+
15
+ ### Language Model-based PII/PHI Detection
16
+
17
+ Presidio analyzer supports language model-based PII/PHI detection (LLMs, SLMs) for flexible entity recognition. The current implementation uses [LangExtract](https://github.com/google/langextract) with support for multiple providers:
18
+
19
+ - **Ollama** - Local model deployment for privacy-sensitive environments
20
+ - **Azure OpenAI** - Cloud-based deployment with enterprise features
21
+
22
+ ```bash
23
+ pip install presidio-analyzer[langextract]
24
+ ```
25
+
26
+ #### Quick Usage
27
+
28
+ **Ollama** (local models):
29
+
30
+ ```python
31
+ from presidio_analyzer.predefined_recognizers import BasicLangExtractRecognizer
32
+ recognizer = BasicLangExtractRecognizer() # Uses default config
33
+ ```
34
+
35
+ **Azure OpenAI** (cloud models):
36
+
37
+ ```python
38
+ from presidio_analyzer.predefined_recognizers import AzureOpenAILangExtractRecognizer
39
+
40
+ # Simple usage - pass everything as parameters
41
+ recognizer = AzureOpenAILangExtractRecognizer(
42
+ model_id="gpt-4", # Your Azure deployment name
43
+ azure_endpoint="https://your-resource.openai.azure.com/",
44
+ api_key="your-api-key"
45
+ )
46
+
47
+ # Or use environment variables (AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY):
48
+ recognizer = AzureOpenAILangExtractRecognizer(
49
+ model_id="gpt-4" # Your Azure deployment name
50
+ )
51
+
52
+ # Advanced: Customize entities/prompts with config file
53
+ recognizer = AzureOpenAILangExtractRecognizer(
54
+ model_id="gpt-4",
55
+ config_path="./custom_config.yaml", # Optional: for custom entities/prompts
56
+ azure_endpoint="https://your-resource.openai.azure.com/",
57
+ api_key="your-api-key"
58
+ )
59
+ ```
60
+
61
+ **Note:** LangExtract recognizers do not validate connectivity during initialization. Connection errors or missing models will be reported when `analyze()` is first called.
62
+
63
+ See the [Language Model-based PII/PHI Detection guide](https://presidio.dataprivacystack.org/samples/python/langextract/) for complete setup and usage instructions.
64
+
65
+ ## Deploy Presidio analyzer to Azure
66
+
67
+ Use the following button to deploy presidio analyzer to your Azure subscription.
68
+
69
+ [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2Fpresidio%2Fmain%2Fpresidio-analyzer%2Fdeploytoazure.json)
70
+
71
+ ## Simple usage example
72
+
73
+ ```python
74
+ from presidio_analyzer import AnalyzerEngine
75
+
76
+ # Set up the engine, loads the NLP module (spaCy model by default) and other PII recognizers
77
+ analyzer = AnalyzerEngine()
78
+
79
+ # Call analyzer to get results
80
+ results = analyzer.analyze(text="My phone number is 212-555-5555",
81
+ entities=["PHONE_NUMBER"],
82
+ language='en')
83
+ print(results)
84
+
85
+ ```
86
+
87
+ ## GPU Acceleration
88
+
89
+ For GPU acceleration, install the appropriate dependencies for your hardware:
90
+
91
+ - **Linux with NVIDIA GPU**: cupy-cuda12x (or the version matching your CUDA installation)
92
+ - **macOS with Apple Silicon**: MPS (Metal Performance Shaders) is currently not supported. The analyzer will use CPU for PyTorch operations.
93
+
94
+ ## Documentation
95
+
96
+ Additional documentation on installation, usage and extending the Analyzer can be found under the [Analyzer](https://presidio.dataprivacystack.org/analyzer/) section of [Presidio Documentation](https://presidio.dataprivacystack.org)
@@ -0,0 +1,54 @@
1
+ # isort: skip_file
2
+ """Presidio analyzer package."""
3
+
4
+ import logging
5
+
6
+ from presidio_analyzer.analysis_explanation import AnalysisExplanation
7
+ from presidio_analyzer.recognizer_result import RecognizerResult
8
+ from presidio_analyzer.dict_analyzer_result import DictAnalyzerResult
9
+ from presidio_analyzer.entity_recognizer import EntityRecognizer
10
+ from presidio_analyzer.local_recognizer import LocalRecognizer
11
+ from presidio_analyzer.pattern import Pattern
12
+ from presidio_analyzer.pattern_recognizer import PatternRecognizer
13
+ from presidio_analyzer.remote_recognizer import RemoteRecognizer
14
+ from presidio_analyzer.lm_recognizer import LMRecognizer
15
+ from presidio_analyzer.recognizer_registry import RecognizerRegistry
16
+ from presidio_analyzer.analyzer_engine import AnalyzerEngine
17
+ from presidio_analyzer.batch_analyzer_engine import BatchAnalyzerEngine
18
+ from presidio_analyzer.analyzer_request import AnalyzerRequest
19
+ from presidio_analyzer.context_aware_enhancers import ContextAwareEnhancer
20
+ from presidio_analyzer.context_aware_enhancers import LemmaContextAwareEnhancer
21
+ from presidio_analyzer.analyzer_engine_provider import AnalyzerEngineProvider
22
+
23
+ # Define default loggers behavior
24
+
25
+ # 1. presidio_analyzer logger
26
+ logging.getLogger("presidio-analyzer").addHandler(logging.NullHandler())
27
+
28
+ # 2. decision_process logger.
29
+ # Setting the decision_process trace here as we would want it
30
+ # to be activated using a parameter to AnalyzeEngine and not by default.
31
+ decision_process_logger = logging.getLogger("decision_process")
32
+ ch = logging.StreamHandler()
33
+ formatter = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s]%(message)s")
34
+ ch.setFormatter(formatter)
35
+ decision_process_logger.addHandler(ch)
36
+ decision_process_logger.setLevel("INFO")
37
+ __all__ = [
38
+ "Pattern",
39
+ "AnalysisExplanation",
40
+ "RecognizerResult",
41
+ "DictAnalyzerResult",
42
+ "EntityRecognizer",
43
+ "LocalRecognizer",
44
+ "PatternRecognizer",
45
+ "RemoteRecognizer",
46
+ "LMRecognizer",
47
+ "RecognizerRegistry",
48
+ "AnalyzerEngine",
49
+ "AnalyzerRequest",
50
+ "ContextAwareEnhancer",
51
+ "LemmaContextAwareEnhancer",
52
+ "BatchAnalyzerEngine",
53
+ "AnalyzerEngineProvider",
54
+ ]
@@ -0,0 +1,65 @@
1
+ from typing import Dict
2
+
3
+
4
+ class AnalysisExplanation:
5
+ """
6
+ Hold tracing information to explain why PII entities were identified as such.
7
+
8
+ :param recognizer: name of recognizer that made the decision
9
+ :param original_score: recognizer's confidence in result
10
+ :param pattern_name: name of pattern
11
+ (if decision was made by a PatternRecognizer)
12
+ :param pattern: regex pattern that was applied (if PatternRecognizer)
13
+ :param validation_result: result of a validation (e.g. checksum)
14
+ :param textual_explanation: Free text for describing
15
+ a decision of a logic or model
16
+ """
17
+
18
+ def __init__(
19
+ self,
20
+ recognizer: str,
21
+ original_score: float,
22
+ pattern_name: str = None,
23
+ pattern: str = None,
24
+ validation_result: bool = None,
25
+ textual_explanation: str = None,
26
+ regex_flags: int = None,
27
+ ):
28
+ self.recognizer = recognizer
29
+ self.pattern_name = pattern_name
30
+ self.pattern = pattern
31
+ self.original_score = original_score
32
+ self.score = original_score
33
+ self.textual_explanation = textual_explanation
34
+ self.score_context_improvement = 0
35
+ self.supportive_context_word = ""
36
+ self.validation_result = validation_result
37
+ self.regex_flags = regex_flags
38
+
39
+ def __repr__(self):
40
+ """Create string representation of the object."""
41
+ return str(self.__dict__)
42
+
43
+ def set_improved_score(self, score: float) -> None:
44
+ """Update the score and calculate the difference from the original score."""
45
+ self.score = score
46
+ self.score_context_improvement = self.score - self.original_score
47
+
48
+ def set_supportive_context_word(self, word: str) -> None:
49
+ """Set the context word which helped increase the score."""
50
+ self.supportive_context_word = word
51
+
52
+ def append_textual_explanation_line(self, text: str) -> None:
53
+ """Append a new line to textual_explanation field."""
54
+ if self.textual_explanation is None:
55
+ self.textual_explanation = text
56
+ else:
57
+ self.textual_explanation = f"{self.textual_explanation}\n{text}"
58
+
59
+ def to_dict(self) -> Dict:
60
+ """
61
+ Serialize self to dictionary.
62
+
63
+ :return: a dictionary
64
+ """
65
+ return self.__dict__