Update
Browse files- Custom_SQuAD.py +6 -39
Custom_SQuAD.py
CHANGED
|
@@ -107,32 +107,6 @@ class ShellcodeIA32(datasets.GeneratorBasedBuilder):
|
|
| 107 |
my_urls = _URLs[self.config.name]
|
| 108 |
data_dir = dl_manager.download_and_extract("https://huggingface.co/datasets/Serhii/Custom_SQuAD/blob/main/Dataset.json")
|
| 109 |
data_dir = "/home/pc/Dev/HF_Datasets/Custom_SQuAD/Dataset.json"
|
| 110 |
-
# return [
|
| 111 |
-
# datasets.SplitGenerator(
|
| 112 |
-
# name=datasets.Split.TRAIN,
|
| 113 |
-
# # These kwargs will be passed to _generate_examples
|
| 114 |
-
# gen_kwargs={
|
| 115 |
-
# "filepath": os.path.join(data_dir, "Shellcode_IA32.tsv"),
|
| 116 |
-
# "split": "train",
|
| 117 |
-
# },
|
| 118 |
-
# ),
|
| 119 |
-
# datasets.SplitGenerator(
|
| 120 |
-
# name=datasets.Split.TEST,
|
| 121 |
-
# # These kwargs will be passed to _generate_examples
|
| 122 |
-
# gen_kwargs={
|
| 123 |
-
# "filepath": os.path.join(data_dir, "Shellcode_IA32.tsv"),
|
| 124 |
-
# "split": "test"
|
| 125 |
-
# },
|
| 126 |
-
# ),
|
| 127 |
-
# datasets.SplitGenerator(
|
| 128 |
-
# name=datasets.Split.VALIDATION,
|
| 129 |
-
# # These kwargs will be passed to _generate_examples
|
| 130 |
-
# gen_kwargs={
|
| 131 |
-
# "filepath": os.path.join(data_dir, "Shellcode_IA32.tsv"),
|
| 132 |
-
# "split": "dev",
|
| 133 |
-
# },
|
| 134 |
-
# ),
|
| 135 |
-
# ]
|
| 136 |
return [
|
| 137 |
datasets.SplitGenerator(
|
| 138 |
name=datasets.Split.TRAIN,
|
|
@@ -167,7 +141,7 @@ class ShellcodeIA32(datasets.GeneratorBasedBuilder):
|
|
| 167 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 168 |
"""This function returns the examples in the raw (text) form."""
|
| 169 |
print(f"FILEPATH ------------------ {filepath}")
|
| 170 |
-
df = pd.read_json(filepath)
|
| 171 |
train = df.sample(frac = 0.8, random_state = 0)
|
| 172 |
test = df.drop(train.index)
|
| 173 |
dev = test.sample(frac = 0.5, random_state = 0)
|
|
@@ -180,16 +154,9 @@ class ShellcodeIA32(datasets.GeneratorBasedBuilder):
|
|
| 180 |
data = test
|
| 181 |
for idx, row in data.iterrows():
|
| 182 |
yield idx, {
|
| 183 |
-
"
|
| 184 |
-
"
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
-
# with open(filepath, encoding="utf-8") as f:
|
| 187 |
-
# reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
|
| 188 |
-
# reader =
|
| 189 |
-
# for idx, row in enumerate(reader):
|
| 190 |
-
#
|
| 191 |
-
# yield idx, {
|
| 192 |
-
# "snippet": row["SNIPPETS"],
|
| 193 |
-
# "intent": row["INTENTS"],
|
| 194 |
-
#
|
| 195 |
-
# }
|
|
|
|
| 107 |
my_urls = _URLs[self.config.name]
|
| 108 |
data_dir = dl_manager.download_and_extract("https://huggingface.co/datasets/Serhii/Custom_SQuAD/blob/main/Dataset.json")
|
| 109 |
data_dir = "/home/pc/Dev/HF_Datasets/Custom_SQuAD/Dataset.json"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
return [
|
| 111 |
datasets.SplitGenerator(
|
| 112 |
name=datasets.Split.TRAIN,
|
|
|
|
| 141 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 142 |
"""This function returns the examples in the raw (text) form."""
|
| 143 |
print(f"FILEPATH ------------------ {filepath}")
|
| 144 |
+
df = pd.read_json(filepath, lines=True)
|
| 145 |
train = df.sample(frac = 0.8, random_state = 0)
|
| 146 |
test = df.drop(train.index)
|
| 147 |
dev = test.sample(frac = 0.5, random_state = 0)
|
|
|
|
| 154 |
data = test
|
| 155 |
for idx, row in data.iterrows():
|
| 156 |
yield idx, {
|
| 157 |
+
"id": row["id"],
|
| 158 |
+
"title": row["title"],
|
| 159 |
+
"context": row["context"],
|
| 160 |
+
"question": row["question"],
|
| 161 |
+
"answers": row["answers"],
|
| 162 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|