ScHh0625 commited on
Commit
ff8a1cd
1 Parent(s): b911e54

Update semi-rel.py

Browse files
Files changed (1) hide show
  1. semi-rel.py +60 -6
semi-rel.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import datasets
3
  import pandas as pd
 
4
 
5
 
6
  class semiRelConfig(datasets.BuilderConfig):
@@ -21,6 +22,27 @@ class semiRel(datasets.GeneratorBasedBuilder):
21
  },
22
  data_url="https://huggingface.co/datasets/matchbench/semi-Rel/resolve/main/",
23
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  ]
25
 
26
  def _info(self):
@@ -42,13 +64,45 @@ class semiRel(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 semiRelConfig(datasets.BuilderConfig):
 
22
  },
23
  data_url="https://huggingface.co/datasets/matchbench/semi-Rel/resolve/main/",
24
  ),
25
+ semiRelConfig(
26
+ name="source",
27
+ features={
28
+ "id": datasets.Value("string"),
29
+ "title": datasets.Value("string"),
30
+ "director": datasets.Value("string"),
31
+ "actors": datasets.Value("string"),
32
+ "year": datasets.Value("string"),
33
+ "rating": datasets.Value("string"),
34
+ "information": datasets.Value("string"),
35
+ },
36
+ data_url="https://huggingface.co/datasets/matchbench/semi-Rel/resolve/main/left.csv",
37
+ ),
38
+
39
+ semiRelConfig(
40
+ name="target",
41
+ features={
42
+ "content": datasets.Value("string"),
43
+ },
44
+ data_url="https://huggingface.co/datasets/matchbench/semi-Rel/resolve/main/right.json",
45
+ ),
46
  ]
47
 
48
  def _info(self):
 
64
  for split in ["train", "valid", "test"]
65
  ]
66
 
67
+ if self.config.name == "source":
68
+ return [datasets.SplitGenerator(name="source", gen_kwargs={
69
+ "path_file": dl_manager.download_and_extract(self.config.data_url), "split": "source", })]
70
+
71
+ if self.config.name == "target":
72
+ return [datasets.SplitGenerator(name="target", gen_kwargs={
73
+ "path_file": dl_manager.download_and_extract(self.config.data_url), "split": "target", })]
74
+
75
  def _generate_examples(self, path_file, split):
76
+ if split in [‘target']:
77
+ with open(path_file, "r") as f:
78
+ file = json.load(f)
79
+ for i in range(len(file)):
80
  yield i, {
81
+ "content": file[i]
 
 
82
  }
83
+ elif split in [‘source’]:
84
+ file = pd.read_csv(path_file)
85
+ for i, row in file.iterrows():
86
+ yield i, {
87
+ "id": row["id"],
88
+ "title": row["title"],
89
+ "director": row["director"],
90
+ "actors": row["actors"],
91
+ "year": row["year"],
92
+ "rating": row["rating"],
93
+ "information": row["information"],
94
+
95
+
96
+
97
+ }
98
+ else:
99
+ file = pd.read_csv(path_file)
100
+ for i, row in file.iterrows():
101
+ yield i, {
102
+ "ltable_id": row["ltable_id"],
103
+ "rtable_id": row["rtable_id"],
104
+ "label": row["label"],
105
+ }
106
+
107
+
108