Python3 Interactive Client
From Textserver wiki
1 #!/usr/bin/env python3
2
3 import requests
4
5 # set query elements
6 text = raw_input('Text to analyze: ')
7 lang = raw_input('Language: ')
8 out = raw_input('Output format (xml,json,conll,naf): ')
9 user = raw_input('TextServer Username: ')
10 pwd = raw_input('TextServer Password: ')
11
12 # Create request
13 request_data = {'username':user
14 'password':pwd,
15 'text_input':text,
16 'language':lang,
17 'output':'xml',
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)