-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_sentiment_classification.py
More file actions
40 lines (33 loc) · 1 KB
/
max_sentiment_classification.py
File metadata and controls
40 lines (33 loc) · 1 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
import requests as rq
import urllib
import json
from pythonosc import udp_client
url = 'http://text-processing.com/api/sentiment/'
print("Welcome to sound narrator")
print("Please write a sentece and press enter")
print("The sentece will be kept secure. No worries ")
print("type 'exit' in order to go out")
print("_._._._._._._._._._._._._._._._._._._._._._._._._._._._")
while True:
text_input = input()
if text_input == "exit":
break
params={
'text':text_input,
}
response = rq.post(url, data= params)
# data = response.json()
data = json.loads(response.text)
k = data["probability"]
label = data["label"]
result = k.get(label)
value = list(k.values())
# print(result)
# print("({})".format(label))
# print (value)
# ip, port = '192.168.43.179' , 5000
ip, port = '127.0.0.1' , 5000
client = udp_client.SimpleUDPClient(ip, port)
msg = value
client.send_message("/message",msg)
# print ('sent {} to {}'.format(msg,ip))