Can I create a natural language to convert SQL queries using NLTK in Python?
-
I want to create a natural language to sql converter, but no previous knowledge about NLP. I just want to build a system that can create simple quries like SELECT or CREATE table kind of. Is it possible to do this with NLTK library of Python?
-
Answer:
Do do such a thing, you would indeed need NLTK to parse the human input natural language into its components. However, then comes the hard part. What I am thinking is somewhere along the lines of an interpreter or a compiler that sits in between NLTK and SQL and does this conversion in a structured, formal manner. So, you would give certain tokens as input to your custom compiler which would in turn generate SQL code for the SQL interpreter to run. The main reason for this complex process is that SQL can be used to create very complex queries (nested joins, for example) which if converted manually from Python to SQL might take a lot of time. Let the interpreter/compiler do the thing for you, in a much better way. Check out Bison and Flex for this.
Kanishka Ganguly at Quora Visit the source
Other answers
Wasn't SQL designed to be as close to "human language" as possible? (Not sure where, but I remember reading this somewhere.) Either way it sounds interesting and I would like to try it. Start a project on Github and share the link here. I'll be happy to join you! Edit: I've been thinking about it. How would you perform a simple select operation? "Select all from table_name" and everything else that I can think of sounds a bit too much like SQL! The simple queries, and other operations, in SQL are similar to how you'd state the task in English. The way I see it, the complex ones are the ones that can be simplified!
Mayur P R Rohith
Yes, you can. See my answer for You can use existing linguistic processing modules in NLTK to do that.
Dat Quoc Nguyen
Related Q & A:
- Can I create a second filestream container on an existing SQL Server 2008 database without going offline?Best solution by Database Administrators
- How can i create a mobile application server?Best solution by Stack Overflow
- How can i create a new blog?Best solution by Yahoo! Answers
- How can I create a new font?Best solution by Yahoo! Answers
- How can I create a cute, artsy, unique facebook profile?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.