-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Embedding the semantic tree in MathML
Peter Krautzberger edited this page Mar 30, 2015
·
9 revisions
Starting example: a+b+c
which might be realized as
<math>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
<mo>+</mo>
<mi>c</mi>
</math>
which would yield [a semantic tree](https://github.com/zorkow/speech-rule-engine/blob/sloan_branch/doc/grammar.tex] looking like
+
|--- a
|--- b
|--- c
which could be embedded as follows
<math>
<mrow data-math-semantic-parent="sum" data-math-semantic-children="3">
<mi data-math-semantic-child>a</mi>
<mo data-math-semantic-operator>+</mo>
<mi data-math-semantic-child>b</mi>
<mo data-math-semantic-operator>+</mo>
<mi data-math-semantic-child>c</mi>
</mrow>
</math>
In other words,
- add mrows when necessary for semantic-tree-nodes with children
- identify children
- do some countin.
The hope is that this simple parent/child structure works well recursively, e.g.,
a + b*d + c
i.e.,
<math>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
<mo>⋅</mo>
<mi>d</mi>
<mo>+</mo>
<mi>c</mi>
</math>
would lead to a semantic tree of
+
|--- a
|--- *
| |--- b
| |--- c
|--- d
and we simply start from the leafs adding an mrow for * etc. to get
<math>
<mrow data-math-semantic-parent="sum" data-math-semantic-children="3">
<mi data-math-semantic-child> a</mi>
<mo data-math-semantic-operator>+</mo>
<mrow data-math-semantic-parent="product" data-math-semantic-children="2">
<mi data-math-semantic-child>b</mi>
<mo data-math-semantic-operator>⋅</mo>
<mi data-math-semantic-child>d</mi>
</mrow>
<mo data-math-semantic-operator>+</mo>
<mi data-math-semantic-child>c</mi>
</mrow>
</math>
This is assuming the MathML tree numbering (IDs) that Neil, Davide and the folks at Texthelp designed.
Questions:
- Is this too simplistic?
- Is adding mrows too destructive?
- Do we need/want to be more destructive than that?