File size: 4,641 Bytes
aea087a
1a4e259
aea087a
1a4e259
 
 
aea087a
1a4e259
 
aea087a
1a4e259
 
 
aea087a
 
 
 
 
 
1a4e259
 
 
aea087a
 
 
 
 
 
 
1a4e259
 
 
aea087a
 
 
1a4e259
 
 
aea087a
1a4e259
aea087a
1a4e259
 
 
 
aea087a
1a4e259
 
 
 
aea087a
1a4e259
 
 
 
 
 
 
 
 
 
aea087a
1a4e259
 
 
aea087a
1a4e259
 
 
 
 
 
aea087a
1a4e259
 
 
 
 
 
 
 
 
aea087a
1a4e259
 
 
 
 
 
 
 
aea087a
1a4e259
 
 
aea087a
1a4e259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aea087a
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Usage Guide

Base URL: `https://cmeneses99-sms-classifier-api.hf.space`

---

## Via Browser (UI)

### Home
Open `https://cmeneses99-sms-classifier-api.hf.space` to see a description of the API with all available endpoints and response examples. From there you can navigate to any view using the buttons.

---

### Classify a single message
1. Click **"Clasificador Simple"** from the home (or navigate directly to `/classify`)
2. Type the message in the text field
3. Click **"Clasificar"** or press **Enter**
4. The result shows the detected category, confidence score and the top 3 most likely categories
5. If the same text was already classified before, a **"caché activo"** badge appears

---

### Classify multiple messages
1. Click **"Clasificador por Lotes"** from the home (or navigate directly to `/classify/batch`)
2. Type one message per line in the text area
3. A real-time counter shows how many messages you have loaded (max 50)
4. Click **"Clasificar todo"**
5. Results appear one by one with their category and confidence
6. The summary bar at the bottom shows how many results came from cache

---

### Browse available categories
1. Click **"Categorías"** from the home (or navigate directly to `/categories`)
2. Each category shows its description and an example in Spanish and English

---

## Via API (curl)

### Classify one message

```bash
curl -X POST https://cmeneses99-sms-classifier-api.hf.space/classify \
  -H "Content-Type: application/json" \
  -d '{"text": "Your OTP code is 482910. Do not share it."}'
```

```json
{
  "text": "Your OTP code is 482910. Do not share it.",
  "prediction": { "category": "otp_verification", "confidence": 0.9821 },
  "top_3": [
    { "category": "otp_verification", "confidence": 0.9821 },
    { "category": "security_alert",   "confidence": 0.0091 },
    { "category": "customer_service", "confidence": 0.0044 }
  ],
  "cached": false
}
```

**Limit:** max 512 characters per message.

---

### Classify multiple messages

```bash
curl -X POST https://cmeneses99-sms-classifier-api.hf.space/classify/batch \
  -H "Content-Type: application/json" \
  -d '{
    "texts": [
      "Your card was charged $45 at Amazon.",
      "Your package will arrive tomorrow between 2-4pm.",
      "Pay your bill today and avoid penalties."
    ]
  }'
```

```json
{
  "results": [
    { "text": "Your card was charged $45 at Amazon.", "prediction": { "category": "transaction", "confidence": 0.97 }, "top_3": [...], "cached": false },
    { "text": "Your package will arrive tomorrow...", "prediction": { "category": "delivery_logistics", "confidence": 0.95 }, "top_3": [...], "cached": false },
    { "text": "Pay your bill today...", "prediction": { "category": "billing_reminder", "confidence": 0.91 }, "top_3": [...], "cached": false }
  ],
  "total": 3,
  "from_cache": 0
}
```

**Limit:** max 50 messages per request.

---

### List categories

```bash
curl https://cmeneses99-sms-classifier-api.hf.space/api/categories
```

```json
["transaction", "otp_verification", "promotion_offer", "security_alert",
 "delivery_logistics", "appointment_reminder", "customer_service",
 "spam_advertising", "billing_reminder"]
```

---

### Health check

```bash
curl https://cmeneses99-sms-classifier-api.hf.space/health
```

```json
{
  "status": "ok",
  "model_loaded": true,
  "cache": { "hits": 12, "misses": 5, "hit_rate": 0.71, "size": 5 }
}
```

---

## Categories

| Category               | Examples                                                                          |
|------------------------|-----------------------------------------------------------------------------------|
| `transaction`          | "Your card was charged $45 at Amazon" / "Se debitó $45.000 en Falabella"         |
| `otp_verification`     | "Your OTP code is 482910" / "Tu código OTP es 482910"                            |
| `promotion_offer`      | "Exclusive offer just for you" / "30% de descuento este fin de semana"           |
| `security_alert`       | "Failed login attempt detected" / "Acceso no reconocido desde Berlín"            |
| `delivery_logistics`   | "Your package will arrive tomorrow" / "Tu pedido está en camino"                 |
| `appointment_reminder` | "Dental appointment confirmed" / "Recordatorio: cita médica mañana a las 10am"  |
| `customer_service`     | "Your case has been escalated" / "Tu ticket #4821 fue resuelto"                  |
| `spam_advertising`     | "You have been selected for a reward" / "Ganaste un premio, haz clic aquí"       |
| `billing_reminder`     | "Pay your bill today and avoid penalties" / "Tu factura vence el 15 de mayo"     |