|
|
|
[OP on mathjax-dev](https://groups.google.com/forum/#!topic/mathjax-dev/BpP3bF-NvaY)
|
|
|
|
|
|
|
|
Starting example: `a+b+c` which might be realized as
|
|
|
|
|
|
|
|
```html
|
|
|
|
<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.tex0 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.,
|
|
|
|
|
|
|
|
```html
|
|
|
|
<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
|
|
|
|
|
|
|
|
```html
|
|
|
|
<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? |
|
|
|
\ No newline at end of file |