Metadata-Version: 2.4
Name: faker-ph
Version: 0.1.0
Summary: Philippine-specific synthetic PII generator (PhilSys, TIN, SSS, PhilHealth, PSGC-backed addresses, origin-stratified names).
Project-URL: Homepage, https://github.com/danielquillanroxas/faker-ph
Project-URL: Repository, https://github.com/danielquillanroxas/faker-ph
Project-URL: Issues, https://github.com/danielquillanroxas/faker-ph/issues
Author-email: Daniel Roxas <danielquillanr@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for describing the origin of the Work and
              reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may accept support,
              warranty, indemnity, or other liability obligations and/or rights
              consistent with this License. However, in accepting such obligations,
              You may act only on Your own behalf and on Your sole responsibility,
              not on behalf of any other Contributor, and only if You agree to
              indemnify, defend, and hold each Contributor harmless for any
              liability incurred by, or claims asserted against, such Contributor
              by reason of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2026 Daniel Roxas
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
License-File: NOTICE
Keywords: anonymization,faker,filipino,nlp,philippines,pii,psgc,synthetic-data,tagalog
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.10
Requires-Dist: faker>=20.0
Requires-Dist: pandas>=2.0
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# faker-ph

**Philippine-specific synthetic PII generator.** Produces format-valid Philippine identifiers across every major government and financial issuer: PhilSys PSN/PCN (national ID), TIN (tax), SSS and GSIS (social security), UMID (unified multi-purpose ID), PhilHealth PIN (health insurance), PRC license (professional regulation), LTO driver's license, DFA passport, and Landbank/BPI/BDO account numbers. Also generates Globe/Smart/Sun/DITO mobile numbers, NCR and provincial landline formats, PSGC-backed addresses across 42,036 barangays, origin-stratified Filipino names (Spanish/Tagalog/Chinese/Anglo buckets), and Filipino-style dates. Includes a small pack of document templates (discharge summary, police blotter, affidavit) that render to text with character-offset gold PII spans for NLP evaluation.

See the [Acronym reference](#acronym-reference) section if these abbreviations are unfamiliar.

Licensed under **Apache-2.0**. Bundled reference data is redistributed from public upstream sources; see [`NOTICE`](NOTICE).

> **Status:** v0.1.0 (alpha). API surface is stable for the identifier generators; the template pack will grow (lab report, prescription, referral letter, and additional legal forms are on the roadmap).

---

## Install

```bash
pip install faker-ph
```

From source:

```bash
git clone https://github.com/danielquillanroxas/faker-ph
cd faker-ph
pip install -e ".[dev]"
```

## Quickstart

```python
from faker_ph import FakerPH

f = FakerPH(seed=42)

f.psn()             # '8894-1850-5612-7456'   (16-digit PhilSys Number)
f.tin()             # '123-456-789-000'        (TIN + branch code)
f.philhealth_pin()  # '12-345678901-2'
f.mobile()          # '0917 555 1234'
f.landline('2')     # '(02) 812 3456'
f.full_name(origin='spanish', sex='f')  # 'María Elena Santos-Lim'
f.filipino_date()   # 'Ika-12 ng Hunyo, 1998'
f.address()['full'] # 'Blk 12 Lot 7, Rizal St, Brgy. ..., ...'
```

All methods are deterministic when seeded. Default seed is `42`.

## Generating documents with gold PII spans

```python
from faker_ph import FakerPH, DISCHARGE_SUMMARY, render

f = FakerPH(seed=42)
text, spans = render(DISCHARGE_SUMMARY, f, doc_id="example_001")

print(text[:200])
for s in spans[:5]:
    print(f"  {s['type']:<16} {text[s['start']:s['end']]!r}")
```

Each span is a dict with `start`, `end`, `type`, and `value`. Character offsets are computed in the post-substitution text, not the template. Templates ship with narrative variants to prevent prompt-memorization when used as evaluation seeds.

See [`examples/generate_samples.py`](examples/generate_samples.py) for a deterministic script that outputs 20 rendered documents with gold spans to `examples/rendered_samples.jsonl` and `examples/gold_spans.jsonl`; both files are committed to the repo so you can inspect output without installing anything.

## Why Filipino PII is distinct

Off-the-shelf multilingual PII detectors (Presidio, GLiNER-Multi-PII, Azure PII) do not cover Filipino as a first-class language, and a straight translation of English tooling misses several Philippine-specific signals:

- **Code-switching (Taglish).** Identifiers frequently appear in English formatting (phone numbers, dates, account numbers) inside otherwise-Tagalog prose, and vice versa. PII recognizers trained on monolingual corpora mis-segment at language boundaries.
- **PSGC geographic hierarchy.** The Philippine Standard Geographic Code (maintained by the Philippine Statistics Authority, PSA) organizes PH addresses in a four-level structure: `region > province > city/municipality > barangay`. Barangay names alone (42,036 unique, often reused across provinces) are strong quasi-identifiers that generic `LOC` taggers flatten away.
- **Government identifier formats with non-trivial validation.**
  - **PhilSys PSN** (Philippine Identification System Number, issued by the Philippine Statistics Authority): 16 digits, displayed `NNNN-NNNN-NNNN-NNNN` per PSA Circular 2020-2004. This is the national ID.
  - **PhilSys PCN** (PhilSys Card Number): 12 digits printed on the physical national-ID card, distinct from the permanent PSN.
  - **TIN** (Taxpayer Identification Number, issued by the Bureau of Internal Revenue, BIR): 9-digit core + 3-digit branch code, `NNN-NNN-NNN-BBB`.
  - **SSS** (Social Security System, private-sector social insurance): 10 digits, `NN-NNNNNNN-N` where the last digit is an undocumented checksum.
  - **GSIS** (Government Service Insurance System, for government employees): 11 digits.
  - **UMID** (Unified Multi-Purpose ID, combines SSS/GSIS/PhilHealth/Pag-IBIG): 12-digit CRN `NNNN-NNNNNNN-N`.
  - **PhilHealth PIN** (Philippine Health Insurance Corporation, PH's universal health insurer): 12 digits, `NN-NNNNNNNNN-N`.
  - **PRC license** (Professional Regulation Commission, issues licenses for doctors, lawyers, engineers, architects): 7 digits.
  - **DFA passport** (Department of Foreign Affairs): 2 letters + 7 digits.
- **Origin-stratified names.** Spanish-origin surnames (Santos, Cruz, Dela Cruz, ~62% of population, a legacy of the 1849 Clavería decree that assigned surnames from a state catalog), native Tagalog surnames (Lakandula, Dimakulangan, Maganda, ~25%), Chinese-origin (Tan, Lim, Sy, ~8%, dating to pre-colonial trade and 19th-century immigration), Anglo-origin (Smith, Johnson, rare). Model fairness across these buckets is measurable and worth auditing.
- **Filipino-style dates.** `Ika-12 ng Hunyo, 1998` coexists with ISO `1998-06-12` and US `06/12/1998` in the same corpus; Tagalog month names (Enero, Pebrero, Marso, etc.) don't appear in any English date parser.
- **Honorifics fused with names.** Tagalog kinship honorifics (`Kuya`, `Ate`, `Lolo`, `Lola`, `Nanay`, `Tatay`) commonly precede names in social text; formal honorifics (`Bb.`, `Gng.`, `Dr.`, `Atty.`, `Engr.`) in legal/clinical text. Both fuse orthographically in ways generic tokenizers don't respect.

faker-ph encodes these distinctions at the generator level so that NLP evaluation corpora built on top of it reflect real Philippine linguistic and administrative reality.

## What's here / what's coming

**Shipping in v0.1.0:**

- `FakerPH` class with 25+ identifier generators, address/name/date/email methods, and a `patient_record()` convenience builder
- Bundled PSGC reference data (17 regions, 117 provinces, 1,648 municipalities/cities, 42,036 barangays)
- Mobile prefix + landline area code tables (all four carriers, all NCR PTE identifiers, 80+ provincial area codes)
- Origin-stratified Filipino name inventory (Spanish/Tagalog/Chinese/Anglo buckets + honorifics)
- `render()` utility that substitutes template slots and returns `(text, gold_spans)`
- Three starter templates: `DISCHARGE_SUMMARY`, `POLICE_BLOTTER`, `AFFIDAVIT_COMPLAINT`
- 20 deterministic example outputs in [`examples/`](examples/)

**Coming in later versions:**

- Additional clinical templates: prescription, referral letter, lab report, PhilHealth claim form
- Additional legal templates: contract NDA, notarial acknowledgment, court complaint
- Published checksum algorithms where reverse-engineered (currently format-only for SSS, PhilHealth)
- A trained PII detection model and an evaluation benchmark are **forthcoming in a separate companion release.** See [Citation](#citation).

## Acronym reference

Philippine government and financial institutions use many acronyms. This section spells out every abbreviation this library encodes, grouped by issuer.

**Identity and civil registry**
- **PhilSys** - Philippine Identification System (the national ID program)
- **PSN** - PhilSys Number (permanent 16-digit lifetime identifier)
- **PCN** - PhilSys Card Number (12 digits, printed on the physical ID card)
- **PSA** - Philippine Statistics Authority (issues PSN/PCN, maintains PSGC and civil registry)
- **PSGC** - Philippine Standard Geographic Code (region/province/city/barangay hierarchy)

**Tax and social insurance**
- **BIR** - Bureau of Internal Revenue (issues TINs)
- **TIN** - Taxpayer Identification Number
- **SSS** - Social Security System (private-sector contributors)
- **GSIS** - Government Service Insurance System (government-sector contributors)
- **UMID** - Unified Multi-Purpose ID (combines SSS/GSIS/PhilHealth/Pag-IBIG on one card)
- **PhilHealth** - Philippine Health Insurance Corporation (universal health coverage)
- **PIN** - Personal Identification Number (PhilHealth's member number)

**Professional and travel**
- **PRC** - Professional Regulation Commission (licenses doctors, lawyers, engineers, teachers, etc.)
- **LTO** - Land Transportation Office (issues driver's licenses)
- **DFA** - Department of Foreign Affairs (issues passports)

**Banking and telecom**
- **BDO** - Banco de Oro (largest PH private bank)
- **BPI** - Bank of the Philippine Islands (oldest PH bank, founded 1851)
- **Landbank** - Land Bank of the Philippines (state-owned bank)
- **NCR** - National Capital Region (Metro Manila, 16 cities + 1 municipality, area code 02)
- **PTE** - Public Telecommunications Entity (the telco operating a given number block: 3=Bayan, 5=Eastern, 6=ABS-CBN, 7=Globe, 8=PLDT for the NCR 8-digit format)

**Locations frequently appearing in the sample data**
- **Brgy.** - Barangay (smallest administrative unit in the Philippines, ~42,000 nationwide)
- **QC** - Quezon City (largest NCR city by population)
- **PNP** - Philippine National Police (referenced in the police-blotter template)
- **DOH** - Department of Health
- **BPO** - Business Process Outsourcing (the $30B PH call-center/back-office industry; relevant to PII workloads)

## Caveats

- **Not a validation oracle.** Do not use generated identifiers to validate real-world documents. Some format specifications are reconstructed from public form layouts and may not match current agency-issued formats exactly.
- **Not a complete name inventory.** The bundled name lists are for synthetic-generation use (~50 names per origin bucket). They are NOT suitable as ground truth for training a name-recognition model without substantial augmentation.
- **PSA data currency.** Bundled PSGC CSVs reflect PSA publications current as of 2023. Municipalities are renamed and barangays created/dissolved periodically; refresh from upstream (see [`NOTICE`](NOTICE)) for production use.

## Citation

```bibtex
@software{roxas2026fakerph,
  author = {Roxas, Daniel Quillan},
  title  = {faker-ph: Philippine-specific synthetic PII generator},
  year   = {2026},
  url    = {https://github.com/danielquillanroxas/faker-ph},
  version = {0.1.0}
}
```

A companion paper describing a broader Filipino PII evaluation framework is in preparation. This `CITATION` entry will be updated once published.

## Contributing

Issues and PRs welcome. Please run `pytest` and `ruff check .` locally before submitting. For large changes (new template categories, checksum algorithm contributions, additional name-origin buckets), open an issue first so we can coordinate scope.

## License

- **Code**: [Apache-2.0](LICENSE)
- **Bundled reference data**: redistributed from public upstreams under their original licenses. See [`NOTICE`](NOTICE).
