Python3 Interactive Client
From Textserver wiki
1 #!/usr/bin/env python3
2
3 import requests
4
5 # set query elements
6 text = input('Text to analyze: ')
7 lang = input('Language: ')
8 out = input('Output format (xml,json,conll,naf): ')
9 user = input('TextServer Username: ')
10 pwd = input('TextServer Password: ')
11
12 # Create request
13 request_data = {'username':user,
14 'password':pwd,
15 'text_input':text,
16 'language':lang,
17 'output':out,
18 'interactive':'1' }
19
20 # service URL
21 service = "SERVICENAME"
22 url = "http://frodo.lsi.upc.edu:8080/TextWS/textservlet/ws/processQuery/"+service
23
24 # Send request and get response
25 resp = requests.post(url, files=request_data)
26
27 # HTTP error, raise exception
28 if resp.status_code != requests.codes.ok :
29 resp.raise_for_status()
30
31 # No error, appropriately process response
32 # (e.g. parsing XML or JSON, and doing clever stuff with the content)
33 print(resp.text)