princemaxp commited on
Commit
b19ae36
·
verified ·
1 Parent(s): fe5f164

Update body_analyzer.py

Browse files
Files changed (1) hide show
  1. body_analyzer.py +4 -5
body_analyzer.py CHANGED
@@ -2,6 +2,7 @@ import requests
2
  import os
3
  import re
4
 
 
5
  HF_API_KEY = os.getenv("HF_API_KEY")
6
  HF_HEADERS = {"Authorization": f"Bearer {HF_API_KEY}"} if HF_API_KEY else {}
7
 
@@ -11,7 +12,7 @@ MODELS = {
11
  "spam": "mrm8488/bert-tiny-finetuned-sms-spam-detection",
12
  }
13
 
14
- # Base suspicious patterns
15
  SUSPICIOUS_PATTERNS = [
16
  r"verify your account",
17
  r"urgent action",
@@ -27,10 +28,6 @@ SUSPICIOUS_PATTERNS = [
27
  r"account (suspended|deactivated|locked)",
28
  r"update your (information|details|billing)",
29
  r"legal action",
30
- ]
31
-
32
- # Extended spammy / phishing keywords
33
- SUSPICIOUS_PATTERNS += [
34
  r"free trial",
35
  r"limited time offer",
36
  r"click below",
@@ -44,6 +41,7 @@ SUSPICIOUS_PATTERNS += [
44
  r"risk-free",
45
  ]
46
 
 
47
  def query_hf(model, text):
48
  if not HF_API_KEY:
49
  return None
@@ -57,6 +55,7 @@ def query_hf(model, text):
57
  except Exception:
58
  return None
59
 
 
60
  def analyze_body(text):
61
  findings = []
62
  score = 0
 
2
  import os
3
  import re
4
 
5
+ # --- HuggingFace API setup ---
6
  HF_API_KEY = os.getenv("HF_API_KEY")
7
  HF_HEADERS = {"Authorization": f"Bearer {HF_API_KEY}"} if HF_API_KEY else {}
8
 
 
12
  "spam": "mrm8488/bert-tiny-finetuned-sms-spam-detection",
13
  }
14
 
15
+ # --- Suspicious keyword patterns ---
16
  SUSPICIOUS_PATTERNS = [
17
  r"verify your account",
18
  r"urgent action",
 
28
  r"account (suspended|deactivated|locked)",
29
  r"update your (information|details|billing)",
30
  r"legal action",
 
 
 
 
31
  r"free trial",
32
  r"limited time offer",
33
  r"click below",
 
41
  r"risk-free",
42
  ]
43
 
44
+ # --- Helper: query HuggingFace model ---
45
  def query_hf(model, text):
46
  if not HF_API_KEY:
47
  return None
 
55
  except Exception:
56
  return None
57
 
58
+ # --- Main body analyzer ---
59
  def analyze_body(text):
60
  findings = []
61
  score = 0