Rostislav Nedelchev commited on
Commit
5214b2a
·
1 Parent(s): bd50616

bugfix: bad filename resolving

Browse files
Files changed (1) hide show
  1. dailydialog.py +17 -3
dailydialog.py CHANGED
@@ -76,16 +76,30 @@ class DailyDialog(datasets.GeneratorBasedBuilder):
76
  split_name: str = str(Path(data_path).stem)
77
 
78
  with zipfile.ZipFile(data_path) as zip_file:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  acts_file = io.TextIOWrapper(
80
- zip_file.open(f"{split_name}/dialogues_act_{split_name}.txt"),
81
  encoding="utf-8",
82
  )
83
  emotions_file = io.TextIOWrapper(
84
- zip_file.open(f"{split_name}/dialogues_emotion_{split_name}.txt"),
85
  encoding="utf-8",
86
  )
87
  utterances_file = io.TextIOWrapper(
88
- zip_file.open(f"{split_name}/dialogues_{split_name}.txt"),
89
  encoding="utf-8",
90
  )
91
 
 
76
  split_name: str = str(Path(data_path).stem)
77
 
78
  with zipfile.ZipFile(data_path) as zip_file:
79
+ files_list = list(map(str, zip_file.namelist()))
80
+
81
+ acts_file = next((f for f in files_list if "act" in f.lower()))
82
+ emotions_file = next((f for f in files_list if "emotion" in f.lower()))
83
+ utterances_file = next(
84
+ (
85
+ f
86
+ for f in files_list
87
+ if "act" not in f.lower()
88
+ and "emotion" not in f.lower()
89
+ and "dialogues" in f.lower()
90
+ )
91
+ )
92
+
93
  acts_file = io.TextIOWrapper(
94
+ zip_file.open(acts_file),
95
  encoding="utf-8",
96
  )
97
  emotions_file = io.TextIOWrapper(
98
+ zip_file.open(emotions_file),
99
  encoding="utf-8",
100
  )
101
  utterances_file = io.TextIOWrapper(
102
+ zip_file.open(utterances_file),
103
  encoding="utf-8",
104
  )
105