Skip to main content

privyscope-ja

Japanese language pack for privyscope, a two-stage hybrid PII detection & masking engine.

This is a thin plugin: it ships only the Japanese data (regex_rules.yaml, entity_config.yaml) and registers itself with the privyscope core via the privyscope.languages entry point. The engine and the privyscope command live in the core, which is pulled in automatically.

Japanese mixes three scripts — kanji (漢字), hiragana (ひらがな) and katakana (カタカナ) — with no inter-word spaces, so the pack advertises all three scripts and leaves personal-name detection to the NER stage rather than regex.

Install

pip install privyscope-ja      # pulls in the `privyscope` core automatically

Quickstart

privyscope redact "田中さんの電話は090-1234-5678、メールは taro@example.co.jp"
# → "<PER>さんの電話は<PHONE>、メールは <EMAIL>"
from privyscope import Privyscope
eng = Privyscope.from_pretrained(lang="ja")
eng.redact("田中さんの電話は090-1234-5678").masked_text   # "<PER>さんの電話は<PHONE>"

How it works

A two-stage hybrid pipeline, results merged via union:

  1. Regex filter — structurally obvious PII: Japanese mobile (0[789]0-xxxx-xxxx, +81), landlines, My Number (個人番号, 12-digit with check digit), passport, driver's license, Corporate Number (法人番号), Japanese bank accounts, email, and credential secrets.
  2. ONNX NER — a BIOES token classifier with a constrained Viterbi decoder for contextual PII (names, addresses, private dates). Weights download from Hugging Face Hub (zafrem/privyscope-ja) on first use.

Inference is ONNX Runtime only — no PyTorch at runtime. The base encoder tokenizes with MeCab, but that dependency is needed only for training/fine-tuning.

Entities

8 base types — PER, PHONE, ID_NUM, EMAIL, LOC, BANK, DATE, SECRET — plus extended BIZ_NUM (Corporate Number 法人番号) and DRIVER_LICENSE, caught by regex.

Model & performance

  • Base encodertohoku-nlp/bert-base-japanese-v3 → BIOES head → Viterbi decoder.
  • Runtime artifact — INT8-quantized ONNX, max sequence length 256, downloaded from the Hub with a SHA-256 checksum.txt for integrity.
  • Accuracy — run privyscope eval --lang ja your_val.jsonl on your own labelled data; numbers will be published here once the held-out evaluation is finalized.

Limitations

  • Not an anonymization/compliance guarantee; use as one layer of privacy-by-design, with human review for sensitive workflows.
  • Personal names are contextual (NER only): recall depends on the fine-tuned model, which is trained across kanji/hiragana/katakana renderings.

License

Apache-2.0. See LICENSE.

Stage-1 regex patterns are compiled from the pii-pattern-engine ruleset. Most rules carry a verification function — a checksum or dictionary validator (jp_my_number_valid, luhn) that a match must pass before it is redacted, so a value that merely looks like an ID is left alone.

Regex-only extended entities: BIZ_NUM · DRIVER_LICENSE · CRYPTO · IP · DEVICE · URL.

privyscope_ja/regex_rules.yaml is generated by scripts/gen_regex_rules.py and is overwritten on every build — edit the mapping in that script, not the YAML. See CONTRIBUTING.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privyscope_ja-0.1.4.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

privyscope_ja-0.1.4-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file privyscope_ja-0.1.4.tar.gz.

File metadata

  • Download URL: privyscope_ja-0.1.4.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for privyscope_ja-0.1.4.tar.gz
Algorithm Hash digest
SHA256 092d9ae5c803a3ac9ebc7a585e444f8ed0526e376c0127598137239fabbee18d
MD5 1590e1b4264d32506cfc081d39267207
BLAKE2b-256 2ec1b7b5486baf502baa1ac909cb15c466679daafba6e00fef65e9591c85d23f

See more details on using hashes here.

File details

Details for the file privyscope_ja-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: privyscope_ja-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for privyscope_ja-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a3e257138c98479a723844c6d453852cd4378f54a8231f4a56e180cf8c540cd7
MD5 389d604b1a4eda089dc4d600103882f0
BLAKE2b-256 e9b7dec0fdc407f4aa2ac14ff213bc6be9b73f3cc1b66b8c4ff460c955e1e11f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5

2 files

This release

0.1.4 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page