Update rel-text.py
Browse files- rel-text.py +19 -2
rel-text.py
CHANGED
|
@@ -20,6 +20,15 @@ class relText(datasets.GeneratorBasedBuilder):
|
|
| 20 |
},
|
| 21 |
data_url="https://huggingface.co/datasets/matchbench/rel-text/resolve/main/",
|
| 22 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
relTextConfig(
|
| 24 |
name="target",
|
| 25 |
features={
|
|
@@ -51,6 +60,11 @@ class relText(datasets.GeneratorBasedBuilder):
|
|
| 51 |
)
|
| 52 |
for split in ["train", "valid", "test"]
|
| 53 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
if self.config.name == "target":
|
| 55 |
return [datasets.SplitGenerator(name="target", gen_kwargs={
|
| 56 |
"path_file": dl_manager.download_and_extract(self.config.data_url), "split": "target", })]
|
|
@@ -58,13 +72,16 @@ class relText(datasets.GeneratorBasedBuilder):
|
|
| 58 |
def _generate_examples(self, path_file, split):
|
| 59 |
file = pd.read_csv(path_file)
|
| 60 |
for i, row in file.iterrows():
|
| 61 |
-
if split not in ['target']:
|
| 62 |
yield i, {
|
| 63 |
"ltable_id": row["ltable_id"],
|
| 64 |
"rtable_id": row["rtable_id"],
|
| 65 |
"label": row["label"],
|
| 66 |
}
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
else:
|
| 69 |
yield i, {
|
| 70 |
"id": row["id"],
|
|
|
|
| 20 |
},
|
| 21 |
data_url="https://huggingface.co/datasets/matchbench/rel-text/resolve/main/",
|
| 22 |
),
|
| 23 |
+
|
| 24 |
+
relTextConfig(
|
| 25 |
+
name="source",
|
| 26 |
+
features={
|
| 27 |
+
"column": datasets.Value("string"),
|
| 28 |
+
},
|
| 29 |
+
data_url="https://huggingface.co/datasets/matchbench/rel-text/resolve/main/left.csv",
|
| 30 |
+
),
|
| 31 |
+
|
| 32 |
relTextConfig(
|
| 33 |
name="target",
|
| 34 |
features={
|
|
|
|
| 60 |
)
|
| 61 |
for split in ["train", "valid", "test"]
|
| 62 |
]
|
| 63 |
+
|
| 64 |
+
if self.config.name == "source":
|
| 65 |
+
return [datasets.SplitGenerator(name="source", gen_kwargs={
|
| 66 |
+
"path_file": dl_manager.download_and_extract(self.config.data_url), "split": "source", })]
|
| 67 |
+
|
| 68 |
if self.config.name == "target":
|
| 69 |
return [datasets.SplitGenerator(name="target", gen_kwargs={
|
| 70 |
"path_file": dl_manager.download_and_extract(self.config.data_url), "split": "target", })]
|
|
|
|
| 72 |
def _generate_examples(self, path_file, split):
|
| 73 |
file = pd.read_csv(path_file)
|
| 74 |
for i, row in file.iterrows():
|
| 75 |
+
if split not in ['source','target']:
|
| 76 |
yield i, {
|
| 77 |
"ltable_id": row["ltable_id"],
|
| 78 |
"rtable_id": row["rtable_id"],
|
| 79 |
"label": row["label"],
|
| 80 |
}
|
| 81 |
+
elif split in ['source']:
|
| 82 |
+
yield i, {
|
| 83 |
+
"column": row["column"],
|
| 84 |
+
}
|
| 85 |
else:
|
| 86 |
yield i, {
|
| 87 |
"id": row["id"],
|