public
Created

Hack to debug Apertium's output

  • Download Gist
gistfile1.md
Markdown
  • Create a debugging mode file
cd apertium-en-es/modes/
sed "s/|/ | tee \/dev\/tty | /g" test-es-en.mode > debug-es-en.mode 
chmod +x debug-es-en.mode 
  • Sample output
cd ../
echo "Quiero una manzana roja del nuevo huerto." | ./modes/debug-es-en.mode 

^Quiero/Querer<vbmod><pri><p1><sg>/Querer<vblex><pri><p1><sg>$ ^una/uno<prn><tn><f><sg>/uno<det><ind><f><sg>/unir<vblex><prs><p3><sg>/unir<vblex><prs><p1><sg>/unir<vblex><imp><p3><sg>$ ^manzana/manzana<n><f><sg>$ ^roja/rojo<adj><f><sg>$ ^del/de<pr>+el<det><def><m><sg>$ ^nuevo/nuevo<adj><m><sg>$ ^huerto/huerto<n><m><sg>$^./.<sent>$
^Querer<vblex><pri><p1><sg>$ ^uno<det><ind><f><sg>$ ^manzana<n><f><sg>$ ^rojo<adj><f><sg>$ ^de<pr>+el<det><def><m><sg>$ ^nuevo<adj><m><sg>$ ^huerto<n><m><sg>$^.<sent>$
^Querer<vblex><pri><p1><sg>$ ^uno<det><ind><f><sg>$ ^manzana<n><f><sg>$ ^rojo<adj><f><sg>$ ^de<pr>$ ^el<det><def><m><sg>$ ^nuevo<adj><m><sg>$ ^huerto<n><m><sg>$^.<sent>$
^Verbcj<SV><vblex><pri><p1><sg>{^want<vblex><pres>$}$ ^det_nom_adj<SN><f><sg>{^a<det><ind><sg>$ ^red<adj>$ ^apple<n><3>$}$ ^de<PREP>{^of<pr>$}$ ^det_adj_nom<SN><m><sg>{^the<det><def><sg>$ ^new<adj><sint>$ ^orchard<n><3>$}$^punt<sent>{^.<sent>$}$
^Subj<prn><subj><p1><GD><sg>{^Prpers<prn><subj><3><4><5>$}$ ^verbcj<SV><vblex><pri><p1><sg>{^want<vblex><pres>$}$ ^det_nom_adj<SN><f><sg>{^a<det><ind><sg>$ ^red<adj>$ ^apple<n><3>$}$ ^de<PREP>{^of<pr>$}$ ^det_adj_nom<SN><m><sg>{^the<det><def><sg>$ ^new<adj><sint>$ ^orchard<n><3>$}$^punt<sent>{^.<sent>$}$
^Prpers<prn><subj><p1><mf><sg>$ ^want<vblex><pres>$ ^a<det><ind><sg>$ ^red<adj>$ ^apple<n><sg>$ ^of<pr>$ ^the<det><def><sg>$ ^new<adj><sint>$ ^orchard<n><sg>$^.<sent>$
I want ~a red apple of the new orchard.
I want a red apple of the new orchard.

The trick is to use the tee command [1]. Then sed is used to replace the pipes | in the mode file with | tee /dev/tty |.

[1] http://en.wikipedia.org/wiki/Tee_(command)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.