apii 0.1.0__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.
- apii-0.1.0/.gitignore +25 -0
- apii-0.1.0/LICENSE-APACHE +202 -0
- apii-0.1.0/LICENSE-MIT +21 -0
- apii-0.1.0/PKG-INFO +305 -0
- apii-0.1.0/README.md +255 -0
- apii-0.1.0/apii/__init__.py +25 -0
- apii-0.1.0/apii/__main__.py +6 -0
- apii-0.1.0/apii/anonymizer.py +281 -0
- apii-0.1.0/apii/batch.py +213 -0
- apii-0.1.0/apii/checksums.py +84 -0
- apii-0.1.0/apii/cli.py +362 -0
- apii-0.1.0/apii/config.py +46 -0
- apii-0.1.0/apii/context.py +100 -0
- apii-0.1.0/apii/csvcols.py +156 -0
- apii-0.1.0/apii/daemon.py +114 -0
- apii-0.1.0/apii/documents/__init__.py +97 -0
- apii-0.1.0/apii/documents/_base.py +143 -0
- apii-0.1.0/apii/documents/csv.py +117 -0
- apii-0.1.0/apii/documents/docx.py +284 -0
- apii-0.1.0/apii/documents/html.py +290 -0
- apii-0.1.0/apii/documents/json.py +132 -0
- apii-0.1.0/apii/documents/pdf.py +92 -0
- apii-0.1.0/apii/documents/plain.py +25 -0
- apii-0.1.0/apii/documents/xlsx.py +293 -0
- apii-0.1.0/apii/evaluate.py +187 -0
- apii-0.1.0/apii/geo.py +112 -0
- apii-0.1.0/apii/guard.py +51 -0
- apii-0.1.0/apii/hook.py +189 -0
- apii-0.1.0/apii/leak_gate.py +55 -0
- apii-0.1.0/apii/ner.py +636 -0
- apii-0.1.0/apii/ner_merge.py +39 -0
- apii-0.1.0/apii/normalize.py +326 -0
- apii-0.1.0/apii/pipeline.py +166 -0
- apii-0.1.0/apii/policy.py +130 -0
- apii-0.1.0/apii/recognizer.py +24 -0
- apii-0.1.0/apii/recognizers/__init__.py +83 -0
- apii-0.1.0/apii/recognizers/_context.py +102 -0
- apii-0.1.0/apii/recognizers/address.py +190 -0
- apii-0.1.0/apii/recognizers/commercial_registration.py +73 -0
- apii-0.1.0/apii/recognizers/iban.py +84 -0
- apii-0.1.0/apii/recognizers/national_id.py +94 -0
- apii-0.1.0/apii/recognizers/pattern.py +48 -0
- apii-0.1.0/apii/recognizers/phone.py +117 -0
- apii-0.1.0/apii/recognizers/tax_number.py +104 -0
- apii-0.1.0/apii/replacer.py +39 -0
- apii-0.1.0/apii/server.py +229 -0
- apii-0.1.0/apii/streaming.py +187 -0
- apii-0.1.0/apii/structured.py +135 -0
- apii-0.1.0/apii/suppressor.py +107 -0
- apii-0.1.0/apii/types.py +114 -0
- apii-0.1.0/apii/ui.py +222 -0
- apii-0.1.0/apii/vault.py +95 -0
- apii-0.1.0/apii/watch.py +167 -0
- apii-0.1.0/docs/agent-hook-gateway.md +133 -0
- apii-0.1.0/docs/document-formats.md +97 -0
- apii-0.1.0/docs/integrations/claude-code-hook.example.json +30 -0
- apii-0.1.0/docs/local-ner.md +122 -0
- apii-0.1.0/docs/qa-private-documents.md +104 -0
- apii-0.1.0/pyproject.toml +69 -0
- apii-0.1.0/tests/eval/real/README.md +194 -0
- apii-0.1.0/tests/eval/real/build_gold.py +419 -0
- apii-0.1.0/tests/eval/real/corpus/arabic_news_bio.txt +15 -0
- apii-0.1.0/tests/eval/real/corpus/charity_payment_instructions.txt +25 -0
- apii-0.1.0/tests/eval/real/corpus/corporate_disclosure_sabic.txt +18 -0
- apii-0.1.0/tests/eval/real/corpus/cr_extract_jarir.txt +23 -0
- apii-0.1.0/tests/eval/real/corpus/english_news_bio.txt +18 -0
- apii-0.1.0/tests/eval/real/corpus/government_directory_page.txt +28 -0
- apii-0.1.0/tests/eval/real/corpus/iban_calculator_faq.txt +28 -0
- apii-0.1.0/tests/eval/real/corpus/kyc_onboarding_form.txt +20 -0
- apii-0.1.0/tests/eval/real/corpus/passport_specimen_icao.txt +18 -0
- apii-0.1.0/tests/eval/real/corpus/payroll_wps_sheet.txt +20 -0
- apii-0.1.0/tests/eval/real/corpus/press_contact_page.txt +21 -0
- apii-0.1.0/tests/eval/real/corpus/support_chat_bilingual.txt +16 -0
- apii-0.1.0/tests/eval/real/corpus/university_contact_gulf.txt +31 -0
- apii-0.1.0/tests/eval/real/corpus/university_directory_ksa_uae.txt +19 -0
- apii-0.1.0/tests/eval/real/corpus/zatca_tax_invoice.txt +20 -0
- apii-0.1.0/tests/eval/real/gold/arabic_news_bio.jsonl +4 -0
- apii-0.1.0/tests/eval/real/gold/charity_payment_instructions.jsonl +5 -0
- apii-0.1.0/tests/eval/real/gold/corporate_disclosure_sabic.jsonl +7 -0
- apii-0.1.0/tests/eval/real/gold/cr_extract_jarir.jsonl +4 -0
- apii-0.1.0/tests/eval/real/gold/english_news_bio.jsonl +6 -0
- apii-0.1.0/tests/eval/real/gold/government_directory_page.jsonl +12 -0
- apii-0.1.0/tests/eval/real/gold/iban_calculator_faq.jsonl +7 -0
- apii-0.1.0/tests/eval/real/gold/kyc_onboarding_form.jsonl +11 -0
- apii-0.1.0/tests/eval/real/gold/passport_specimen_icao.jsonl +1 -0
- apii-0.1.0/tests/eval/real/gold/payroll_wps_sheet.jsonl +8 -0
- apii-0.1.0/tests/eval/real/gold/press_contact_page.jsonl +9 -0
- apii-0.1.0/tests/eval/real/gold/support_chat_bilingual.jsonl +5 -0
- apii-0.1.0/tests/eval/real/gold/university_contact_gulf.jsonl +12 -0
- apii-0.1.0/tests/eval/real/gold/university_directory_ksa_uae.jsonl +7 -0
- apii-0.1.0/tests/eval/real/gold/zatca_tax_invoice.jsonl +4 -0
- apii-0.1.0/tests/eval/real/verify_gold.py +100 -0
- apii-0.1.0/tests/eval/real_bulk/README.md +62 -0
- apii-0.1.0/tests/eval/real_bulk/build_bulk_gold.py +245 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_address_gcc.txt +188 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_address_ksa.txt +138 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_cr_gcc.txt +92 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_email_gcc.txt +83 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_email_ksa.txt +80 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_ae.txt +31 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_bh.txt +13 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_kw.txt +32 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_om.txt +2 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_qa.txt +25 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_iban_sa.txt +42 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_national_id_vectors.txt +22 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_org_gcc.txt +110 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_org_ksa.txt +149 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_person_arabic.txt +92 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_person_en.txt +90 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_ae.txt +37 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_bh.txt +30 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_kw.txt +32 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_om.txt +33 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_qa.txt +32 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_phone_sa.txt +40 -0
- apii-0.1.0/tests/eval/real_bulk/corpus/bulk_tax_vat.txt +51 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_address_gcc.jsonl +60 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_address_ksa.jsonl +60 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_cr_gcc.jsonl +92 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_email_gcc.jsonl +83 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_email_ksa.jsonl +80 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_ae.jsonl +31 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_bh.jsonl +13 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_kw.jsonl +32 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_om.jsonl +2 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_qa.jsonl +25 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_iban_sa.jsonl +42 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_national_id_vectors.jsonl +22 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_org_gcc.jsonl +110 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_org_ksa.jsonl +149 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_person_arabic.jsonl +92 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_person_en.jsonl +90 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_ae.jsonl +37 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_bh.jsonl +30 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_kw.jsonl +32 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_om.jsonl +33 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_qa.jsonl +32 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_phone_sa.jsonl +40 -0
- apii-0.1.0/tests/eval/real_bulk/gold/bulk_tax_vat.jsonl +51 -0
- apii-0.1.0/tests/eval/real_bulk/sources.jsonl +1297 -0
- apii-0.1.0/tests/python/test_anonymizer.py +117 -0
- apii-0.1.0/tests/python/test_batch.py +88 -0
- apii-0.1.0/tests/python/test_case_augment.py +129 -0
- apii-0.1.0/tests/python/test_checksums.py +78 -0
- apii-0.1.0/tests/python/test_cli.py +85 -0
- apii-0.1.0/tests/python/test_context.py +80 -0
- apii-0.1.0/tests/python/test_csvcols.py +60 -0
- apii-0.1.0/tests/python/test_doc_csv.py +109 -0
- apii-0.1.0/tests/python/test_doc_docx.py +201 -0
- apii-0.1.0/tests/python/test_doc_html.py +146 -0
- apii-0.1.0/tests/python/test_doc_json.py +146 -0
- apii-0.1.0/tests/python/test_doc_pdf.py +106 -0
- apii-0.1.0/tests/python/test_doc_xlsx.py +273 -0
- apii-0.1.0/tests/python/test_documents_base.py +61 -0
- apii-0.1.0/tests/python/test_edge_cases.py +224 -0
- apii-0.1.0/tests/python/test_guard_leak_fuzzy.py +83 -0
- apii-0.1.0/tests/python/test_hook_daemon.py +106 -0
- apii-0.1.0/tests/python/test_iban.py +88 -0
- apii-0.1.0/tests/python/test_install.py +47 -0
- apii-0.1.0/tests/python/test_leak_hardening.py +71 -0
- apii-0.1.0/tests/python/test_ner.py +188 -0
- apii-0.1.0/tests/python/test_ner_pipeline.py +93 -0
- apii-0.1.0/tests/python/test_normalize.py +182 -0
- apii-0.1.0/tests/python/test_policy.py +73 -0
- apii-0.1.0/tests/python/test_real_bulk_corpus.py +79 -0
- apii-0.1.0/tests/python/test_real_corpus.py +58 -0
- apii-0.1.0/tests/python/test_recognizers.py +310 -0
- apii-0.1.0/tests/python/test_restore_on_write.py +54 -0
- apii-0.1.0/tests/python/test_server.py +84 -0
- apii-0.1.0/tests/python/test_smoke.py +27 -0
- apii-0.1.0/tests/python/test_streaming.py +80 -0
- apii-0.1.0/tests/python/test_structured.py +87 -0
- apii-0.1.0/tests/python/test_suppressor_geo.py +86 -0
- apii-0.1.0/tests/python/test_ui.py +33 -0
- apii-0.1.0/tests/python/test_watch.py +95 -0
apii-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
|
|
14
|
+
# Local secrets / config — never commit
|
|
15
|
+
.local/
|
|
16
|
+
*.env
|
|
17
|
+
.env
|
|
18
|
+
*.vault
|
|
19
|
+
|
|
20
|
+
# NER models (210 MB int8 ONNX; hosted externally, not in git)
|
|
21
|
+
models/
|
|
22
|
+
*.onnx
|
|
23
|
+
|
|
24
|
+
# OS
|
|
25
|
+
.DS_Store
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
apii-0.1.0/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aajil Labs
|
|
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.
|
apii-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apii
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Arabic/GCC PII detection, tokenization, and streaming-interception gateway.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Aajil-Labs/arabic-pii-py
|
|
6
|
+
Project-URL: Repository, https://github.com/Aajil-Labs/arabic-pii-py
|
|
7
|
+
Project-URL: NER models, https://huggingface.co/aajil-labs-sa/arabic-pii-ner
|
|
8
|
+
Author-email: Aajil Labs <omar@aajil.sa>
|
|
9
|
+
License: MIT OR Apache-2.0
|
|
10
|
+
License-File: LICENSE-APACHE
|
|
11
|
+
License-File: LICENSE-MIT
|
|
12
|
+
Keywords: anonymization,arabic,gcc,llm,ner,pii,privacy,redaction,tokenization
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Natural Language :: Arabic
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: msgspec>=0.18
|
|
29
|
+
Requires-Dist: regex>=2024.0
|
|
30
|
+
Provides-Extra: cli
|
|
31
|
+
Requires-Dist: cryptography>=42.0; extra == 'cli'
|
|
32
|
+
Requires-Dist: typer>=0.12; extra == 'cli'
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
35
|
+
Provides-Extra: documents
|
|
36
|
+
Requires-Dist: pypdf>=4.0; extra == 'documents'
|
|
37
|
+
Provides-Extra: ner
|
|
38
|
+
Requires-Dist: huggingface-hub>=0.20; extra == 'ner'
|
|
39
|
+
Requires-Dist: numpy>=1.24; extra == 'ner'
|
|
40
|
+
Requires-Dist: onnxruntime>=1.17; extra == 'ner'
|
|
41
|
+
Requires-Dist: tokenizers>=0.15; extra == 'ner'
|
|
42
|
+
Provides-Extra: perf
|
|
43
|
+
Requires-Dist: onnxruntime>=1.17; extra == 'perf'
|
|
44
|
+
Requires-Dist: pyahocorasick>=2.0; extra == 'perf'
|
|
45
|
+
Provides-Extra: proxy
|
|
46
|
+
Requires-Dist: fastapi>=0.110; extra == 'proxy'
|
|
47
|
+
Requires-Dist: httpx>=0.27; extra == 'proxy'
|
|
48
|
+
Requires-Dist: uvicorn[standard]>=0.29; extra == 'proxy'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# arabic-pii-py · `apii`
|
|
52
|
+
|
|
53
|
+
> **Keep Arabic & GCC personal data off the LLM — without changing how you work.**
|
|
54
|
+
> Names, IBANs, national IDs, phones, emails, addresses get swapped for
|
|
55
|
+
> reversible tokens **on your machine**, before anything reaches Claude / GPT.
|
|
56
|
+
> You keep seeing the real values. The model never does.
|
|
57
|
+
|
|
58
|
+
Everything runs **locally**. No cloud, no account, no data leaves your laptop
|
|
59
|
+
(the only network call is a one-time, optional model download you can replace).
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Why this exists
|
|
64
|
+
|
|
65
|
+
If you work with GCC customer data — banks, telcos, government, clinics — you
|
|
66
|
+
often legally **cannot** send that PII to a US-hosted LLM. `apii` lets you use
|
|
67
|
+
Claude / GPT on that data anyway: the personal data stays on your machine, the
|
|
68
|
+
model only ever sees placeholders like `EMAIL_C7E2…`, and the real values are
|
|
69
|
+
restored locally for *you*.
|
|
70
|
+
|
|
71
|
+
- 🇸🇦 **Built for Arabic & the GCC** — Saudi / Emirati / Qatari / Kuwaiti /
|
|
72
|
+
Bahraini / Omani shapes, IBAN ISO-7064 (MOD-97), national-ID checksums, and
|
|
73
|
+
on-device Arabic + English NER for names & organizations.
|
|
74
|
+
- 💻 **100% local** — no service to run, no API key required, nothing uploaded.
|
|
75
|
+
- 🪶 **Lightweight** — pure Python, **no PyTorch**; NER runs as int8 ONNX.
|
|
76
|
+
- 🔁 **Reversible & stable** — the same value always maps to the same token, and
|
|
77
|
+
only *your* secret can turn it back.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ⭐ The headline: transparent PII protection inside Claude Code
|
|
82
|
+
|
|
83
|
+
This is the part most tools can't do. With one command, `apii` wires two hooks
|
|
84
|
+
into Claude Code:
|
|
85
|
+
|
|
86
|
+
| | what happens | result |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| **redact-on-read** | when Claude reads a file, PII in it is tokenized *before the model sees it* | Claude only ever sees `EMAIL_…`, `IBAN_…`, `PERSON_…` |
|
|
89
|
+
| **restore-on-write** | when Claude writes/edits a file, the tokens are turned back into real values *before the bytes hit disk* | your **files come out correct**, the chat stays tokens |
|
|
90
|
+
| **`apii watch`** | a side pane restores Claude's tokenized replies locally | **you** read the real values; Anthropic still only got tokens |
|
|
91
|
+
|
|
92
|
+
It's **non-blocking** — you work normally; Claude just never receives the PII.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# in the project where you keep customer data:
|
|
96
|
+
apii install-claude-hook # one time — wires both hooks
|
|
97
|
+
|
|
98
|
+
# open a fresh Claude Code session there (it loads the hook at startup)
|
|
99
|
+
claude
|
|
100
|
+
|
|
101
|
+
# and, in another terminal pane IN THE SAME PROJECT FOLDER, watch real values:
|
|
102
|
+
apii watch # follows this folder's session; --once dumps it so far
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Now ask Claude to work on a file with PII. In the chat you'll see tokens; in the
|
|
106
|
+
`apii watch` pane you'll see the real data; and your customer's information never
|
|
107
|
+
left your machine.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Install (from source — it's yours, no PyPI needed)
|
|
112
|
+
|
|
113
|
+
Requires **Python 3.10+**.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/Aajil-Labs/arabic-pii-py.git
|
|
117
|
+
cd arabic-pii-py
|
|
118
|
+
|
|
119
|
+
python3 -m venv .venv && source .venv/bin/activate # a 3.10+ interpreter
|
|
120
|
+
pip install -e ".[ner,cli,proxy,documents]" # editable, all features
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
That gives you the `apii` command. To use it outside the venv, either keep the
|
|
124
|
+
venv active, or symlink it onto your `PATH`:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ln -sf "$PWD/.venv/bin/apii" ~/.local/bin/apii # if ~/.local/bin is on PATH
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**NER models** (names & organizations) auto-download once (~210 MB, int8 ONNX)
|
|
131
|
+
from Hugging Face and cache under `~/.cache/huggingface`. Without them, every
|
|
132
|
+
*structured* kind (email, phone, IBAN, ID, CR, VAT, address) still works — only
|
|
133
|
+
`PERSON` / `ORGANIZATION` need the models. Point at your own copy any time with
|
|
134
|
+
`APII_NER_MODEL` / `APII_NER_EN_MODEL`, or change the source repo with
|
|
135
|
+
`APII_NER_HF_REPO`.
|
|
136
|
+
|
|
137
|
+
Extras you can pick: `ner`, `cli`, `proxy` (streaming gateway), `documents`
|
|
138
|
+
(pdf/docx/xlsx). Core (`pip install -e .`) is just regex + checksums.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Ways to use it — pick what fits
|
|
143
|
+
|
|
144
|
+
### 1. Claude Code (above) — the transparent, zero-friction path.
|
|
145
|
+
|
|
146
|
+
### 2. CLI — text, files, and folders
|
|
147
|
+
```bash
|
|
148
|
+
# free text or a .txt file → tokens (mapping saved to a vault), then restore:
|
|
149
|
+
echo "call 0501234567, email omar@aajil.sa" | apii redact --vault demo.vault
|
|
150
|
+
apii restore answer.txt --vault demo.vault # the model's tokens → real values
|
|
151
|
+
|
|
152
|
+
apii detect notes.txt # audit only: detections as JSON
|
|
153
|
+
|
|
154
|
+
# whole folders, format-aware (csv / json / docx / xlsx / pdf→txt):
|
|
155
|
+
apii scan-dir ./statements --ext csv --out audit.jsonl
|
|
156
|
+
apii redact-dir ./statements --out-dir ./masked --ext csv --vault s.vault
|
|
157
|
+
```
|
|
158
|
+
> `apii redact <file>` reads the file as text. For **documents**
|
|
159
|
+
> (pdf/docx/xlsx/json) use `redact-dir` or the UI — they preserve layout.
|
|
160
|
+
|
|
161
|
+
### 3. Local UI — paste-in / paste-out (+ file upload)
|
|
162
|
+
```bash
|
|
163
|
+
apii ui # opens http://127.0.0.1:8765 — paste text or drop a CSV/Excel,
|
|
164
|
+
# take the tokens to any LLM, paste the reply back to restore.
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 4. As a library — embed it in your own app
|
|
168
|
+
```python
|
|
169
|
+
from apii.anonymizer import Anonymizer
|
|
170
|
+
|
|
171
|
+
a = Anonymizer(secret="your-secret", tenant="acme")
|
|
172
|
+
r = a.anonymize("Email omar@aajil.sa, IBAN SA0380000000608010167519")
|
|
173
|
+
send_to_llm(r.text) # the model sees only tokens
|
|
174
|
+
show_user(a.deanonymize(model_reply)) # real values restored locally
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 5. Drop-in proxy — protect an app you can't modify
|
|
178
|
+
```bash
|
|
179
|
+
pip install "apii[proxy]"
|
|
180
|
+
apii serve # local OpenAI-/Anthropic-compatible gateway on 127.0.0.1:8720
|
|
181
|
+
# point your client's base URL at it (e.g. ANTHROPIC_BASE_URL=http://127.0.0.1:8720);
|
|
182
|
+
# it anonymizes the request and de-anonymizes the streamed response, transparently.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## What it detects
|
|
188
|
+
|
|
189
|
+
| kind | how |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `EMAIL` | format |
|
|
192
|
+
| `PHONE` | GCC country codes, Saudi 05X, intl shapes |
|
|
193
|
+
| `IBAN` | ISO-7064 **MOD-97** checksum (all 6 GCC countries) |
|
|
194
|
+
| `TAX_NUMBER` | 15-digit Saudi / GCC VAT |
|
|
195
|
+
| `COMMERCIAL_REGISTRATION` | 10-digit CR, label-cued |
|
|
196
|
+
| `NATIONAL_ID` | UAE-784 / Saudi-Iqama / GCC |
|
|
197
|
+
| `PERSON` | **on-device NER** (no name lists, no regex) |
|
|
198
|
+
| `ORGANIZATION` | **on-device NER** |
|
|
199
|
+
| `ADDRESS` | PO-box / street regex + NER locations |
|
|
200
|
+
|
|
201
|
+
Quality is measured against a **1,340-span corpus of real, publicly-sourced
|
|
202
|
+
values** (`tests/eval/`) — `pytest tests/python -q` runs it.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Command reference
|
|
207
|
+
|
|
208
|
+
| command | what it does |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `apii redact [file]` | Anonymize text (stdin or a text file) → stdout; save the token↔value map to `--vault`. |
|
|
211
|
+
| `apii restore [file] --vault V` | Reverse it: tokens → real values, using the vault. |
|
|
212
|
+
| `apii detect [file]` | Audit mode — list detections as JSON, redact nothing. |
|
|
213
|
+
| `apii scan-dir DIR --out F` | Detect across a folder; write per-file JSONL summaries + totals. |
|
|
214
|
+
| `apii redact-dir DIR --out-dir D` | Redact every matching file (format-aware) into `--out-dir`, merging records into one `--vault`. |
|
|
215
|
+
| `apii ui` | Local paste-in / paste-out web UI + file upload (`127.0.0.1:8765`). |
|
|
216
|
+
| `apii serve` | Local anonymizing LLM proxy — `/v1/messages`, `/v1/chat/completions`, `/v1/responses` (needs `[proxy]`). |
|
|
217
|
+
| `apii watch` | Side-viewer: tail the **current folder's** Claude session, restoring tokens for *your* screen. `--once` dumps the session so far. |
|
|
218
|
+
| `apii install-claude-hook` | Wire redact-on-read + restore-on-write into Claude Code in one command (`--global` for all projects). |
|
|
219
|
+
| `apii hook` | The per-event hook itself (stdin event JSON → response JSON); used by the installed hooks. |
|
|
220
|
+
| `apii daemon` | Long-lived local hook daemon (`POST /hook`) — avoids a process spawn per event. |
|
|
221
|
+
| `apii hook-client` | Thin bridge that relays a hook event to a running `daemon`. |
|
|
222
|
+
|
|
223
|
+
Common flags: `--secret` (or `$APII_SECRET`), `--tenant`, `--vault`,
|
|
224
|
+
`--policy strict|balanced|audit`, `--no-ner`. Run `apii <cmd> --help` for the rest.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Environment variables
|
|
229
|
+
|
|
230
|
+
| var | purpose |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `APII_SECRET` | Vault HMAC / encryption key. Falls back to the managed `~/.apii/secret` (auto-created, `chmod 600`). |
|
|
233
|
+
| `APII_HOME` | Config + vault directory (default `~/.apii`). |
|
|
234
|
+
| `APII_POLICY` | Default policy: `strict` (default) / `balanced` / `audit`. |
|
|
235
|
+
| `APII_NER_CASE_AUG` | Lowercase-name recovery: `auto` (default — fires on fully-lowercase input) / `always` (mixed-case too) / `off`. |
|
|
236
|
+
| `APII_NER_THRESHOLD` | NER minimum confidence (default `0.85`). |
|
|
237
|
+
| `APII_NER_MODEL` / `APII_NER_EN_MODEL` | Use your own local Arabic / English ONNX model dirs (override the auto-download). |
|
|
238
|
+
| `APII_NER_HF_REPO` | Hugging Face repo to fetch models from (default `aajil-labs-sa/arabic-pii-ner`). |
|
|
239
|
+
| `APII_NER_NO_DOWNLOAD` | Set to disable the model auto-download (fully offline). |
|
|
240
|
+
| `APII_ANTHROPIC_BASE` / `APII_OPENAI_BASE` | Upstream targets for `apii serve`. |
|
|
241
|
+
| `APII_SUPPRESS_PHRASES` | Path to a phrase file of structural vocabulary to never tokenize. |
|
|
242
|
+
| `APII_GEO_GAZETTEER` | Path to an optional geo gazetteer for address detection. |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## How it stays private (the model)
|
|
247
|
+
|
|
248
|
+
Two separate boundaries — that's the whole trick:
|
|
249
|
+
|
|
250
|
+
- **Privacy boundary** = what the LLM receives → **only tokens**, always.
|
|
251
|
+
- **Display boundary** = what *you* see → real values, because it's your data on
|
|
252
|
+
your machine.
|
|
253
|
+
|
|
254
|
+
The bridge is a local, encrypted **vault** (`~/.apii/default.vault`, ChaCha20)
|
|
255
|
+
plus a secret (`~/.apii/secret`, `chmod 600`). Tokens are
|
|
256
|
+
`HMAC-SHA256(secret, value)` — deterministic, and irreversible without your
|
|
257
|
+
secret. Restoration is applied at the **last mile** (your screen, your files) and
|
|
258
|
+
**never re-enters the model's context**.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Make it your own
|
|
263
|
+
|
|
264
|
+
This is a normal, self-contained Python package — **it's yours to run, change,
|
|
265
|
+
and ship privately. You never have to publish it anywhere or run a server.**
|
|
266
|
+
|
|
267
|
+
- **Customize detection:** the recognizers live in `apii/recognizers/` — edit a
|
|
268
|
+
regex, tune a checksum, add a country shape.
|
|
269
|
+
- **Swap the NER models:** point `APII_NER_MODEL` / `APII_NER_EN_MODEL` at your
|
|
270
|
+
own ONNX models, or set `APII_NER_HF_REPO` to your own Hugging Face repo.
|
|
271
|
+
- **Change token formats, policy, vault location** (`APII_HOME`), tenants, etc.
|
|
272
|
+
- **Stay fully offline:** clone, `pip install -e .`, bring the NER models locally
|
|
273
|
+
— no cloud, no PyPI, no service, ever.
|
|
274
|
+
|
|
275
|
+
It's built to be forked and made internal. Keep it private; it's yours.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## NER models & credit
|
|
280
|
+
|
|
281
|
+
The bundled models are int8-ONNX redistributions of two open models — **please
|
|
282
|
+
keep crediting the original authors**:
|
|
283
|
+
|
|
284
|
+
- **Arabic** — [`hatmimoha/arabic-ner`](https://huggingface.co/hatmimoha/arabic-ner)
|
|
285
|
+
by Hatim Mohamed (on [`asafaya/bert-base-arabic`](https://huggingface.co/asafaya/bert-base-arabic) by Ali Safaya).
|
|
286
|
+
- **English** — [`dslim/bert-base-NER`](https://huggingface.co/dslim/bert-base-NER)
|
|
287
|
+
by David S. Lim (MIT, CoNLL-2003).
|
|
288
|
+
|
|
289
|
+
Hosted (quantized) at
|
|
290
|
+
[`aajil-labs-sa/arabic-pii-ner`](https://huggingface.co/aajil-labs-sa/arabic-pii-ner)
|
|
291
|
+
with full provenance + SHAs.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
**© Aajil Labs.** Dual-licensed — your choice of **MIT** *or* **Apache-2.0**
|
|
298
|
+
(see `LICENSE-MIT` and `LICENSE-APACHE`).
|
|
299
|
+
|
|
300
|
+
You may use, modify, and redistribute this software (including privately and
|
|
301
|
+
commercially) under either license. **You must keep the copyright and license
|
|
302
|
+
notices** in copies and substantial portions. The bundled NER models are
|
|
303
|
+
redistributed under their original authors' terms — credit them as above.
|
|
304
|
+
|
|
305
|
+
This is yours to build on — just respect the license.
|