Difference between revisions of "Transfuse"

From Apertium
Jump to navigation Jump to search
(Created page with "'''Transfuse''' is used under the hood for Format handling on the edges of the pipeline. See * User:Khannatanmai/Wordbound_blanks * https://github.com/TinoDidrikse...")
 
Line 6: Line 6:
   
 
* https://github.com/TinoDidriksen/Transfuse
 
* https://github.com/TinoDidriksen/Transfuse
  +
  +
== Debugging transfuse issues ==
  +
  +
Transfuse runs the full pipeline with NUL flushing, so if you want to catch the intermediate output between stages of a mode, you need a little helper. Put this in $PATH with filename <code>teez</code>:
  +
  +
<pre>
  +
#!/bin/sh
  +
[ "$1" = -z ] && shift
  +
  +
[ -z "$1" ] && { echo "Expecting file as arg" >&2; exit 1; }
  +
  +
awk -v out="$1" 'BEGIN{RS="\0"}{printf "%s", $0 >> out; printf "%s", $0}'
  +
</pre>
  +
  +
then you can <code>cp modes/foo-bar.mode modes/tf.mode</code> and insert `teez /tmp/tf1.log | ` at the start and `| teez /tmp/tfN.log` etc. in the middle between pipeline steps in modes/tf.mode and do things like <code>APERTIUM_TRANSFUSE=yes apertium -f docx -u -d . tf /tmp/in.docx >/tmp/out.docx</code> and then inspect /tmp/tf?.log

Revision as of 09:42, 3 June 2022

Transfuse is used under the hood for Format handling on the edges of the pipeline.

See

Debugging transfuse issues

Transfuse runs the full pipeline with NUL flushing, so if you want to catch the intermediate output between stages of a mode, you need a little helper. Put this in $PATH with filename teez:

#!/bin/sh
[ "$1" = -z ] && shift

[ -z "$1" ] && { echo "Expecting file as arg" >&2; exit 1; }

awk -v out="$1" 'BEGIN{RS="\0"}{printf "%s", $0 >> out; printf "%s", $0}'

then you can cp modes/foo-bar.mode modes/tf.mode and insert `teez /tmp/tf1.log | ` at the start and `| teez /tmp/tfN.log` etc. in the middle between pipeline steps in modes/tf.mode and do things like APERTIUM_TRANSFUSE=yes apertium -f docx -u -d . tf /tmp/in.docx >/tmp/out.docx and then inspect /tmp/tf?.log