- 
          
 - 
                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
      
    This proposal is in its very early stages and will change considerably
Simple 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 id=0>
  <mrow id=1 data-math-semantic-parent="3,5" data-math-semantic-children="2,4,6">
     <mi id=2 data-math-semantic-child>a</mi>
     <mo id=3 data-math-semantic-operator="sum(meaning),+(type)">+</mo>
     <mi id=4 data-math-semantic-child>b</mi>
     <mo id=5 data-math-semantic-operator="sum,+">+</mo>
     <mi id=6 data-math-semantic-child>c</mi>
  </mrow>
</math>In other words,
- add mrows when necessary for semantic-tree-nodes with children
 - identify parent and children
 - use "standard" MathML tree numbering (IDs) (Texthelp/DSI/MathJax conversation but simplified).
 
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 id=0>
<mrow id=1 data-math-semantic-parent="3,8" data-math-semantic-children="2,4,9">
  <mi id=2 data-math-semantic-child>a</mi>
  <mo id=3 data-math-semantic-operator="sum,+">+</mo>
  <mrow id=4 data-math-semantic-child data-math-semantic-parent="6" data-math-semantic-children="5,7">
    <mi id=5 data-math-semantic-child>b</mi>
    <mo id=6 data-math-semantic-operator="product,⋅">⋅</mo>
    <mi id=7 data-math-semantic-child>d</mi>
  </mrow>
  <mo id=8 data-math-semantic-operator="sum,+">+</mo>
  <mi id=9 data-math-semantic-child>c</mi>
</mrow>
</math>Questions:
- Is this too simplistic?
 - Is adding mrows too destructive?
 - Do we need/want to be more destructive than that?