qgyd2021 commited on
Commit
8a97f64
1 Parent(s): 06124c0

[update]edit h_novel.py

Browse files
Files changed (1) hide show
  1. h_novel.py +26 -25
h_novel.py CHANGED
@@ -95,34 +95,35 @@ class HNovel(datasets.GeneratorBasedBuilder):
95
 
96
  try:
97
  filename = dl_manager.download(filename)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  except Exception:
99
  continue
100
 
101
- filename = Path(filename)
102
-
103
- name = filename.stem
104
- splits = name.split("_")
105
- idx = splits[-1]
106
- novel_name = "_".join(splits[:-1])
107
-
108
- row_idx = 1
109
- with open(filename.as_posix(), "r", encoding="utf-8") as f:
110
- for txt_row in f:
111
- txt_row = str(txt_row).strip()
112
- if len(txt_row) == 0:
113
- continue
114
-
115
- yield sample_idx, {
116
- "source": source,
117
- "idx": idx,
118
- "filename": "/".join(filename.parts[-3:]),
119
- "novel_name": novel_name,
120
- "row_idx": row_idx,
121
- "text": txt_row,
122
- }
123
- row_idx += 1
124
- sample_idx += 1
125
-
126
 
127
  if __name__ == '__main__':
128
  pass
 
95
 
96
  try:
97
  filename = dl_manager.download(filename)
98
+
99
+ filename = Path(filename)
100
+
101
+ name = filename.stem
102
+ splits = name.split("_")
103
+ idx = splits[-1]
104
+ novel_name = "_".join(splits[:-1])
105
+
106
+ row_idx = 1
107
+ with open(filename.as_posix(), "r", encoding="utf-8") as f:
108
+ for txt_row in f:
109
+ txt_row = str(txt_row).strip()
110
+ if len(txt_row) == 0:
111
+ continue
112
+
113
+ yield sample_idx, {
114
+ "source": source,
115
+ "idx": idx,
116
+ "filename": "/".join(filename.parts[-3:]),
117
+ "novel_name": novel_name,
118
+ "row_idx": row_idx,
119
+ "text": txt_row,
120
+ }
121
+ row_idx += 1
122
+ sample_idx += 1
123
+
124
  except Exception:
125
  continue
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  if __name__ == '__main__':
129
  pass