title: Converting natural language to a math equation
body: <p>I've got a home automation system working in Java, and I want to add simple math capabilities such as addition, subtraction, multiplication, division, roots, and powers.</p>
  
  <p>At the system current state, it can convert a phrase into tags, as shown in the following examples:</p>
  
  <p>example:</p>
  
  <pre><code>Phrase: "what is one hundred twenty two to the power of seven"
  Tagged: {QUESTION/math} {NUMBER/122} {MATH/pwr} {NUMBER/7}
  </code></pre>
  
  <p>example:</p>
  
  <pre><code>Phrase: "twenty seven plus pi 3 squared"
  Tagged: {NUMBER/27} {MATH/add} {NUMBER/3.14159} {MATH/multiply} {MATH/pwr} {NUMBER/2}
  </code></pre>
  
  <p>This example could be just as easily converted to something like this:</p>
  
  <pre><code>27 + 3.14159 * 3^2
  </code></pre>
  
  <p>Each tag is an object that can be queried for it value.</p>
  
  <p><strong>Edit: Specific question:</strong></p>
  
  <p>So now I need a way to read that group of tags as an equation, and return a numerical result. As a last resort I could use google or wolfram alpha, but that will be slower, and I'm trying to keep the automation system completely self contained.</p>
  
  <p>If you would like to see the entire source, <a href="https://github.com/Sprakle/HomeAutomation/tree/master/HomeAutomation" rel="nofollow">here it is in github.</a>
  Note that I have not committed the last few few changes, so some of the math related things I gave examples will not work.</p>