What would be the best way I could convert english text to sql queries. For example, if I wanted a user to run a query by typing in “show me college students with a GPA higher than 3.” or “show mothers with 2 or more kids” The closest link I found so far is this: http://english2sql.com/demo.html, but it does not look like it is supported much since the email I sent them bounced back to me. If there are some open source libraries I could use for this, preferably in C# that would be awesome. Any suggestions?
Share
You can look at SharpNLP project.
It has very interesting abilities to parse and tokenise sentences.
Once you have a stream of tokens you can analyse and construct other “sentences” from it, for example in SQL.
Say, you can recognize verb tokens like “show”, “display” and know that it is going to be a SELECT query, then you find a noun and treat it as a table name, a preposition like “with” will become “WHERE”, article tokens could be ignored, etc.
Here is an example of how it can tokenise a sentence, recognize a type of every token and much more: Parsing English Sentences
Also you may look at the M language which is a DSL modeling language from Microsoft (I saw it presented on one of PDCs). It would probably a bit easier to use it than things like SharpNLP as you can easily define your own grammar rules so it will understand phrases like “show me mothers with more than 2 kids” and will know exactly what to do with them.
But I have no idea of what is the state of M-language now.