ScHh0625 commited on
Commit
799da27
1 Parent(s): c50401a

Update semi-homo.py

Browse files
Files changed (1) hide show
  1. semi-homo.py +38 -8
semi-homo.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import datasets
3
  import pandas as pd
 
4
 
5
 
6
  class semiHomoConfig(datasets.BuilderConfig):
@@ -19,7 +20,22 @@ class semiHomo(datasets.GeneratorBasedBuilder):
19
  "rtable_id": datasets.Value("string"),
20
  "label": datasets.Value("string"),
21
  },
22
- data_url="https://huggingface.co/datasets/matchbench/semi-Homo/resolve/main/",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ),
24
  ]
25
 
@@ -42,13 +58,27 @@ class semiHomo(datasets.GeneratorBasedBuilder):
42
  for split in ["train", "valid", "test"]
43
  ]
44
 
 
 
 
 
 
 
 
 
45
  def _generate_examples(self, path_file, split):
46
- file = pd.read_csv(path_file)
47
- for i, row in file.iterrows():
48
- if split in ['train', 'valid','test']:
 
49
  yield i, {
50
- "ltable_id": row["ltable_id"],
51
- "rtable_id": row["rtable_id"],
52
- "label": row["label"],
53
  }
54
-
 
 
 
 
 
 
 
 
1
  import os
2
  import datasets
3
  import pandas as pd
4
+ import json
5
 
6
 
7
  class semiHomoConfig(datasets.BuilderConfig):
 
20
  "rtable_id": datasets.Value("string"),
21
  "label": datasets.Value("string"),
22
  },
23
+ data_url="https://huggingface.co/datasets/matchbench/semi-homo/resolve/main/",
24
+ ),
25
+ semiHomoConfig(
26
+ name="source",
27
+ features={
28
+ "content": datasets.Value("string"),
29
+ },
30
+ data_url="https://huggingface.co/datasets/matchbench/semi-homo/resolve/main/left.json",
31
+ ),
32
+
33
+ semihomoConfig(
34
+ name="target",
35
+ features={
36
+ "content": datasets.Value("string"),
37
+ },
38
+ data_url="https://huggingface.co/datasets/matchbench/semi-homo/resolve/main/right.json",
39
  ),
40
  ]
41
 
 
58
  for split in ["train", "valid", "test"]
59
  ]
60
 
61
+ if self.config.name == "source":
62
+ return [datasets.SplitGenerator(name="source", gen_kwargs={
63
+ "path_file": dl_manager.download_and_extract(self.config.data_url), "split": "source", })]
64
+
65
+ if self.config.name == "target":
66
+ return [datasets.SplitGenerator(name="target", gen_kwargs={
67
+ "path_file": dl_manager.download_and_extract(self.config.data_url), "split": "target", })]
68
+
69
  def _generate_examples(self, path_file, split):
70
+ if split in ['source','target']:
71
+ with open(path_file, "r") as f:
72
+ file = json.load(f)
73
+ for i in range(len(file)):
74
  yield i, {
75
+ "content": file[i]
 
 
76
  }
77
+ else:
78
+ file = pd.read_csv(path_file)
79
+ for i, row in file.iterrows():
80
+ yield i, {
81
+ "ltable_id": row["ltable_id"],
82
+ "rtable_id": row["rtable_id"],
83
+ "label": row["label"],
84
+ }