Open yuxuan-wei118 opened 3 months ago
Although it can translate correctly, the new update code fails to pass a few tests involving the
Hi, @yuxuan-wei118. Thanks for your contribution! However, the issue is not clear to me. Besides the test you added, could you provide some examples of input, the expected result, and the result before the changes, highlighting the broken/missing part? I would like to understand the problem a little better.
Hi @asnunes. Thank you for your reply! One mistranslating example is the code below.
<math display="block">
<mfrac>
<mi>A</mi>
<mn>2</mn>
</mfrac>
<mo>=</mo>
<mrow>
<mo>(</mo>
<mtable>
<mtr>
<mtd><mn>1</mn></mtd>
<mtd><mn>2</mn></mtd>
<mtd><mn>3</mn></mtd>
</mtr>
<mtr>
<mtd><mn>4</mn></mtd>
<mtd><mn>5</mn></mtd>
<mtd><mn>6</mn></mtd>
</mtr>
<mtr>
<mtd><mn>7</mn></mtd>
<mtd><mn>8</mn></mtd>
<mtd><mn>9</mn></mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</math>
The expected result should be that:
However, the original code will translate the input into the following:
which is an illegal syntax missing \begin{array} {ccc} and end {array}.
Please feel free to give more comments!
Hi @asnunes.
For the first concern, I think we should change code to make these tests pass.
For the second issue, the addition of hspace
aims to address any possible additional formatting syntax that may appeared in mtable
tag.
Here is an example mathml code that you can see mtable
may include additional formatting syntax:
<math xmlns="http://www.w3.org/1998/Math/MathML"><mtable columnwidth="3em 0.05em 3em 3em 3em 3em" columnspacing="0.0em" rowspacing="0.05ex" rowlines="solid" columnlines="solid" frame="solid" framespacing="0.0em 0ex"><mtr><mtd><mi>x</mi></mtd><mtd><mspace width="0.0em" height="2.5ex" depth="1.0ex"/></mtd><mtd><mo>−</mo><mn>1</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mi>g</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mtd><mtd><mspace width="0.0em" height="2.5ex" depth="1.0ex"/></mtd><mtd><mn>6</mn></mtd><mtd><mn>4</mn></mtd><mtd><mn>2</mn></mtd><mtd><mo>−</mo><mn>1</mn></mtd></mtr><mtr><mtd><msup><mi>g</mi><mo>'</mo></msup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mtd><mtd><mspace width="0.0em" height="2.5ex" depth="1.0ex"/></mtd><mtd><mo>−</mo><mn>1</mn></mtd><mtd><mo>−</mo><mn>7</mn></mtd><mtd><mo>−</mo><mn>2</mn></mtd><mtd><mo>−</mo><mn>3</mn></mtd></mtr></mtable></math>
Adding hspace
makes the output Latex code closer to the intended format given by mathml. But it is also true that it may be redundant in some cases.
Please feel free to give more comments!
The original code may mistranslate the tag. I fixed the issue by using array{ccc} to express the final output, and it should be able to translate to Latex correctly now. I also add a few tests to prove that.