darwinkernelpanic commited on
Commit
70a8440
Β·
verified Β·
1 Parent(s): 85c76fb

Upload moderat_speed_test.ipynb with huggingface_hub

Browse files
Files changed (1) hide show
  1. moderat_speed_test.ipynb +6 -6
moderat_speed_test.ipynb CHANGED
@@ -96,7 +96,7 @@
96
  "metadata": {},
97
  "outputs": [],
98
  "source": [
99
- "# @title 4. PII Detector Class (FIXED)\n",
100
  "class PIIDetector:\n",
101
  " \"\"\"Detect PII with proper age-based social media rules\"\"\"\n",
102
  " \n",
@@ -223,7 +223,7 @@
223
  "metadata": {},
224
  "outputs": [],
225
  "source": [
226
- "# @title 6. PII Detection Tests (FIXED)\n",
227
  "print(\"πŸ”’ PII Detection Results (Fixed)\\n\")\n",
228
  "print(\"Expected: Address and Credit Card now detected correctly\")\n",
229
  "print(\"Expected: Social media ALLOWED for 13+ (unless grooming)\\n\")\n",
@@ -257,7 +257,7 @@
257
  "metadata": {},
258
  "outputs": [],
259
  "source": [
260
- "# @title 7. Speed Test - Single Inference\n",
261
  "test_text = \"damn that's crazy\"\n",
262
  "\n",
263
  "# Warm up\n",
@@ -285,7 +285,7 @@
285
  "metadata": {},
286
  "outputs": [],
287
  "source": [
288
- "# @title 8. Dual-Mode Content Test\n",
289
  "test_cases = [\n",
290
  " (\"that was a great game\", 10),\n",
291
  " (\"that was a great game\", 15),\n",
@@ -312,7 +312,7 @@
312
  "metadata": {},
313
  "outputs": [],
314
  "source": [
315
- "# @title 9. Batch Processing Speed Test\n",
316
  "batch_texts = [\n",
317
  " \"that was a great game\",\n",
318
  " \"shit that sucks\",\n",
@@ -348,7 +348,7 @@
348
  "metadata": {},
349
  "outputs": [],
350
  "source": [
351
- "# @title 10. Summary\n",
352
  "print(\"πŸ“Š moderat Summary\")\n",
353
  "print(\"=\"*60)\n",
354
  "print(\"\")\n",
 
96
  "metadata": {},
97
  "outputs": [],
98
  "source": [
99
+ "# @title 4. Unicode Deobfuscator\n", "class UnicodeDeobfuscator:\n", " CIRCLED_MAP = {\n", " 'ⓐ': 'a', 'β“‘': 'b', 'β“’': 'c', 'β““': 'd', 'β“”': 'e',\n", " 'β“•': 'f', 'β“–': 'g', 'β“—': 'h', 'β“˜': 'i', 'β“™': 'j',\n", " 'β“š': 'k', 'β“›': 'l', 'β“œ': 'm', 'ⓝ': 'n', 'β“ž': 'o',\n", " 'β“Ÿ': 'p', 'β“ ': 'q', 'β“‘': 'r', 'β“’': 's', 'β“£': 't',\n", " 'β“€': 'u', 'β“₯': 'v', 'ⓦ': 'w', 'β“§': 'x', 'ⓨ': 'y', 'β“©': 'z',\n", " 'β’Ά': 'A', 'β’·': 'B', 'β’Έ': 'C', 'β’Ή': 'D', 'β’Ί': 'E',\n", " 'β’»': 'F', 'β’Ό': 'G', 'β’½': 'H', 'β’Ύ': 'I', 'β’Ώ': 'J',\n", " 'β“€': 'K', 'Ⓛ': 'L', 'β“‚': 'M', 'Ⓝ': 'N', 'β“„': 'O',\n", " 'β“…': 'P', 'Ⓠ': 'Q', 'Ⓡ': 'R', 'β“ˆ': 'S', 'Ⓣ': 'T',\n", " 'β“Š': 'U', 'β“‹': 'V', 'β“Œ': 'W', 'Ⓧ': 'X', 'β“Ž': 'Y', 'Ⓩ': 'Z',\n", " }\n", " \n", " @classmethod\n", " def detect(cls, text):\n", " suspicious = []\n", " normalized = []\n", " for char in text:\n", " if char in cls.CIRCLED_MAP:\n", " suspicious.append((char, 'circled'))\n", " normalized.append(cls.CIRCLED_MAP[char])\n", " else:\n", " normalized.append(char)\n", " return len(suspicious) > 0, suspicious, ''.join(normalized)\n", "\n", "# @title 5. PII Detector Class (FIXED)\n",
100
  "class PIIDetector:\n",
101
  " \"\"\"Detect PII with proper age-based social media rules\"\"\"\n",
102
  " \n",
 
223
  "metadata": {},
224
  "outputs": [],
225
  "source": [
226
+ "# @title 6. Unicode Deobfuscation Tests\n", "print(\"πŸ”€ Unicode Deobfuscation Tests\\n\")\n", "\n", "unicode_tests = [\n", " (\"have you tried like β“•/ β„‚k\", 15),\n", " (\"you're a β“Ÿβ“˜β“”β“’β“” of β“’β“—β“˜β“£\", 15),\n", " (\"β“šβ“˜β“›β“› yourself\", 15),\n", "]\n", "\n", "for text, age in unicode_tests:\n", " is_obf, chars, norm = UnicodeDeobfuscator.detect(text)\n", " result = check_content(text, age)\n", " status = \"βœ…\" if result['allowed'] else \"❌\"\n", " print(f\"{status} Original: {text}\")\n", " print(f\" Normalized: {norm}\")\n", " print(f\" β†’ {result['reason']}\")\n", " print()\n", "\n", "# @title 7. PII Detection Tests (FIXED)\n",
227
  "print(\"πŸ”’ PII Detection Results (Fixed)\\n\")\n",
228
  "print(\"Expected: Address and Credit Card now detected correctly\")\n",
229
  "print(\"Expected: Social media ALLOWED for 13+ (unless grooming)\\n\")\n",
 
257
  "metadata": {},
258
  "outputs": [],
259
  "source": [
260
+ "# @title 8. Speed Test - Single Inference\n",
261
  "test_text = \"damn that's crazy\"\n",
262
  "\n",
263
  "# Warm up\n",
 
285
  "metadata": {},
286
  "outputs": [],
287
  "source": [
288
+ "# @title 9. Dual-Mode Content Test\n",
289
  "test_cases = [\n",
290
  " (\"that was a great game\", 10),\n",
291
  " (\"that was a great game\", 15),\n",
 
312
  "metadata": {},
313
  "outputs": [],
314
  "source": [
315
+ "# @title 10. Batch Processing Speed Test\n",
316
  "batch_texts = [\n",
317
  " \"that was a great game\",\n",
318
  " \"shit that sucks\",\n",
 
348
  "metadata": {},
349
  "outputs": [],
350
  "source": [
351
+ "# @title 11. Summary\n",
352
  "print(\"πŸ“Š moderat Summary\")\n",
353
  "print(\"=\"*60)\n",
354
  "print(\"\")\n",