|
import sys |
|
|
|
sys.path.append("modules/preprocess") |
|
|
|
from preprocessor.SerialPreprocessor import SerialConfig, SerialPreprocessor |
|
from const import ( |
|
QUESTION_IN_CONTEXT_REWRITING, |
|
) |
|
from preprocessor.prompt_funcs import const_prompt_func_wrapper |
|
from preprocessor.knowledge_funcs import extract_dict_knowledge_wrapper, None_knowledge |
|
from preprocessor.label_funs import ( |
|
extrac_rewritten, |
|
) |
|
|
|
if __name__ == "__main__": |
|
TASK = QUESTION_IN_CONTEXT_REWRITING |
|
input_data_path = sys.argv[1] |
|
output_data_path = sys.argv[2] |
|
has_knowledge = len(sys.argv) > 3 |
|
|
|
kf = ( |
|
extract_dict_knowledge_wrapper(": ", " | ") if has_knowledge else None_knowledge |
|
) |
|
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( |
|
"Rewrite the user utterance of current turn based on the given dialogue context." |
|
), |
|
knowledge_func=kf, |
|
|
|
label_func=extrac_rewritten, |
|
) |
|
) |
|
|
|
serial_proc.launch() |
|
|