Download mosesdecoder/contrib/server/client.py from suricodes/hindi-sindhi-docker: direct link, hf CLI and curl.
- Browser
- Download file 647 Bytes
-
https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/contrib/server/client.py
- Command line
-
hf download hf://spaces/suricodes/hindi-sindhi-docker/mosesdecoder/contrib/server/client.py
-
curl -L -o client.py https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/contrib/server/client.py
647 Bytes
| #!/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']) | |