-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·94 lines (83 loc) · 3.96 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·94 lines (83 loc) · 3.96 KB
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
#!/bin/bash -e
# Build the images: ./build-docker-images.sh
# Run them: docker compose up
# Now run this script: ./tests.sh
assert_contains() {
local response="$1"
local expected="$2"
local label="$3"
if echo "$response" | grep -q "$expected"; then
echo "PASS: $label"
else
echo "FAIL: $label — expected '$expected' in response: $response"
exit 1
fi
}
echo "Testing pii_en_small (port 8006)..."
RESPONSE=$(curl -s -X POST http://localhost:8006/find \
-H "Content-Type: application/json" \
-d '{"text": "George Washington was president and he lived in Virginia.", "labels": ["name"], "threshold": 0.9}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "George Washington" "pii_en_small: name detected"
assert_contains "$RESPONSE" '"label": "name"' "pii_en_small: uses the 'name' label"
echo
echo "Testing pii_en_xsmall (port 8007)..."
RESPONSE=$(curl -s -X POST http://localhost:8007/find \
-H "Content-Type: application/json" \
-d '{"text": "George Washington was president and he lived in Virginia.", "labels": ["name"], "threshold": 0.5}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "George Washington" "pii_en_xsmall: name detected"
echo
echo "Testing pii_en_medium (port 8008)..."
RESPONSE=$(curl -s -X POST http://localhost:8008/find \
-H "Content-Type: application/json" \
-d '{"text": "George Washington was president and he lived in Virginia.", "labels": ["name"], "threshold": 0.7}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "George Washington" "pii_en_medium: name detected"
echo
echo "Testing pii_en_large (port 8009)..."
RESPONSE=$(curl -s -X POST http://localhost:8009/find \
-H "Content-Type: application/json" \
-d '{"text": "George Washington was president and he lived in Virginia.", "labels": ["name"], "threshold": 0.95}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "George Washington" "pii_en_large: name detected"
echo
echo "Testing pii_base (port 8001)..."
RESPONSE=$(curl -s -X POST http://localhost:8001/find \
-H "Content-Type: application/json" \
-d '{"text": "George Washington was president and he lived in Virginia.", "labels": ["Person", "Place"], "threshold": 0.5}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "George Washington" "pii_base: person detected"
assert_contains "$RESPONSE" "Virginia" "pii_base: place detected"
echo
echo "Testing hospitals (port 8002)..."
RESPONSE=$(curl -s -X POST http://localhost:8002/find \
-H "Content-Type: application/json" \
-d '{"text": "The patient was admitted to St. Marys Hospital and assigned to room 204.", "labels": ["hospital", "room number"], "threshold": 0.0}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "hospital" "hospitals: hospital label present"
assert_contains "$RESPONSE" "room" "hospitals: room number label present"
echo
echo "Testing medical_conditions (port 8003)..."
RESPONSE=$(curl -s -X POST http://localhost:8003/find \
-H "Content-Type: application/json" \
-d '{"text": "The patient was diagnosed with diabetes and hypertension.", "labels": ["DISEASE_DISORDER"], "threshold": 0.0}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "diabetes" "medical_conditions: diabetes detected"
assert_contains "$RESPONSE" "hypertension" "medical_conditions: hypertension detected"
echo
echo "Testing french_persons (port 8004)..."
RESPONSE=$(curl -s -X POST http://localhost:8004/find \
-H "Content-Type: application/json" \
-d '{"text": "Jean Dupont est arrivé à Paris hier soir.", "labels": ["person"], "threshold": 0.0}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "Jean Dupont" "french_persons: person detected"
echo
echo "Testing french_medical (port 8005)..."
RESPONSE=$(curl -s -X POST http://localhost:8005/find \
-H "Content-Type: application/json" \
-d '{"text": "Le patient souffre de diabète et d'\''hypertension artérielle.", "labels": ["Maladie"], "threshold": 0.3}')
echo "$RESPONSE"
assert_contains "$RESPONSE" "diab" "french_medical: diabète detected"
assert_contains "$RESPONSE" "hypertension" "french_medical: hypertension detected"
echo