Read a file from a path and returns data as dict with given datasets.
data_dict = dict()
train_data_path = os.path.join(data_path, "dstc2-trn.jsonlist")
valid_data_path = os.path.join(data_path, "dstc2-val.jsonlist")
test_data_path = os.path.join(data_path, "dstc2-tst.jsonlist")
if train_data_path is not None:
print("___Reading train data from %s" % train_data_path)
if os.path.isfile(train_data_path):
data_dict["train"] = IntentDatasetReader.read_from_json(train_data_path)
else:
raise IOError("Error: Train file does not exist")
After Change
data_dict = dict()
train_data_path = Path(data_path).joinpath("dstc2-trn.jsonlist")
valid_data_path = Path(data_path).joinpath("dstc2-val.jsonlist")
test_data_path = Path(data_path).joinpath("dstc2-tst.jsonlist")
if Path(train_data_path).is_file():
print("___Reading train data from %s" % train_data_path)
data_dict["train"] = IntentDatasetReader.read_from_json(train_data_path)
else:
raise IOError("Error: Train file does not exist")
if Path(valid_data_path).is_file():
print("___Reading valid data from %s" % train_data_path)
data_dict["valid"] = IntentDatasetReader.read_from_json(valid_data_path)
else: