From f2e1c28e179f6432ec713598e40618470deb4989 Mon Sep 17 00:00:00 2001 From: nlper <1132461715@qq.com> Date: Mon, 13 Sep 2021 08:12:20 +0800 Subject: [PATCH] Update preprocess.py FileNotFoundError: [Errno 2] No such file or directory: './data/ECDT2019/ecdt2019_tokenized/train_persona.json' --- preprocess.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/preprocess.py b/preprocess.py index 5fc9ffa..541c1ef 100644 --- a/preprocess.py +++ b/preprocess.py @@ -14,7 +14,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - +import os import json from argparse import ArgumentParser @@ -170,7 +170,10 @@ def preprocess(args): path = './data/ConvAI2/convai2_tokenized/' if not args.roberta else './data/ConvAI2/convai2_roberta_tokenized/' else: path = './data/ECDT2019/ecdt2019_tokenized/' - + if not os.path.exists(path): + # for the FileNotFoundError: [Errno 2] No such file or directory: './data/ECDT2019/ecdt2019_tokenized/train_persona.json', + # when first running this code. + os.makedirs(path) print(f"Saving tokenized dict at {path}") with open(path+'train_persona.json','w') as train_persona: