Upload codeforces_question_solution_label.py
Browse files
codeforces_question_solution_label.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
|
5 |
+
class CodeforcesQuestionSolutionLabel(datasets.GeneratorBasedBuilder):
|
6 |
+
BUILDER_CONFIGS = [
|
7 |
+
datasets.BuilderConfig(name="cpp", description="C++ Solutions"),
|
8 |
+
datasets.BuilderConfig(name="py", description="Python Solutions"),
|
9 |
+
datasets.BuilderConfig(name="java", description="Java Solultions"),
|
10 |
+
]
|
11 |
+
|
12 |
+
def _info(self):
|
13 |
+
return datasets.DatasetInfo(
|
14 |
+
features=datasets.Features({
|
15 |
+
"contest_id": datasets.Value("string"),
|
16 |
+
"problem_id": datasets.Value("string"),
|
17 |
+
"statement": datasets.Value("string"),
|
18 |
+
"tags": datasets.Sequence(datasets.Value("string")),
|
19 |
+
"code": datasets.Value("string"),
|
20 |
+
"language": datasets.Value("string"),
|
21 |
+
}),
|
22 |
+
)
|
23 |
+
|
24 |
+
def _split_generators(self, dl_manager):
|
25 |
+
config = self.config.name
|
26 |
+
data_dir = f"{config}/"
|
27 |
+
return [
|
28 |
+
datasets.SplitGenerator(
|
29 |
+
name=datasets.Split.TRAIN,
|
30 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "train.jsonl")},
|
31 |
+
),
|
32 |
+
datasets.SplitGenerator(
|
33 |
+
name=datasets.Split.VALIDATION,
|
34 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "validation.jsonl")},
|
35 |
+
),
|
36 |
+
datasets.SplitGenerator(
|
37 |
+
name=datasets.Split.TEST,
|
38 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl")},
|
39 |
+
),
|
40 |
+
]
|
41 |
+
|
42 |
+
def _generate_examples(self, filepath):
|
43 |
+
with open(filepath, encoding="utf-8") as f:
|
44 |
+
for key, row in enumerate(f):
|
45 |
+
data = json.loads(row)
|
46 |
+
yield key, data
|