Difference between revisions of "User:Khannatanmai/Wordbound blanks"
Khannatanmai (talk | contribs) |
Khannatanmai (talk | contribs) |
||
Line 63: | Line 63: | ||
<pre>[[wordboundblank]]word[[/]] word2 word3 [[wordboundblank]]word4[[/]]</pre> |
<pre>[[wordboundblank]]word[[/]] word2 word3 [[wordboundblank]]word4[[/]]</pre> |
||
= Examples = |
|||
== Markup Handling == |
|||
=== Working Examples === |
|||
==== lt-proc to postchunk ==== |
|||
Moved to talk page. |
|||
⚫ | |||
⚫ | |||
Current Translation Command: <code>apertium-deshtml < html_input-eng.in | apertium -f none -d $PREFIX/apertium-eng-spa eng-spa | apertium-retxt</code> |
Current Translation Command: <code>apertium-deshtml < html_input-eng.in | apertium -f none -d $PREFIX/apertium-eng-spa eng-spa | apertium-retxt</code> |
||
Wordbound blank with Transfuse Command: <code>tf-html-fragment $PREFIX/apertium-eng-spa/modes/eng-spa.mode < html_input-eng.in</code> |
Wordbound blank with Transfuse Command: <code>tf-html-fragment $PREFIX/apertium-eng-spa/modes/eng-spa.mode < html_input-eng.in</code> |
||
== Spanish - Catalan == |
|||
<pre> |
<pre> |
||
Source: <p>Es <s>además</s> de Valencia.</p> |
Source: <p>Es <s>además</s> de Valencia.</p> |
||
Line 84: | Line 78: | ||
</pre> |
</pre> |
||
== Spanish - English == |
|||
<pre> |
<pre> |
||
Source: legal <b>persons</b> |
Source: legal <b>persons</b> |
||
Line 167: | Line 161: | ||
After wordbound blanks: <p id="8"><span class="cx-segment" data-segmentid="9"><a class="cx-link" data-linkid="17" href="./The_New_York_Times" rel="mw:WikiLink" title="The New York Times">The New York Times</a>, el cual tiene un <b>editor ejecutivo</b> sobre las páginas noticiosas y un <b>editor</b> de <b>página</b> del <b>editorial</b> encima páginas de opinión.</span></p> |
After wordbound blanks: <p id="8"><span class="cx-segment" data-segmentid="9"><a class="cx-link" data-linkid="17" href="./The_New_York_Times" rel="mw:WikiLink" title="The New York Times">The New York Times</a>, el cual tiene un <b>editor ejecutivo</b> sobre las páginas noticiosas y un <b>editor</b> de <b>página</b> del <b>editorial</b> encima páginas de opinión.</span></p> |
||
</pre> |
</pre> |
||
== Tests == |
|||
<pre> |
|||
Input: |
|||
The [[t:b:qum2bhp]]big [[t:b:qum2bhp; t:i:M0JZW3Q]]red dog[] |
|||
Transfer Input: |
|||
^The<det><def><sp>/El<det><def><GD><ND>$ [[t:b:qum2bhp]]^big<adj><sint>/grande<adj><mf>$ [[t:b:qum2bhp; t:i:M0JZW3Q]]^red<adj>/rojo<adj>$ ^dog<n><sg>/perro<n><GD><sg>$ |
|||
Transfer Output: |
|||
^Det_nom_adj_adj<SN><DET><GD><sg>{^el<det><def><3><4>$ [[t:b:qum2bhp]]^perro<n><3><4>$ [[t:b:qum2bhp; t:i:M0JZW3Q]]^rojo<adj><3><4>$ ^grande<adj><mf><4>$}$ |
|||
</pre> |
|||
* https://github.com/unhammer/apertium/blob/blank-handling/tests/pretransfer/__init__.py |
|||
== Previous Attempts == |
== Previous Attempts == |
Revision as of 08:31, 26 July 2020
This page will follow the development of word bound blanks in the apertium stream format.
Features
Transfer (Pull Request 1, Pull Request 2)
Chunker/Single-stage transfer
- Wordbound blanks are a part of transfer word as a new side: blank.
- Are ignored in pattern matching
- Wordbound blanks are added just before the output LU from the LU that the lem/lemh is clipped from.
- If the lem/lemh comes from a variable in the output then the balnk come from the LU which the lemma comes from, by tracing its variable assignment in <let>.
- No regression. Stream without wordbound blanks work as-is.
- Normal blanks don't move around while wordbound blanks move around.
- When MLUs are formed the blanks are merged.
- Tests added
- If rule pattern has only one LU, the wordbound blank gets output with all output LUs of the rule
Interchunk
- No change needed as inter chunk doesn't access LUs inside the chunk.
Postchunk
- Wordbound blanks are ignored in pattern matching
- Wordbound blanks are added just before the output LU from the LU that the lem/lemh/whole is clipped from.
- If the lem/lemh comes from a variable in the output then the blank comes from the LU which the lemma comes from, by tracing its variable assignment in .
- No regression. Stream without wordbound blanks work as-is.
- Normal blanks don't move around while wordbound blanks move around.
- When MLUs are formed the blanks are merged.
- Tests added
- If rule pattern chunk has only one LU, the wordbound blank gets output with all output LUs of the rule
Pretransfer (Pull Request)
- Wordbound blanks distribute across parts when compounds are split into individual LUs
Separable (Pull Request)
- Merge wordbound blanks and add to all LUs in rule output.
- Works for both autoseq and revautoseq.
Analysis, Biltrans, Generation (Pull Request)
- Parsing wordbound blanks as normal blanks for analysis, generation, biltrans.
- Added a test for wordbound blank analysis.
Streamparser (Pull Request)
- Wordbound blanks parsed as part of a lexical unit in the stream parser.
- Can be accessed by class member:
LexicalUnit.wordbound_blank
.
Postgeneration (Pull Request)
- Wordbound blanks merge when words merge.
- Wordbound blanks apply to all output words when output of postgen rule are more than input words.
- No regression for postgeneration without wordbound blanks.
- Lots of tests added.
Rationale
Wordbound blanks will store information about a lexical unit that can help us with several applications where we want to send information through the pipeline but this information can't be sent as tags because it would break the FST matching in the modules.
We want to store it with a lexical unit, as throughout the pipe lexical units split, merge, delete and get added, and we want that this information distributes over multiple output words, merges on the output words, etc.
Formalism
Wordbound blanks will be denoted by double square brackets and will always appear right before a Lexical Unit.
[[wordboundblank]]^LU<tags>$
If there is no Lexical Unit in the stream (before the morph analyser and after the generator), then we have an end wblank as well.
[[wordboundblank]]word[[/]] word2 word3 [[wordboundblank]]word4[[/]]
Full Pipe Testing
Current Translation Command: apertium-deshtml < html_input-eng.in | apertium -f none -d $PREFIX/apertium-eng-spa eng-spa | apertium-retxt
Wordbound blank with Transfuse Command: tf-html-fragment $PREFIX/apertium-eng-spa/modes/eng-spa.mode < html_input-eng.in
Spanish - Catalan
Source: <p>Es <s>además</s> de Valencia.</p> Current Translation: <p>És <s>a més de</s> València.</p> Ideal Translation: <p>Es <s>además</s> de Valencia.</p> After wordbound blanks: <p>És <s>*ademà s</s> de València.</p>
Spanish - English
Source: legal <b>persons</b> Current Translation: Personas jurídicas <b></b> Ideal Translation: <b>Personas</b> legales After wordbound blanks: <b>Personas</b> legales Source: I <b>am</b> David Current Translation: <b>soy David</b> Ideal Translation: <b>Soy</b> David After wordbound blanks: <b>soy</b> David Source: <p>Bees <b>cannot</b> swim</p> Current Translation: <p>Las abejas <b>no pueden</b> nadar</p> Ideal Translation: <p>Las Abejas <b>no pueden</b> nadar</p> After wordbound blanks: <p>las abejas <b>no pueden</b> nadar</p> Source: <a href="Conway">Conway</a> stated that young <a href="children">children</a><i>“understand <a href="Object_permanence">object permanence</a>. <a href="Concealment">Concealed</a> <a href="Object">objects</a> feature in their awareness.”</i><span typeof="mw:Extension/ref"><a href="#ref-5">[5]</a></span><b>(<a href="Nielsen">Nielsen</a> equivalence).</b> Current Translation: <a href="Conway">*Conway</a> Declaró que los niños <a href="children">jóvenes</a><i>“entienden <a href="Object_permanence">permanencia de objeto</a>. <a href="Concealment">Encubierto</a> <a href="Object">objeta</a> característica en su concienciación.”</i><span typeof="mw:Extension/ref"><a href="#ref-5">[5]</a></span><b>(<a href="Nielsen">*Nielsen</a> equivalencia).</b> Ideal Translation: After wordbound blanks: <a href="Conway">*Conway</a> declaró que los <a href="children">niños</a> jóvenes“<i>entienden <a href="Object_permanence">permanencia</a></i> de <i> <a href="Object_permanence">objeto</a></i><i>. <a href="Concealment">Encubierto</a> </i> <i><a href="Object">objeta</a> </i> <i>característica en</i> <i>su concienciación</i><i>.</i>”<span typeof="mw:Extension/ref"><a href="#ref-5">\[</a></span><span typeof="mw:Extension/ref"><a href="#ref-5">5</a></span><span typeof="mw:Extension/ref"><a href="#ref-5">\]</a></span><b>(<a href="Nielsen">*Nielsen</a> </b> <b>equivalencia)</b> <b>.</b> Source: <p><b><i>my sister</i><br/>lives</b> <u>in Wales</u></p> Current Translation: <p><b><i>Mis vidas</i><br/>de hermana</b> <u>en Gales</u></p> Ideal Translation: After wordbound blanks: Source: <b>The</b> <i>sister</i>'s <em>dog</em> Current Translation: <b>El perro</i> de la <em></b> <i>hermana</em> Ideal Translation: After wordbound blanks: <p><b><i>Mis</i><br></b> <b>vidas</b> de <b><i>hermana</i><br></b> <u>en Gales</u></p> <em>el perro</em>
From [tests]:
Source: <p>A <b>Japanese</b> <i>BBC</i> article</p> Current Translation: <p>Una <b>prenda</b> <i>de BBC</i> japonesa</p> Ideal Translation: After wordbound blanks: <b>de L</b> <i>a hermana</i><p>Una prenda de <i>BBC</i> <b>japonesa</b> </p> Source: <div>A <b>modern</b> Britain.</div> Current Translation: <div>Una <b>Gran Bretaña</b> moderna.</div> Ideal Translation: <div>Una Gran Bretaña <b>moderna</b>.</div> After wordbound blanks: <div>Una Gran Bretaña <b>moderna</b> .</div> Source: <p>The <b>big <i>red</i></b> dog</p> Current Translation: <p>El <b>perro <i>rojo</i></b> grande</p> Ideal Translation: <p>El perro <b><i>rojo</i></b> <b>grande</b></p> After wordbound blanks: <p>El perro <b> <i>rojo</i></b> <b>grande</b> </p> Source: <p>He said "<i>I tile <a href="x">bathrooms</a>.</i>"</p> Current Translation: <p> Diga "<i>#I baños <a href="x">de azulejo</a>.</i>"</p> Ideal Translation: <p>Diga que "<i>enladrillo</i> <i><a href="x">baños</a></i>."</p> After wordbound blanks: <p>diga "<i>#I <a href="x">baños</a></i> de <i>azulejo.</i>"</p> Source: <p>The <b>big red</b> dog</p> Current Translation: <p>El <b>perro rojo</b> grande</p> Ideal Translation: <p>El perro <b>rojo grande</b></p> After wordbound blanks: <p>El perro <b>rojo grande</b> </p> Source: <p>The <b>big</b> <b>red</b> dog</p> Current Translation: <p>El <b>perro</b> <b>rojo</b> grande</p> Ideal Translation: <p>El perro <b>rojo</b> <b>grande</b></p> After wordbound blanks: <p>El perro <b>rojo</b> <b>grande</b> </p> Source: <p>The <a href="1">big</a> <a href="2">red</a> dog</p> Current Translation: <p>El <a href="1">perro</a> <a href="2">rojo</a> grande</p> Ideal Translation: <p>El perro <a href="2">rojo</a> <a href="1">grande</a></p> After wordbound blanks: <p>El perro <a href="2">rojo</a> <a href="1">grande</a> </p> Source: <p id="8"><span class="cx-segment" data-segmentid="9"><a class="cx-link" data-linkid="17" href="./The_New_York_Times" rel="mw:WikiLink" title="The New York Times">The New York Times</a>, which has an <b>executive editor</b> over the news pages and an <b>editorial page editor</b> over opinion pages.</span></p> Current Translation: <p id="8"><span class="cx-segment" data-segmentid="9"><a class="cx-link" data-linkid="17" href="./The_New_York_Times" rel="mw:WikiLink" title="The New York Times">The New York Times</a>, el cual tiene un <b>editor ejecutivo</b> sobre las páginas noticiosas y un <b>editor de página del editorial</b> encima páginas de opinión.</span></p> Ideal Translation: <p id="8"><span data-segmentid="9" class="cx-segment"><a title="The New York Times" rel="mw:WikiLink" href="./The_New_York_Times" data-linkid="17" class="cx-link">The New York Times</a>, el cual tiene un <b>editor ejecutivo</b> sobre las páginas noticiosas y un <b>editor de página del editorial</b> encima páginas de opinión.</span></p> After wordbound blanks: <p id="8"><span class="cx-segment" data-segmentid="9"><a class="cx-link" data-linkid="17" href="./The_New_York_Times" rel="mw:WikiLink" title="The New York Times">The New York Times</a>, el cual tiene un <b>editor ejecutivo</b> sobre las páginas noticiosas y un <b>editor</b> de <b>página</b> del <b>editorial</b> encima páginas de opinión.</span></p>
Previous Attempts
- https://wiki.apertium.org/wiki/User:SilentFlame/Progress
- https://github.com/junaidiiith/apertium/tree/blank-handling GsoC2016 project
- https://github.com/unhammer/apertium/tree/blank-handling older, unfinished implementation of the changes required in apertium-transfer, with notes at https://github.com/unhammer/apertium/blob/blank-handling/blank_notes.org#consequences-of-this-type-of-blank-handling
- https://github.com/junaidiiith/apertium
- https://github.com/junaidiiith/Apertium_Code
- https://github.com/unhammer/apertium/commit/b5c73fbe82544d83a98eb16b921c2fa224f6d40c
References