apertium-apy, where apy=APy, and stands for API in Python



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46776 72bbbca6-d526-0410-a7d9-f06f51895060
some cleaning up of commented-out code



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46777 72bbbca6-d526-0410-a7d9-f06f51895060
now with callback support, I think



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46780 72bbbca6-d526-0410-a7d9-f06f51895060
programming fail



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46785 72bbbca6-d526-0410-a7d9-f06f51895060
uses .mode files



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46821 72bbbca6-d526-0410-a7d9-f06f51895060
three different ways to translate: modes file direct, modes file deep, and apertium direct



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46822 72bbbca6-d526-0410-a7d9-f06f51895060
now requires r46823 for lrx-proc



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46824 72bbbca6-d526-0410-a7d9-f06f51895060
getting stuck at procOut.stdout.read(1)



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46825 72bbbca6-d526-0410-a7d9-f06f51895060
return False stack could be collapsed to a single line



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@46826 72bbbca6-d526-0410-a7d9-f06f51895060
another test to prevent failure



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47159 72bbbca6-d526-0410-a7d9-f06f51895060
apertium-transfer -z fails.  also, script needs to be async / threaded



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47160 72bbbca6-d526-0410-a7d9-f06f51895060
skip pretransfer



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47211 72bbbca6-d526-0410-a7d9-f06f51895060
a small bug fix and some more debugs



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47214 72bbbca6-d526-0410-a7d9-f06f51895060
proper handling of apertium-pretransfer



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47383 72bbbca6-d526-0410-a7d9-f06f51895060
fflush after writing the NUL (instead of writing it twice); use deformat; read apertiumpath/port from command line arguments

git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47463 72bbbca6-d526-0410-a7d9-f06f51895060
a little debugging



git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47467 72bbbca6-d526-0410-a7d9-f06f51895060
split up big requests before sending to pipeline so we don't fill up buffers

This doesn't handle parallel requests, simply to avoid deadlocking on read/write. Also, support POST, e.g. curl --data-urlencode 'langpair=nb|nn' --data-urlencode 'q@file' localhost:2737/translate

git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47473 72bbbca6-d526-0410-a7d9-f06f51895060
doh, typo in do_GET

git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47477 72bbbca6-d526-0410-a7d9-f06f51895060
Threading request handler, to handle multiple users

Uses TCPServer inheriting ThreadingMixIn. A lock on translateMode (which
has to have at most one thread per pipeline) ensures that part stays
single-threaded (to avoid Alice getting Bob's text).

http://stackoverflow.com/a/487281/69663 recommends select/polling over
threading (http://docs.python.org/3.3/library/socketserver.html for
diffs) but requires either lots of manually written dispatching
code (http://pymotw.com/2/select/) or a framework like Twisted.

Try testing with e.g.

python3 servlet "$APERTIUMPATH" 2737 &

curl -s --data-urlencode 'langpair=nb|nn' --data-urlencode \
'q@/tmp/reallybigfile' 'http://localhost:2737/translate' >/tmp/output &

curl 'http://localhost:2737/translate?langpair=nb|nn&q=men+ikke+den'
curl 'http://localhost:2737/translate?langpair=nb|nn&q=men+ikke+den'
curl 'http://localhost:2737/translate?langpair=nb|nn&q=men+ikke+den'

And see how the last three (after a slight wait) start outputting before
the first request is done.

git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@47994 72bbbca6-d526-0410-a7d9-f06f51895060
Add morphological analysis and generation support to APY

git-svn-id: https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy@48984 72bbbca6-d526-0410-a7d9-f06f51895060