ShimizuYuki commited on
Commit
95b2b6e
1 Parent(s): b4ab6e8

Rename Dataset loading script.py to script.py

Browse files
Dataset loading script.py → script.py RENAMED
@@ -23,7 +23,7 @@ _URLS = {
23
  "hero_hero_comic": "https://drive.google.com/file/d/1wel0zjoa8GvBo255dlX7cVOPF9XbvQrI/view?usp=sharing",
24
  }
25
 
26
- class NCEducationDataset(datasets.GeneratorBasedBuilder):
27
 
28
  VERSION = datasets.Version("1.0.1")
29
 
@@ -35,31 +35,31 @@ class NCEducationDataset(datasets.GeneratorBasedBuilder):
35
  DEFAULT_CONFIG_NAME = "adjacency_list"
36
 
37
  def _info(self):
38
- if self.config.name == "adjacency_list": # This is the name of the configuration selected in BUILDER_CONFIGS above
39
- features = datasets.Features(
40
- {
41
- "hero1": datasets.Value("string"),
42
- "hero2": datasets.Value("string"),
43
- "counts": datasets.Value("int64")
44
- # These are the features of your dataset like images, labels ...
45
- }
46
- )
47
- else: # This is an example to show how to have different features for "first_domain" and "second_domain"
48
- features = datasets.Features(
49
- {
50
- "hero1": datasets.Value("string"),
51
- "hero2": datasets.Value("string"),
52
- "comic": datasets.Value("int64")
53
- # These are the features of your dataset like images, labels ...
54
- }
55
- )
56
- return datasets.DatasetInfo(
57
- description=_DESCRIPTION,
58
- features=features,
59
- homepage=_HOMEPAGE,
60
- license=_LICENSE,
61
- citation=_CITATION,
62
- )
63
 
64
 
65
  def _split_generators(self, dl_manager):
@@ -75,29 +75,19 @@ class NCEducationDataset(datasets.GeneratorBasedBuilder):
75
  ]
76
 
77
  def _generate_examples(self, filepath):
78
- data = {}
79
- with open(filepath, "r", encoding="utf-8") as file:
80
- csv_reader = csv.DictReader(file)
81
- for row in csv_reader:
82
- if self.config.name == "adjacency_list":
83
- hero1 = row["hero1"]
84
- hero2 = row["hero2"]
85
- counts = int(row["counts"])
86
- else:
87
- hero1 = row["hero1"]
88
- hero2 = row["hero2"]
89
- comic = row["comic"]
90
-
91
- for idx, (area_name, area_data) in enumerate(data.items()):
92
- if self.config.name == "adjacency_list":
93
- yield idx, {
94
- "hero1": hero1,
95
- "hero2": hero2,
96
- "counts": counts,
97
- }
98
- else:
99
- yield idx, {
100
- "hero1": hero1,
101
- "hero2": hero2,
102
- "comic": comic,
103
- }
 
23
  "hero_hero_comic": "https://drive.google.com/file/d/1wel0zjoa8GvBo255dlX7cVOPF9XbvQrI/view?usp=sharing",
24
  }
25
 
26
+ class Marvel(datasets.GeneratorBasedBuilder):
27
 
28
  VERSION = datasets.Version("1.0.1")
29
 
 
35
  DEFAULT_CONFIG_NAME = "adjacency_list"
36
 
37
  def _info(self):
38
+ if self.config.name == "adjacency_list": # This is the name of the configuration selected in BUILDER_CONFIGS above
39
+ features = datasets.Features(
40
+ {
41
+ "hero1": datasets.Value("string"),
42
+ "hero2": datasets.Value("string"),
43
+ "counts": datasets.Value("int64")
44
+ # These are the features of your dataset like images, labels ...
45
+ }
46
+ )
47
+ else: # This is an example to show how to have different features for "first_domain" and "second_domain"
48
+ features = datasets.Features(
49
+ {
50
+ "hero1": datasets.Value("string"),
51
+ "hero2": datasets.Value("string"),
52
+ "comic": datasets.Value("int64")
53
+ # These are the features of your dataset like images, labels ...
54
+ }
55
+ )
56
+ return datasets.DatasetInfo(
57
+ description=_DESCRIPTION,
58
+ features=features,
59
+ homepage=_HOMEPAGE,
60
+ license=_LICENSE,
61
+ citation=_CITATION,
62
+ )
63
 
64
 
65
  def _split_generators(self, dl_manager):
 
75
  ]
76
 
77
  def _generate_examples(self, filepath):
78
+ """Generates examples as dictionaries."""
79
+ with open(filepath, encoding="utf-8") as csv_file:
80
+ reader = csv.DictReader(csv_file)
81
+ for id_, row in enumerate(reader):
82
+ if self.config.name == "adjacency_list":
83
+ yield id_, {
84
+ "hero1": row["hero1"],
85
+ "hero2": row["hero2"],
86
+ "counts": int(row["counts"]),
87
+ }
88
+ elif self.config.name == "hero_hero_comic":
89
+ yield id_, {
90
+ "hero1": row["hero1"],
91
+ "hero2": row["hero2"],
92
+ "comic": int(row["comic"]),
93
+ }