File size: 647 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# python port of client.perl

import xmlrpclib
import datetime

url = "http://localhost:8080/RPC2"
proxy = xmlrpclib.ServerProxy(url)

text = u"il a souhaité que la présidence trace à nice le chemin pour l' avenir ."
params = {"text":text, "align":"true", "report-all-factors":"true"}

result = proxy.translate(params)

print result['text']

if 'id' in result:
    print "Segment ID:%s" % (result['id'])

if 'align' in result:
    print "Phrase alignments:"
    aligns = result['align']
    for align in aligns:
        print "%s,%s,%s" %(align['tgt-start'], align['src-start'], align['src-end'])