兮尘
commited on
Commit
·
e38431d
1
Parent(s):
fcf2e50
dataset script
Browse files- RamseyGraph.py +6 -5
RamseyGraph.py
CHANGED
|
@@ -146,23 +146,24 @@ class RamseyGraph(datasets.GeneratorBasedBuilder):
|
|
| 146 |
# Download and extract dataset
|
| 147 |
name = self.config.name
|
| 148 |
url = _URLS[name]
|
| 149 |
-
|
| 150 |
-
data_dir = dl_manager.download_and_extract(url)
|
| 151 |
return [
|
| 152 |
datasets.SplitGenerator(
|
| 153 |
name=datasets.Split.TRAIN,
|
| 154 |
gen_kwargs={
|
| 155 |
-
"filepath":
|
|
|
|
|
|
|
| 156 |
},
|
| 157 |
)
|
| 158 |
]
|
| 159 |
|
| 160 |
-
def _generate_examples(self, filepath: str):
|
| 161 |
"""Yields examples from the dataset."""
|
| 162 |
if not os.path.exists(filepath):
|
| 163 |
raise FileNotFoundError(f"Dataset file {filepath} not found.")
|
| 164 |
# Determine if the file is gzipped or not
|
| 165 |
-
open_func = gzip.open if
|
| 166 |
|
| 167 |
with open_func(filepath, 'rt') as f:
|
| 168 |
for key, line in enumerate(f):
|
|
|
|
| 146 |
# Download and extract dataset
|
| 147 |
name = self.config.name
|
| 148 |
url = _URLS[name]
|
| 149 |
+
filepath = dl_manager.download_and_extract(url)
|
|
|
|
| 150 |
return [
|
| 151 |
datasets.SplitGenerator(
|
| 152 |
name=datasets.Split.TRAIN,
|
| 153 |
gen_kwargs={
|
| 154 |
+
"filepath": filepath,
|
| 155 |
+
"name": name,
|
| 156 |
+
"url": url,
|
| 157 |
},
|
| 158 |
)
|
| 159 |
]
|
| 160 |
|
| 161 |
+
def _generate_examples(self, filepath: str, name: str, url: str):
|
| 162 |
"""Yields examples from the dataset."""
|
| 163 |
if not os.path.exists(filepath):
|
| 164 |
raise FileNotFoundError(f"Dataset file {filepath} not found.")
|
| 165 |
# Determine if the file is gzipped or not
|
| 166 |
+
open_func = gzip.open if url.endswith('.gz') else open
|
| 167 |
|
| 168 |
with open_func(filepath, 'rt') as f:
|
| 169 |
for key, line in enumerate(f):
|