LisaWang0306 commited on
Commit
b55a988
1 Parent(s): 26886bb

Update dbp15k-fr-en.py

Browse files
Files changed (1) hide show
  1. dbp15k-fr-en.py +28 -14
dbp15k-fr-en.py CHANGED
@@ -1,8 +1,7 @@
1
  import datasets
2
  import os
3
 
4
- class EntityAlignmentConfig(datasets.BuilderConfig):
5
- """BuilderConfig for SuperGLUE."""
6
 
7
  def __init__(self, features, data_url, citation, url, label_classes=("False", "True"), **kwargs):
8
  """BuilderConfig for SuperGLUE.
@@ -24,7 +23,7 @@ class EntityAlignmentConfig(datasets.BuilderConfig):
24
  # the full release (v2.0).
25
  # 1.0.0: S3 (new shuffling, sharding and slicing mechanism).
26
  # 0.0.2: Initial version.
27
- super(EntityAlignmentConfig, self).__init__(version=datasets.Version("1.0.3"), **kwargs)
28
  self.features = features
29
  self.label_classes = label_classes
30
  self.data_url = data_url
@@ -32,24 +31,29 @@ class EntityAlignmentConfig(datasets.BuilderConfig):
32
  self.url = url
33
 
34
 
35
- class EntityAlignment(datasets.GeneratorBasedBuilder):
36
- """The SuperGLUE benchmark."""
37
 
38
  BUILDER_CONFIGS = [
39
- EntityAlignmentConfig(
40
  name="source",
41
  features=["column1", "column2", "column3"],
42
- data_url="https://www.dropbox.com/s/j55ly9i7w7t4tnn/dbp15k-fr-en-src.zip"
 
 
43
  ),
44
- EntityAlignmentConfig(
45
  name="target",
46
  features=["column1", "column2", "column3"],
47
- data_url="https://www.dropbox.com/s/eo2huntzhfti1p1/dbp15k-fr-en-tgt.zip"
 
 
48
  ),
49
- EntityAlignmentConfig(
50
  name="pairs",
51
  features=["left_id", "right_id"],
52
- data_url="https://www.dropbox.com/s/5lhkfka1imuum1o/dbp15k-fr-en-pairs.zip"
 
 
53
  ),
54
  ]
55
 
@@ -83,7 +87,7 @@ class EntityAlignment(datasets.GeneratorBasedBuilder):
83
  datasets.SplitGenerator(
84
  name="attr_triples",
85
  gen_kwargs={
86
- "data_file": os.path.join(dl_dir, "attr_triples_1"),
87
  "split": "attr_triples",
88
  },
89
  ),
@@ -114,7 +118,7 @@ class EntityAlignment(datasets.GeneratorBasedBuilder):
114
  datasets.SplitGenerator(
115
  name="attr_triples",
116
  gen_kwargs={
117
- "data_file": os.path.join(dl_dir, "attr_triples_2"),
118
  "split": "attr_triples",
119
  },
120
  ),
@@ -149,21 +153,31 @@ class EntityAlignment(datasets.GeneratorBasedBuilder):
149
  f = open(data_file,"r",encoding='utf-8')
150
  data = f.readlines()
151
  for i in range(len(data)):
152
- row = data[i].strip('\n').split('\t')
153
  if self.config.name in ["source", "target"]:
154
  if split in ["ent_ids","rel_ids"]:
 
155
  yield i, {
156
  "column1": row[0],
157
  "column2": row[1],
158
  "column3": None
159
  }
 
 
 
 
 
 
 
160
  else:
 
161
  yield i, {
162
  "column1": row[0],
163
  "column2": row[1],
164
  "column3": row[2]
165
  }
166
  if self.config.name == "pairs":
 
167
  yield i, {
168
  "left_id": row[0],
169
  "right_id": row[1]
 
1
  import datasets
2
  import os
3
 
4
+ class Dbp15kFrEnConfig(datasets.BuilderConfig):
 
5
 
6
  def __init__(self, features, data_url, citation, url, label_classes=("False", "True"), **kwargs):
7
  """BuilderConfig for SuperGLUE.
 
23
  # the full release (v2.0).
24
  # 1.0.0: S3 (new shuffling, sharding and slicing mechanism).
25
  # 0.0.2: Initial version.
26
+ super(Dbp15kFrEnConfig, self).__init__(version=datasets.Version("1.0.3"), **kwargs)
27
  self.features = features
28
  self.label_classes = label_classes
29
  self.data_url = data_url
 
31
  self.url = url
32
 
33
 
34
+ class DBP15KFREN(datasets.GeneratorBasedBuilder):
 
35
 
36
  BUILDER_CONFIGS = [
37
+ Dbp15kFrEnConfig(
38
  name="source",
39
  features=["column1", "column2", "column3"],
40
+ citation="TODO",
41
+ url="TODO",
42
+ data_url="https://huggingface.co/datasets/matchbench/dbp15k-fr-en/resolve/main/dbp15k-fr-en-src.zip"
43
  ),
44
+ Dbp15kFrEnConfig(
45
  name="target",
46
  features=["column1", "column2", "column3"],
47
+ citation="TODO",
48
+ url="TODO",
49
+ data_url="https://huggingface.co/datasets/matchbench/dbp15k-fr-en/resolve/main/dbp15k-fr-en-tgt.zip"
50
  ),
51
+ Dbp15kFrEnConfig(
52
  name="pairs",
53
  features=["left_id", "right_id"],
54
+ citation="TODO",
55
+ url="TODO",
56
+ data_url="https://huggingface.co/datasets/matchbench/dbp15k-fr-en/resolve/main/dbp15k-fr-en-pairs.zip"
57
  ),
58
  ]
59
 
 
87
  datasets.SplitGenerator(
88
  name="attr_triples",
89
  gen_kwargs={
90
+ "data_file": os.path.join(dl_dir, "att_triples_1"),
91
  "split": "attr_triples",
92
  },
93
  ),
 
118
  datasets.SplitGenerator(
119
  name="attr_triples",
120
  gen_kwargs={
121
+ "data_file": os.path.join(dl_dir, "att_triples_2"),
122
  "split": "attr_triples",
123
  },
124
  ),
 
153
  f = open(data_file,"r",encoding='utf-8')
154
  data = f.readlines()
155
  for i in range(len(data)):
156
+ #print(row)
157
  if self.config.name in ["source", "target"]:
158
  if split in ["ent_ids","rel_ids"]:
159
+ row = data[i].strip('\n').split('\t')
160
  yield i, {
161
  "column1": row[0],
162
  "column2": row[1],
163
  "column3": None
164
  }
165
+ elif split in ["rel_triples"]:
166
+ row = data[i].strip('\n').split('\t')
167
+ yield i, {
168
+ "column1": row[0],
169
+ "column2": row[1],
170
+ "column3": row[2]
171
+ }
172
  else:
173
+ row = data[i].strip('\n').split(' ')
174
  yield i, {
175
  "column1": row[0],
176
  "column2": row[1],
177
  "column3": row[2]
178
  }
179
  if self.config.name == "pairs":
180
+ row = data[i].strip('\n').split('\t')
181
  yield i, {
182
  "left_id": row[0],
183
  "right_id": row[1]