<commit_before># Queryparser
Let's parse some MySQL and ADQL!

## Requirements
To generate the parsers you need python (either 2 or 3), java and antlr4 (which
has to be installed inside the /usr/local/lib/ or /usr/local/bin/ directories). 
For running the parsers, only runtime libraries that are installed
automatically are needed.

## Instalation
After cloning the project, run
```
python setup.py install
```
This also takes care of installing the required antlr runtime package.

## Parsing
### MySQL
Processing of MySQL queries is done by first creating an instance of the
```
qp = MySQLQueryProcessor()
```
feeding it a MySQL query
```
sql = "SELECT a FROM b;"
qp.set_query(sql)
```
and running it with
```
qp.process_query()
```
After the processing, the processor object will include columns, functions,
and keywords used in the query.

Alternatively, passing the query at initialization automatically processes it.

### ADQL
Translation of ADQL queries is done similarly by first creating an instance
of the translator object,
```
query = ...
adt = ADQLQueryTranslator(query)
```
and calling
```
adt.to_mysql()
```
which returns a translated string.

## TODO
* Documentation
* ADQL coordinate systems
* ADQL mixed coordinates
* antlr search path<commit_msg>Add information about example queries<commit_after># Queryparser
Let's parse some MySQL and ADQL!

## Requirements
To generate the parsers you need python (either 2 or 3), java and antlr4 (which
has to be installed inside the /usr/local/lib/ or /usr/local/bin/ directories). 
For running the parsers, only runtime libraries that are installed
automatically are needed.

## Instalation
After cloning the project, run
```
python setup.py install
```
This also takes care of installing the required antlr runtime package.

## Parsing
### MySQL
Processing of MySQL queries is done by first creating an instance of the
```
qp = MySQLQueryProcessor()
```
feeding it a MySQL query
```
sql = "SELECT a FROM b;"
qp.set_query(sql)
```
and running it with
```
qp.process_query()
```
After the processing, the processor object will include columns, functions,
and keywords used in the query.

Alternatively, passing the query at initialization automatically processes it.

### ADQL
Translation of ADQL queries is done similarly by first creating an instance
of the translator object,
```
query = ...
adt = ADQLQueryTranslator(query)
```
and calling
```
adt.to_mysql()
```
which returns a translated string.

### Examples
There are some example queries in the queryparser/examples directory. Have a look there, edit `run.py` (just comment out/uncomment the line you want in `main`) and run it:
```
python queryparser/examples/run.py
```
This will parse a number of queries (specified in the corresponding example-files) and print the query, the parsed columns and the parsing time.

## TODO
* Documentation
* ADQL coordinate systems
* ADQL mixed coordinates
* antlr search path
{'fraction_non_alphanumeric': 0.08498293515358361, 'fraction_numerical': 0.0020477815699658703, 'mean_word_length': 4.781065088757397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1100388', 'n_tokens_mistral': 831, 'n_tokens_neox': 766, 'n_words': 384}