-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-sentiment-app.sh
More file actions
executable file
·67 lines (56 loc) · 1.67 KB
/
Copy pathtest-sentiment-app.sh
File metadata and controls
executable file
·67 lines (56 loc) · 1.67 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
#!/bin/bash
POSITIVE_TEXTS=(
"I absolutely love this product!"
"Amazing experience, highly recommend."
"Works like a charm, I'm very satisfied."
"Exceptional quality and great value."
"This exceeded all my expectations!"
)
NEGATIVE_TEXTS=(
"I absolutely hate this product."
"Terrible experience, not recommended."
"Broke on the first day, waste of money."
"Very disappointed with the quality."
"It doesn't work as advertised."
)
NEUTRAL_TEXTS=(
"It’s okay, nothing special."
"Just average, works as expected."
"Not bad, not great either."
"Meh, I’ve seen better."
"Does the job, no complaints."
)
NUM_POS=${1:-50}
NUM_NEG=${2:-50}
NUM_NEU=${3:-20}
URL="http://localhost:8080/api/v1/sentiment"
send_random_text() {
local array_name=$1[@]
local texts=("${!array_name}")
local text="${texts[RANDOM % ${#texts[@]}]}"
curl -s -X POST $URL \
-H "Content-Type: application/json" \
-d "{\"text\":\"$text\"}" >> sentiment_log.txt
echo "" >> sentiment_log.txt
sleep 0.5
}
for ((i=0; i<NUM_POS; i++)); do
send_random_text POSITIVE_TEXTS
done
for ((i=0; i<NUM_NEG; i++)); do
send_random_text NEGATIVE_TEXTS
done
for ((i=0; i<NUM_NEU; i++)); do
send_random_text NEUTRAL_TEXTS
done
curl -s -X POST "$URL/batch" \
-H "Content-Type: application/json" \
-d '{"texts":[
"I love this product! It works perfectly.",
"This is terrible, it broke after one day.",
"It is okay, nothing special but gets the job done.",
"Best purchase ever! Highly recommended!",
"Disappointed with the quality, not worth the money."
]}' >> sentiment_log.txt
echo "" >> sentiment_log.txt
echo "Simulation completed. Check sentiment_log.txt for results"