Skip to content

Instantly share code, notes, and snippets.

@elaichi
Created December 19, 2011 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elaichi/1495251 to your computer and use it in GitHub Desktop.
Save elaichi/1495251 to your computer and use it in GitHub Desktop.
Hack to debug Apertium's output
  • 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.
@elaichi
Copy link
Author

elaichi commented Dec 19, 2011

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment