Download example.py from CobuildX-AI/cbx-indic-pii-extractor-17M: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/CobuildX-AI/cbx-indic-pii-extractor-17M/resolve/main/example.py
- Command line
-
hf download hf://CobuildX-AI/cbx-indic-pii-extractor-17M/example.py
-
curl -L -o example.py https://huggingface.co/CobuildX-AI/cbx-indic-pii-extractor-17M/resolve/main/example.py
1.24 kB
| """Check the install: find and redact PII in four sample texts (Hindi, romanised Hindi, Tamil, Bengali; all values | |
| are invented). | |
| python example.py | |
| """ | |
| from pii import PIIExtractor | |
| SAMPLES = [ | |
| "नमस्ते, मेरा नाम अनीता कुलकर्णी है। मेरा मोबाइल नंबर 98204 51763 है और ईमेल anita.k@example.in है।", | |
| "Sir, mera PAN BXQPK4821M hai aur account number 50100234567812, IFSC HDFC0004521. Kripya update kar dijiye.", | |
| "என் பெயர் முருகன் செல்வம். என் ஆதார் எண் 4521 8890 2316, முகவரி 14, காந்தி தெரு, மதுரை 625001.", | |
| "আমার UPI আইডি rakesh.das@okaxis, গাড়ির নম্বর WB 02 AK 4417। অর্ডার নম্বর ORD-55231 এখনও আসেনি।", | |
| ] | |
| pii = PIIExtractor() | |
| print(f"model loaded on {pii.device}\n") | |
| for text in SAMPLES: | |
| spans, ms = pii.timed_extract(text) | |
| print(text) | |
| for s in spans: | |
| print(f" {s['label']:15} {s['text']!r} [{s['start']}:{s['end']}]") | |
| print(f" redacted: {pii.redact(text)}") | |
| print(f" ({ms:.0f} ms)\n") | |