Auto-commit 2026-05-02 09:37

This commit is contained in:
2026-05-02 09:37:30 -04:00
parent b6b0f86d73
commit fe754761d9
15 changed files with 674 additions and 14 deletions

View File

@@ -1,4 +1,12 @@
import { SpamShieldService } from '../services/spamshield.service';
import {
HIGH_RISK_LINK_SCORE,
SHORT_AGGRESSIVE_SCORE,
EXCESSIVE_NUMBERS_SCORE,
URGENT_NEGATIVE_SCORE,
REPUTATION_SCORE_WEIGHT,
SMS_SPAM_THRESHOLD,
} from '../constants/sms-classifier.constants';
export interface SmsClassificationResult {
isSpam: boolean;
@@ -58,31 +66,31 @@ export class BertSmsClassifier implements SmsClassifier {
// High-risk patterns
if (hasLinks && length > 100) {
spamScore += 0.3;
spamScore += HIGH_RISK_LINK_SCORE;
}
// Short aggressive messages
if (length < 20 && hasNumbers) {
spamScore += 0.2;
spamScore += SHORT_AGGRESSIVE_SCORE;
}
// Excessive numbers
if (/\d{3,}/.test(text)) {
spamScore += 0.15;
spamScore += EXCESSIVE_NUMBERS_SCORE;
}
// Negative/urgent language
if (sentiment === 'negative' && language === 'unknown') {
spamScore += 0.2;
spamScore += URGENT_NEGATIVE_SCORE;
}
// Combine with reputation score if available
const reputation = await this.spamShield.checkReputation('placeholder');
if (reputation.isSpam) {
spamScore += 0.25;
spamScore += REPUTATION_SCORE_WEIGHT;
}
const isSpam = spamScore > 0.5;
const isSpam = spamScore > SMS_SPAM_THRESHOLD;
// Update metrics
this.metrics.totalClassified++;