mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
ported perl xmlrpc example to python
This commit is contained in:
parent
e7f54efa72
commit
34c8975aa7
21
contrib/server/client.py
Executable file
21
contrib/server/client.py
Executable file
@ -0,0 +1,21 @@
|
||||
#!/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 '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'])
|
Loading…
Reference in New Issue
Block a user