Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some of the ways to convert NLP to SQL?

Recently, have started working on the idea of conversational chatbot and have been thinking of different ways to convert Natural Language query to SQL. These are some of the libraries I have shortlisted to evaluate before writing from scratch. Any other ideas or suggestions?

  • https://github.com/FerreroJeremy/ln2sql
  • https://github.com/dadashkarimi/seq2sql
  • https://github.com/xiaojunxu/SQLNet
  • http://www.ling.helsinki.fi/kit/2009s/clt231/NLTK/book/ch10-AnalyzingTheMeaningOfSentences.html#querying-a-database
like image 494
Pramit Avatar asked Feb 22 '19 02:02

Pramit


People also ask

What is NLP in SQL?

Comprehending natural language text, with its first-hand challenges of ambiguity and co-reference, has been a longstanding problem in Natural Language Processing (NLP).

How do I convert a text file to SQL?

Step 1:Downloading a txt file via FTP to a local drive. Step 2:Convert the file to SQL. Step 3:Copy the file to another FTP location. Step 4:Delete the file from the local drive.

Which database is good for NLP?

mysql - Which database can be used to store processed data from NLP engine - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

What is the use of NLP to SQL web service?

NLP to SQL web service is used for unstructured Natural Language user request transformation into Structured Query Language. For this tutorial, we are using NLSQL. For NLSQL customization you should have database schema and Q&A samples you would like to use.

Can you convert natural human language into SQL queries?

What we’re really asking here is how to convert natural human language into valid SQL queries. By itself, natural language processing ( NLP) is one of the most challenging areas in AI research, and translating that question into a valid SQL query introduces a whole new layer of complexity.

What do I need for nlsql and NLP?

For NLSQL customization you should have database schema and Q&A samples you would like to use. For NLP to API webservice you should have your API web service documentation as well as Q&A dialog sample.

How can non-technical experts implement cognitive automation using NLP?

This article presents detail instructions on how technically skilled experts can implement cognitive automation use cases and provide non-technical employees intuitive access to enterprise data by Natural Language Interface. NLP to SQL API is used for unstructured Natural Language user request transformation into Structured Query Language.


3 Answers

check this demo from AllenNLP: https://demo.allennlp.org/atis-parser

Which converts Natural Language text into SQL queries. They also have python library allennlp.

Here is their github repo: https://github.com/allenai/allennlp

For documentation regarding semantic_parsing:

https://allenai.github.io/allennlp-docs/api/allennlp.data.dataset_readers.semantic_parsing.html

like image 128
taurz Avatar answered Oct 19 '22 01:10

taurz


The main challenge here is to fit end-user needs. Most of the end-users are not technically skilled enough and they don't know database schema.

All open-sourced libraries mentioned here requires to use column names inside input requests, so end-user should design request as "give me count for column_name where column_name is lower than 120". This assumption is wrong because end-users usually don't care about database structure and column names. With open-source libraries, you can create another Structure Query Language layer on top of the usual SQL.

I would recommend having a look at NLP libraries before building your service:

BERT ==== https://github.com/hanxiao/bert-as-service

Sentence Transformers ==== https://github.com/UKPLab/sentence-transformers

VaderSentiment ==== https://github.com/cjhutto/vaderSentiment

Also, I would recommend having a look at NLP to SQL software architecture and existing commercial software for Natural Language to SQL

like image 3
Den Brown Avatar answered Oct 19 '22 01:10

Den Brown


Check this open source Python framework (started in 2014):

  • https://pypi.org/project/quepy/
  • https://quepy.readthedocs.io/en/latest/

Quepy is a framework to convert natural language to database queries. It can be easily customized to different kinds of questions in natural language and database queries. So, with little coding you can build your own system for natural language access to your database.

like image 3
peter.cyc Avatar answered Oct 18 '22 23:10

peter.cyc