Feat(#29): NB 모델 재학습 및 PII 마스킹 토큰 통일 - #30
Conversation
📝 WalkthroughWalkthroughThe change aligns Naive Bayes PII normalization with Spring-compatible bracketed tokens. It adds masking for RRN, card, account, phone, and email values, recognizes normalized phone markers, and validates score stability after masking. ChangesPII token alignment
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MessageInput
participant NaiveBayesNormalizer
participant PhoneFeatureExtractor
participant ScoreEvaluator
MessageInput->>NaiveBayesNormalizer: normalize PII values
NaiveBayesNormalizer->>PhoneFeatureExtractor: pass text containing [PHONE]
PhoneFeatureExtractor->>ScoreEvaluator: set structural phone feature
ScoreEvaluator-->>MessageInput: return analyzer score
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/analysis/text/naive_bayes_analyzer.py`:
- Around line 46-52: Reorder the masking calls in the normalizer at
app/analysis/text/naive_bayes_analyzer.py lines 46-52 and the corresponding
normalizer at data_science/SMSModel/train_sms.py lines 89-96 so _RE_EMAIL runs
before _RE_URL; leave the remaining substitutions unchanged to ensure email
addresses are fully masked before URL processing.
- Around line 20-23: Update the numeric PII regexes _RE_RRN, _RE_CARD,
_RE_PHONE, and _RE_ACCOUNT in app/analysis/text/naive_bayes_analyzer.py at lines
20-23 to use (?<!\d) and (?!\d) instead of digit boundaries, while preserving
their existing numeric patterns. Apply the same boundary changes to the
corresponding regexes in data_science/SMSModel/train_sms.py at lines 71-74 so
both normalizers handle values adjacent to Hangul consistently.
In `@tests/analysis/text/test_nb_masking_accuracy.py`:
- Around line 55-60: Ensure both analyze_text_with_naive_bayes results report
is_available before extracting risk_score in the accuracy test. Fail the test
immediately when either inference is unavailable, then retain the existing score
calculation and difference assertion for successful results.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 60adb9a1-ffc9-4de6-87b5-128f96d0dc67
⛔ Files ignored due to path filters (2)
data_science/SMSModel/phishing_model_artifact.pklis excluded by!**/*.pkldata_science/SMSModel/phishing_vectorizer.pklis excluded by!**/*.pkl
📒 Files selected for processing (5)
app/analysis/text/naive_bayes_analyzer.pydata_science/SMSModel/train_sms.pypytest.initests/analysis/text/test_naive_bayes_analyzer.pytests/analysis/text/test_nb_masking_accuracy.py
📝 개요
Spring PiiMaskingService 단일 마스킹 전환(#69) 이후 학습 데이터와 운영 입력 간 토큰 불일치 문제를 해결하기 위해 _normalize_text를 Spring 기준 토큰으로 통일하고 NB 모델을 재학습했습니다.
🔗 관련 이슈
Closes #29
🎯 주요 변경 사항
📸 사진
✅ PR 체크리스트
Summary by CodeRabbit
Bug Fixes
Tests