| import sys |
| import os |
|
|
| sys.path.append("modules/preprocess") |
|
|
| from preprocessor.SerialPreprocessor import SerialConfig, SerialPreprocessor |
| from const import ( |
| TEXT2SQL, |
| ) |
| from preprocessor.prompt_funcs import const_prompt_func_wrapper |
| from preprocessor.knowledge_funcs import ( |
| origin_knowledge, |
| extract_schema_knowledge_wrapper, |
| ) |
| from preprocessor.label_funs import ( |
| extract_sql, |
| ) |
|
|
| import shutil |
|
|
| if __name__ == "__main__": |
| |
| TASK = TEXT2SQL |
| input_data_path = sys.argv[1] |
| output_data_path = sys.argv[2] |
|
|
| serial_proc = SerialPreprocessor( |
| SerialConfig( |
| input_data_path, |
| output_data_path, |
| TASK, |
| logger_name=TASK, |
| task_bos_token=f"[{TASK}]", |
| prompt_func=const_prompt_func_wrapper( |
| "Parse the SQL based on the given dialogue context and schema." |
| ), |
| knowledge_func=origin_knowledge, |
| turn_knowledge_func=extract_schema_knowledge_wrapper(), |
| label_func=extract_sql, |
| ) |
| ) |
|
|
| serial_proc.launch() |
|
|
| shutil.copyfile( |
| os.path.join(input_data_path, "tables.json"), |
| os.path.join(output_data_path, "tables.json"), |
| ) |
|
|
| if not os.path.exists(os.path.join(output_data_path, "database")): |
| shutil.copytree( |
| os.path.join(input_data_path, "database"), |
| os.path.join(output_data_path, "database"), |
| ) |
|
|