Difference between revisions of "Null flush"
(Created page with ''''Null flush''' is an option (<code>-z</code>) to most Apertium programs (and programs compatible with Apertium stream format) that flushes the output buffer upon receiving …') |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
'''Null flush''' is an option (<code>-z</code>) to most Apertium programs (and programs compatible with [[Apertium stream format]]) that flushes the output buffer upon receiving the <code>\0</code> character instead of on end-of-file. This allows programs which call Apertium externally to keep a translator online, meaning they can avoid startup time for every translation. |
'''Null flush''' is an option (<code>-z</code>) to most Apertium programs (and programs compatible with [[Apertium stream format]]) that flushes the output buffer upon receiving the <code>\0</code> character instead of on end-of-file. This allows programs which call Apertium externally to keep a translator online, meaning they can avoid startup time for every translation. |
||
To see how to use this in practice, read [[Daemon]]. |
|||
=== Testing === |
|||
If you want to test that a pipe handles null flush correctly, you can use something like: |
|||
<pre> |
|||
cat <(echo -e "this here[][\n]\0is a[][\n]\0little[][\n]\0flushing test[][\n]\0") /dev/stdin | your -z | pipe -z | goes -z | here -z |
|||
</pre> |
|||
where \0 are the nulls, and the [] are there because many of the tools expect a [][\n] at the end of a stream (all the deformatters put this at the end of the stream, try <tt>echo bunnymen|apertium-destxt</tt>). Use Ctrl-D (^D) to close the input that cat keeps open. |
|||
=== Other flush signals === |
|||
Note that in CG stream format, <code>vislcg3</code> uses the string "<STREAMCMD:FLUSH>" instead of a NUL byte: http://beta.visl.sdu.dk/cg3/single/#cmd-flush |
|||
(cg-proc, however, uses the NUL byte like the other programs used in Apertium). |
|||
[[Category:Terminology]] |
[[Category:Terminology]] |
||
[[Category:Documentation in English]] |
Latest revision as of 18:29, 18 October 2016
Null flush is an option (-z
) to most Apertium programs (and programs compatible with Apertium stream format) that flushes the output buffer upon receiving the \0
character instead of on end-of-file. This allows programs which call Apertium externally to keep a translator online, meaning they can avoid startup time for every translation.
To see how to use this in practice, read Daemon.
Testing[edit]
If you want to test that a pipe handles null flush correctly, you can use something like:
cat <(echo -e "this here[][\n]\0is a[][\n]\0little[][\n]\0flushing test[][\n]\0") /dev/stdin | your -z | pipe -z | goes -z | here -z
where \0 are the nulls, and the [] are there because many of the tools expect a [][\n] at the end of a stream (all the deformatters put this at the end of the stream, try echo bunnymen|apertium-destxt). Use Ctrl-D (^D) to close the input that cat keeps open.
Other flush signals[edit]
Note that in CG stream format, vislcg3
uses the string "<STREAMCMD:FLUSH>" instead of a NUL byte: http://beta.visl.sdu.dk/cg3/single/#cmd-flush
(cg-proc, however, uses the NUL byte like the other programs used in Apertium).