update
Browse files- test_script.py +8 -22
test_script.py
CHANGED
|
@@ -40,7 +40,11 @@ _LICENSE = "123"
|
|
| 40 |
# "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
| 41 |
# "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
| 42 |
# }
|
| 43 |
-
_URLS =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
|
@@ -117,7 +121,7 @@ class ScriptTest(datasets.GeneratorBasedBuilder):
|
|
| 117 |
name=datasets.Split.TRAIN,
|
| 118 |
# These kwargs will be passed to _generate_examples
|
| 119 |
gen_kwargs={
|
| 120 |
-
"filepath": os.path.join(data_dir
|
| 121 |
"split": "train",
|
| 122 |
},
|
| 123 |
),
|
|
@@ -125,7 +129,7 @@ class ScriptTest(datasets.GeneratorBasedBuilder):
|
|
| 125 |
name=datasets.Split.VALIDATION,
|
| 126 |
# These kwargs will be passed to _generate_examples
|
| 127 |
gen_kwargs={
|
| 128 |
-
"filepath": os.path.join(data_dir
|
| 129 |
"split": "validation",
|
| 130 |
},
|
| 131 |
),
|
|
@@ -133,7 +137,7 @@ class ScriptTest(datasets.GeneratorBasedBuilder):
|
|
| 133 |
name=datasets.Split.TEST,
|
| 134 |
# These kwargs will be passed to _generate_examples
|
| 135 |
gen_kwargs={
|
| 136 |
-
"filepath": os.path.join(data_dir
|
| 137 |
"split": "test"
|
| 138 |
},
|
| 139 |
),
|
|
@@ -141,24 +145,6 @@ class ScriptTest(datasets.GeneratorBasedBuilder):
|
|
| 141 |
|
| 142 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 143 |
def _generate_examples(self, filepath, split):
|
| 144 |
-
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 145 |
-
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 146 |
-
# with open(filepath, encoding="utf-8") as f:
|
| 147 |
-
# for key, row in enumerate(f):
|
| 148 |
-
# data = json.loads(row)
|
| 149 |
-
# if self.config.name == "first_domain":
|
| 150 |
-
# # Yields examples as (key, example) tuples
|
| 151 |
-
# yield key, {
|
| 152 |
-
# "sentence": data["sentence"],
|
| 153 |
-
# "option1": data["option1"],
|
| 154 |
-
# "answer": "" if split == "test" else data["answer"],
|
| 155 |
-
# }
|
| 156 |
-
# else:
|
| 157 |
-
# yield key, {
|
| 158 |
-
# "sentence": data["sentence"],
|
| 159 |
-
# "option2": data["option2"],
|
| 160 |
-
# "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
|
| 161 |
-
# }
|
| 162 |
with open(filepath, 'rb') as f:
|
| 163 |
df = pd.read_excel(f)
|
| 164 |
for key in df.index.tolist():
|
|
|
|
| 40 |
# "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
| 41 |
# "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
| 42 |
# }
|
| 43 |
+
_URLS = {
|
| 44 |
+
'train': 'https://huggingface.co/datasets/lijianbin/test_script/train.xlsx',
|
| 45 |
+
'validation': 'https://huggingface.co/datasets/lijianbin/test_script/validation.xlsx',
|
| 46 |
+
'test': 'https://huggingface.co/datasets/lijianbin/test_script/test.xlsx',
|
| 47 |
+
}
|
| 48 |
|
| 49 |
|
| 50 |
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
|
|
|
| 121 |
name=datasets.Split.TRAIN,
|
| 122 |
# These kwargs will be passed to _generate_examples
|
| 123 |
gen_kwargs={
|
| 124 |
+
"filepath": os.path.join(data_dir['train']),
|
| 125 |
"split": "train",
|
| 126 |
},
|
| 127 |
),
|
|
|
|
| 129 |
name=datasets.Split.VALIDATION,
|
| 130 |
# These kwargs will be passed to _generate_examples
|
| 131 |
gen_kwargs={
|
| 132 |
+
"filepath": os.path.join(data_dir['validation']),
|
| 133 |
"split": "validation",
|
| 134 |
},
|
| 135 |
),
|
|
|
|
| 137 |
name=datasets.Split.TEST,
|
| 138 |
# These kwargs will be passed to _generate_examples
|
| 139 |
gen_kwargs={
|
| 140 |
+
"filepath": os.path.join(data_dir['test']),
|
| 141 |
"split": "test"
|
| 142 |
},
|
| 143 |
),
|
|
|
|
| 145 |
|
| 146 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 147 |
def _generate_examples(self, filepath, split):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
with open(filepath, 'rb') as f:
|
| 149 |
df = pd.read_excel(f)
|
| 150 |
for key in df.index.tolist():
|