DialogZoo / src /preprocess /EmoryNLP.py
AnAutomaticPencil's picture
data preprocessing update
a6326c7
import re
from utils import read_json_file, read_jsonl_file, write_json_file, write_jsonl_file, read_txt_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(1, len(data)):
ds = data[i]
t = {
"turn": "single",
"locale": "en",
"dialog": []
}
d = {"role": ds[1].strip("\[\]\'"),
"utterance": ds[0],
"belief_state": [{"domain": None,
"goal": [{"intent": None,
"slot_value_table": [{"slot": 'Emotion', "value": ds[2]},
{"slot": 'Sentiment', "value": ds[4]}
]}
]}
],
"querying_result": [],
"summary": None,
"locale": None,
"topic" : None,
"opinions": None,
"answer": None}
t["dialog"].append(d)
t["knowledge"] = None
turns.append(t)
write_jsonl_file(turns, args.output_dir + "/" + file + ".jsonl")
def preprocess(args):
reformat(args, "emorynlp_train_final")
reformat(args, "emorynlp_dev_final")
reformat(args, "emorynlp_test_final")
if __name__ == "__main__":
args = parse()
preprocess(args)