Skip to content

feat: detect sensitive text with privmask's DetectionPipeline - #43

Merged
snaka merged 2 commits into
mainfrom
feat/privmask-detection
Sep 27, 2026
Merged

snaka merged 2 commits into
mainfrom
feat/privmask-detection

Conversation

@snaka

@snaka snaka commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Replace the OCR text detectors (SensitiveDetectors + the broad Apple Intelligence prompt) with privmask's DetectionPipeline, pinned to 0.4.x.
  • OCR lines are joined into one text for the pipeline; JoinedLines maps each finding's UTF-16 range back to its line so the existing glyph-rect lookup still applies.
  • The on-device model is used for Japanese personal names only, and its findings are reconciled in the same pipeline (a model "name" wrapping a phone number is dropped). All candidates are masked regardless of confidence.
  • Debug overlay colours now come from each region's label instead of the detector, since one detector now yields both deterministic and model findings.
  • README gains a before/after sample of detection.

Why

NLTagger has no Japanese NER, so Japanese names were effectively never detected; the broad AI prompt produced false positives (port numbers and IPs as addresses). privmask measured 9/9 Japanese names on text input and filters implausible phone numbers (order numbers, timestamps).

Coverage changes

Test plan

  • swift test --package-path Packages/BokashiCore (39 tests, incl. new JoinedLinesTests)
  • Debug build; sample image via clipboard import → Detect masks names, phone, email, postal code/address, AWS secret and an English name, and leaves commit hash, version, port, IP, order number and timestamp alone (the README images are that run's export)

🤖 Generated with Claude Code

snaka and others added 2 commits September 28, 2026 07:16
NLTagger has no Japanese named-entity model, so Japanese personal names
were effectively never found, and the broad Apple Intelligence prompt
produced false positives such as port numbers read as addresses.

Run the OCR text through privmask instead: deterministic detectors for
phone numbers (with Japanese plausibility rules), emails, postal codes,
addresses, My Number and credentials, and the on-device model for
Japanese personal names only, verified against a surname list. Model
findings go through the same pipeline so its precedence rules drop a
name that wraps a phone number.

Usernames/handles and card numbers are no longer covered; tracked in
snaka/privmask#25 and #26.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@snaka
snaka merged commit 9a8a3f2 into main Sep 27, 2026
2 checks passed
@snaka
snaka deleted the feat/privmask-detection branch September 27, 2026 22:20
@snaka snaka mentioned this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant