Dear all,
While working on apertium-eng-kaz, I was trying to write a macro to deal
with superblanks (the idea was not to output them when they are just a
single whitespace, when the first word, for instance, an English
article, does not translate into Kazakh) and was not succeeding. My plan
was to use a variable, like this:
<def-macro n="process-preblank-1" npar="1">
<!-- Sets preblank-1 to null if it is just a single blank;
sets it to superblank 1 otherwise -->
<choose>
<when>
<test>
<equal>
<b pos="1"/>
<lit v=" "/>
</equal>
</test>
<let>
<var n="preblank-1"/><lit v=""/>
</let>
</when>
<otherwise>
<let>
<var n="preblank-1"/><b pos="1"/>
</let>
</otherwise>
</choose>
</def-macro>
And then my was to call the macro in some rules:
<call-macro n="process-preblank-1">
<with-param pos="1"/>
</call-macro>
And then, instead of <b pos="1"/> I would output <var n="preblank-1"/>
<out>
<!-- snip -->
<!-- <b pos="1"/> -->
<var n="preblank-1"/>
<!-- snip -->
</out>
It did not work. It's seems to be accessing the superblank BEFORE the
first lexical unit (something like <b pos="0"/>), but I think this is
not stable.
Then I talked to Francis Tyers and he showed me what the problem might
be. Apparently, for <b pos="1"/> to be accessible to the macro, I have
to define the macro to have two arguments:
<def-macro n="process-preblank-1"*npar="2**"*> <!-- etc. -->
and then call it like this:
<call-macro n="process-preblank-1">
<with-param pos="1"/>
<with-param pos="2"/>
</call-macro>
And then it works. Problem solved but...
..this is not the semantics I expected from macro calls. Is this a bug,
or is this the desired semantics? (I am copying Sergio Ortiz, as he
implemented this sometime in 2007 when we were doing Catalan?English for
the Generalitat de Catalunya). The official documentation we wrote at
that time gives examples about lexical unit handling in connection with
agreement (e.g. fig 3.36) but does not have examples with superblanks on
them.
I expected calls to map positions (pos). If I call the macro with two
positions, i.e.
<with-param pos="4"/>
<with-param pos="1"/>
I was expecting that any reference to pos="1" in the macro referred to
pos="4" in the calling code and any reference to pos="2" referred to
pos="1" in the calling code, but I am not sure anymore. Which
superblanks would be made available to this macro?
If this is a bug, I would appreciate it being chased down before I do a
lot of superblank management in apertium-eng-kaz. I need it, both in
.t1x and in .t2x because word order varies widely.
If this is the desired semantics, I am ready to document it in the wiki
for future users, but I would need to understand first how it works, and
I would rather avoid reverse engineering ;-)
Thanks a million!
Mikel
--
Mikel L. Forcada (http://www.dlsi.ua.es/~mlf/)
Departament de Llenguatges i Sistemes InformĂ tics
Universitat d'Alacant
E-03071 Alacant, Spain
Phone: +34 96 590 9776
Fax: +34 96 590 9326
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Apertium-stuff mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/apertium-stuff