DialogZoo / src /preprocess /Banking77.py
AnAutomaticPencil's picture
data preprocessing update
a6326c7
raw
history blame contribute delete
759 Bytes
from utils import write_jsonl_file, read_csv_file, parse
def reformat(args, file):
path = args.input_dir + "/" + file + ".csv"
data = read_csv_file(path)
turns = []
for i in range(len(data)):
t = {
"turn": "single",
"locale": "en",
"dialog": [
{
"roles": ["USER"],
"utterance": data["text"][i],
"active_intents": [data["category"][i]],
}
],
}
turns.append(t)
write_jsonl_file(turns, args.output_dir + "/" + file + ".jsonl")
def preprocess(args):
reformat(args, "train")
reformat(args, "test")
if __name__ == "__main__":
args = parse()
preprocess(args)