Answers.Body: <p>You can use a component library which can help you to implement Natural language query builder in your application( <em>the question part</em> ) called <a href="https://opennlp.apache.org" rel="nofollow noreferrer">Open Natural Language Processing Package</a>
   ,  so you can definitely develop a module, by using existing modules of OpenNLP such as entity extraction, chunking and parsing.</p>
  
  <p>According to <a href="https://en.wikipedia.org/wiki/Question_answering" rel="nofollow noreferrer">wikipedia source</a>   ; it points out that as of 2001, <em>Q&amp;A</em> applications typically includes "a question classifier module which determines the type of question and the type of answer," so "a multiagent question and answering architecture has been proposed, where each domain [or variable] is represented by an agent which tries to answer questions, taking into account its specific knowledge."</p>
  
  <p>But it still need some effort to build a <a href="https://deepblue.lib.umich.edu/bitstream/handle/2027.42/138709/lifei_1.pdf?sequence=1&amp;isAllowed=y" rel="nofollow noreferrer">NLgenerators inline with databases</a> , for the answer query and also is the link to help you on how you can work with <a href="https://nlp.stanford.edu/software/sempre/wikitable" rel="nofollow noreferrer">Compositional Semantic Parsing on Semi-Structured Tables</a></p>
  
  <p>Hope this can give you some insight.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-26T15:25:26.427Z
Answers.Text: The original version of this answer was just copied and pasted from one or more answers from [here](https://www.quora.com/How-do-I-use-OpenNLP-to-convert-English-sentences-to-SQL-queries). Copy-and-paste answers are not allowed on this site, unless you give proper attribution and make it clear what has been copied. I will leave this comment here until I or someone else can review that all the info in this answer has not been copied/plagiarised.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-02-04T14:58:45.733Z
Answers.LastActivityDate: 2018-09-16T23:45:23.363Z
Answers.LastEditDate: 2018-09-16T23:45:23.363Z
Answers.UserDisplayName: quintumnia
Answers.Body: <p>This is a hard problem to solve, and the best approach depends very much on the scope of your task. If you have a small database table with a limited number of columns, you might get away with some basic pattern matching techniques. If it is more complex than that, you might have to do a full-scale syntactic analysis of the question. This also depends on the variations of possible question types.</p>
  
  <p>Assuming a limited set of variables and variants, you could set up something like:</p>
  
  <blockquote>
    <p>How many X did Y produce/How many X were done by Y/What is the number of X for Y</p>
  </blockquote>
  
  <p>where you have two variables to fill from the pattern, which you then use in your query:</p>
  
  <blockquote>
    <p>select sum(X) where producer == Y</p>
  </blockquote>
  
  <p>(Or whatever format your query has).</p>
  
  <p>The advantage of this is that you don't need to be a linguistics expert to maintain/expand the system, and you can just add more patterns to it if necessary. You might have to map some terms onto synonyms to get the right column headings/labels out of it. But this approach is not very hard to implement, and you should have a basic system up and running fairly quickly. You then have to see/test what questions your users are asking, and expand the pattern inventory accordingly.</p>
  
  <p>The disadvantage is that you might end up with a long list of patterns, and there could be some which are conflicting, ie the same pattern with different variables will ask for a different kind of result. If that turns out to be a problem, you might have to look for a more powerful approach.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-15T09:42:49.920Z
Answers.LastActivityDate: 2018-06-15T09:42:49.920Z
Answers.UserDisplayName: Oliver Mason
Body: <p>I am researching Natural Language Processing (NLP) to develop an NL Question Answering system. The answering part is already done. So processing the question remains, along with the questions regarding the algorithms.</p>
  <p>The final product should allow the user to ask a question in NL. The question then gets translated to an <a href="https://en.wikipedia.org/wiki/MultiDimensional_eXpressions" rel="nofollow noreferrer">Multidimensional Expressions (MDX) query</a>, which generates a script regarding the dimensions of the cube.</p>
  <p>How can I translate a natural language question to an MDX query?</p>
  <p>The outcome of the question is in the form of a calculation. For example</p>
  <blockquote>
  <p>How many declarations were done by employee 1?</p>
  </blockquote>
  <p>or</p>
  <blockquote>
  <p>Give me the quantities for Sales.</p>
  </blockquote>
  
Tags: <natural-language-processing><question-answering>
Title: How can I translate a natural language question to an MDX query?
UserDisplayName: lilienfa
ThreadText: # How can I translate a natural language question to an MDX query?
  
  (Asked by: username_0 on 2017-02-03)
  
  I am researching Natural Language Processing (NLP) to develop an NL Question Answering system. The answering part is already done. So processing the question remains, along with the questions regarding the algorithms.
  
  The final product should allow the user to ask a question in NL. The question then gets translated to an [Multidimensional Expressions (MDX) query](https://en.wikipedia.org/wiki/MultiDimensional_eXpressions), which generates a script regarding the dimensions of the cube.
  
  How can I translate a natural language question to an MDX query?
  
  The outcome of the question is in the form of a calculation. For example
  
  > How many declarations were done by employee 1?
  
  or
  
  > Give me the quantities for Sales.
  
  **Tags:** natural-language-processing, question-answering
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-02-04. Score: 5
  
  You can use a component library which can help you to implement Natural language query builder in your application( *the question part* ) called [Open Natural Language Processing Package](https://opennlp.apache.org)
  , so you can definitely develop a module, by using existing modules of OpenNLP such as entity extraction, chunking and parsing.
  
  According to [wikipedia source](https://en.wikipedia.org/wiki/Question_answering) ; it points out that as of 2001, *Q&A* applications typically includes "a question classifier module which determines the type of question and the type of answer," so "a multiagent question and answering architecture has been proposed, where each domain [or variable] is represented by an agent which tries to answer questions, taking into account its specific knowledge."
  
  But it still need some effort to build a [NLgenerators inline with databases](https://deepblue.lib.umich.edu/bitstream/handle/2027.42/138709/lifei_1.pdf?sequence=1&isAllowed=y) , for the answer query and also is the link to help you on how you can work with [Compositional Semantic Parsing on Semi-Structured Tables](https://nlp.stanford.edu/software/sempre/wikitable)
  
  Hope this can give you some insight.
  
  > **Comments:**
  > **username_2**: The original version of this answer was just copied and pasted from one or more answers from [here](https://www.quora.com/How-do-I-use-OpenNLP-to-convert-English-sentences-to-SQL-queries). Copy-and-paste answers are not allowed on this site, unless you give proper attribution and make it clear what has been copied. I will leave this comment here until I or someone else can review that all the info in this answer has not been copied/plagiarised.  
  
  ---
  
  ### Answer by username_3 on 2018-06-15. Score: 0
  
  This is a hard problem to solve, and the best approach depends very much on the scope of your task. If you have a small database table with a limited number of columns, you might get away with some basic pattern matching techniques. If it is more complex than that, you might have to do a full-scale syntactic analysis of the question. This also depends on the variations of possible question types.
  
  Assuming a limited set of variables and variants, you could set up something like:
  
  > How many X did Y produce/How many X were done by Y/What is the number of X for Y
  
  where you have two variables to fill from the pattern, which you then use in your query:
  
  > select sum(X) where producer == Y
  
  (Or whatever format your query has).
  
  The advantage of this is that you don't need to be a linguistics expert to maintain/expand the system, and you can just add more patterns to it if necessary. You might have to map some terms onto synonyms to get the right column headings/labels out of it. But this approach is not very hard to implement, and you should have a basic system up and running fairly quickly. You then have to see/test what questions your users are asking, and expand the pattern inventory accordingly.
  
  The disadvantage is that you might end up with a long list of patterns, and there could be some which are conflicting, ie the same pattern with different variables will ask for a different kind of result. If that turns out to be a problem, you might have to look for a more powerful approach.
  
  
  ---
  
  