Can Spacy Support other than Natural Language? #9528
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For parsing out SQL queries, you don't need to parse natural language, you can do it in an easier way. SQL is a context free language, which means it's "easier" to parse. Context free languages are more complicated than regular languages and easier than human languages. Here's a great resource: Hopcroft and Ullmann Automata Theory book . You're looking for Chapter 3, Context Free Languages. So basically a context free grammar for SQL queries look sth like this:
Notice that this is a grammar that finely breaks down the SQL query strings into its elements. This is not possible for natural language. Natural languages are hard by nature, this is the reason we use statistical models. Regular and context free languages are represented by easier grammars(which are regular grammars and CF grammars), hence can be parsed with less complicated tools. Statistical models are big hammers, you don't need them for every problem especially when you know the problem already have an easier and well-defined alternative 😉 . Here's an ANTLR grammar for PostgreSQL: https://github.com/antlr/grammars-v4/tree/master/sql/postgresql If you want to do it with Python, I recommend Another recommendation is |
Beta Was this translation helpful? Give feedback.
For parsing out SQL queries, you don't need to parse natural language, you can do it in an easier way.
SQL is a context free language, which means it's "easier" to parse. Context free languages are more complicated than regular languages and easier than human languages.
Here's a great resource: Hopcroft and Ullmann Automata Theory book . You're looking for Chapter 3, Context Free Languages.
So basically a context free grammar for SQL queries look sth like this:
…