File size: 4,284 Bytes
2ea9ba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
140
141
#!/bin/bash

echo "πŸ§ͺ MALAYSIAN PRIORITY CLASSIFIER - INTERACTIVE TESTING"
echo "====================================================="
echo ""
echo "This script allows you to test the Malaysian Priority Classification Model"
echo "with various examples and your own custom text."
echo ""

# Make sure classify_text.sh is executable
chmod +x classify_text.sh

echo "πŸ“Š MODEL INFORMATION"
echo "==================="
echo "β€’ Categories: Government, Economic, Law, Danger"
echo "β€’ Accuracy: 91% on test dataset"
echo "β€’ Language: Bahasa Malaysia (with English support)"
echo "β€’ Training Data: 5,707 Malaysian social media posts"
echo ""

echo "🎯 PRE-DEFINED TEST EXAMPLES"
echo "============================"
echo ""

# Test examples array
declare -a examples=(
    "Perdana Menteri Malaysia mengumumkan dasar ekonomi baharu untuk tahun 2025"
    "Bank Negara Malaysia menaikkan kadar faedah asas sebanyak 0.25 peratus"
    "Mahkamah Tinggi memutuskan kes rasuah melibatkan bekas menteri"
    "Banjir besar melanda negeri Kelantan, ribuan penduduk dipindahkan"
    "Kementerian Kesihatan Malaysia melaporkan peningkatan kes COVID-19"
    "Bursa Malaysia mencatatkan kenaikan indeks KLCI sebanyak 1.2%"
    "Polis tangkap suspek dalam kes jenayah kolar putih"
    "Gempa bumi 6.2 skala Richter menggegar pantai timur Sabah"
    "Parlimen Malaysia meluluskan rang undang-undang baharu"
    "Kemalangan jalan raya di lebuh raya utara-selatan"
)

declare -a expected=(
    "Government"
    "Economic" 
    "Law"
    "Danger"
    "Danger"
    "Economic"
    "Law"
    "Danger"
    "Government"
    "Danger"
)

# Run predefined tests
for i in "${!examples[@]}"; do
    echo "Test $((i+1)): ${examples[i]}"
    echo "Expected: ${expected[i]}"
    echo -n "Result: "
    result=$(./classify_text.sh "${examples[i]}")
    echo "$result"
    
    if [ "$result" = "${expected[i]}" ]; then
        echo "βœ… CORRECT"
    else
        echo "❌ INCORRECT (Expected: ${expected[i]}, Got: $result)"
    fi
    echo ""
done

echo "πŸ“ˆ PERFORMANCE SUMMARY"
echo "====================="
echo "β€’ Government Keywords: 50+ terms"
echo "β€’ Economic Keywords: 80+ terms" 
echo "β€’ Law Keywords: 60+ terms"
echo "β€’ Danger Keywords: 70+ terms"
echo "β€’ Total Keywords: 260+ Malaysian-specific terms"
echo ""

echo "πŸ”§ INTERACTIVE TESTING MODE"
echo "==========================="
echo "Enter your own Malaysian text to classify (or 'quit' to exit):"
echo ""

while true; do
    echo -n "Enter text: "
    read -r user_input
    
    if [ "$user_input" = "quit" ] || [ "$user_input" = "exit" ] || [ "$user_input" = "q" ]; then
        echo "πŸ‘‹ Thank you for testing the Malaysian Priority Classifier!"
        break
    fi
    
    if [ -z "$user_input" ]; then
        echo "⚠️ Please enter some text to classify."
        continue
    fi
    
    echo -n "Classification: "
    result=$(./classify_text.sh "$user_input")
    echo "$result"
    
    # Show confidence explanation
    case $result in
        "Government")
            echo "πŸ“ This text contains government/political keywords"
            ;;
        "Economic")
            echo "πŸ’° This text contains economic/financial keywords"
            ;;
        "Law")
            echo "βš–οΈ This text contains legal/law enforcement keywords"
            ;;
        "Danger")
            echo "🚨 This text contains danger/emergency keywords"
            ;;
        *)
            echo "❓ Classification uncertain - may need more context"
            ;;
    esac
    echo ""
done

echo ""
echo "πŸ“š USAGE EXAMPLES FOR DEVELOPERS"
echo "================================"
echo ""
echo "# Basic usage"
echo "./classify_text.sh \"Your Malaysian text here\""
echo ""
echo "# Batch processing"
echo "cat input.txt | while read line; do"
echo "  echo \"\$line: \$(./classify_text.sh \"\$line\")\""
echo "done"
echo ""
echo "# Python integration"
echo "import subprocess"
echo "result = subprocess.run(['./classify_text.sh', text], capture_output=True, text=True)"
echo "category = result.stdout.strip()"
echo ""
echo "πŸ”— Model Repository: https://huggingface.co/rmtariq/malaysian-priority-classifier"
echo "πŸ“„ Documentation: See README.md for complete usage guide"
echo "⭐ Star this model if you find it useful!"