JesseLiu
commited on
Commit
·
05cc00f
1
Parent(s):
2828e2a
update script
Browse files- medqa_maze.py +14 -14
medqa_maze.py
CHANGED
@@ -2,15 +2,18 @@ import os
|
|
2 |
import json
|
3 |
import datasets
|
4 |
|
5 |
-
_CITATION = "
|
6 |
-
_DESCRIPTION = "
|
|
|
7 |
|
8 |
class MedQaMazeConfig(datasets.BuilderConfig):
|
9 |
def __init__(self, **kwargs):
|
10 |
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
11 |
|
12 |
-
|
|
|
13 |
BUILDER_CONFIGS = [
|
|
|
14 |
MedQaMazeConfig(name="advance", description="Advanced-level test data"),
|
15 |
MedQaMazeConfig(name="all", description="Full dataset with train and test"),
|
16 |
MedQaMazeConfig(name="basic", description="Basic-level test data"),
|
@@ -31,47 +34,47 @@ class MedQA_Maze(datasets.GeneratorBasedBuilder):
|
|
31 |
)
|
32 |
|
33 |
def _split_generators(self, dl_manager):
|
|
|
34 |
config_name = self.config.name
|
35 |
|
36 |
if config_name == "advance":
|
37 |
return [
|
38 |
datasets.SplitGenerator(
|
39 |
name=datasets.Split.TEST,
|
40 |
-
gen_kwargs={"filepath": os.path.join(
|
41 |
)
|
42 |
]
|
43 |
elif config_name == "all":
|
44 |
return [
|
45 |
datasets.SplitGenerator(
|
46 |
name=datasets.Split.TRAIN,
|
47 |
-
gen_kwargs={"filepath": os.path.join(
|
48 |
),
|
49 |
datasets.SplitGenerator(
|
50 |
name=datasets.Split.TEST,
|
51 |
-
gen_kwargs={"filepath": os.path.join(
|
52 |
)
|
53 |
]
|
54 |
elif config_name == "basic":
|
55 |
return [
|
56 |
datasets.SplitGenerator(
|
57 |
name=datasets.Split.TEST,
|
58 |
-
gen_kwargs={"filepath": os.path.join(
|
59 |
)
|
60 |
]
|
61 |
elif config_name == "challenge":
|
62 |
return [
|
63 |
datasets.SplitGenerator(
|
64 |
name=datasets.Split.TEST,
|
65 |
-
gen_kwargs={"filepath": os.path.join(
|
66 |
)
|
67 |
]
|
68 |
|
69 |
def _generate_examples(self, filepath):
|
70 |
-
"""Yields examples
|
71 |
with open(filepath, "r", encoding="utf-8") as f:
|
72 |
for idx, line in enumerate(f):
|
73 |
data = json.loads(line)
|
74 |
-
|
75 |
yield idx, {
|
76 |
"context": data.get("context", ""),
|
77 |
"question": data.get("question", ""),
|
@@ -79,7 +82,4 @@ class MedQA_Maze(datasets.GeneratorBasedBuilder):
|
|
79 |
"groundtruth_zoo": data.get("groundtruth_zoo", []),
|
80 |
"answer": data.get("answer", ""),
|
81 |
}
|
82 |
-
|
83 |
-
@property
|
84 |
-
def base_path(self):
|
85 |
-
return os.path.dirname(os.path.realpath(__file__))
|
|
|
2 |
import json
|
3 |
import datasets
|
4 |
|
5 |
+
_CITATION = ""
|
6 |
+
_DESCRIPTION = ""
|
7 |
+
|
8 |
|
9 |
class MedQaMazeConfig(datasets.BuilderConfig):
|
10 |
def __init__(self, **kwargs):
|
11 |
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
12 |
|
13 |
+
|
14 |
+
class MedQaMaze(datasets.GeneratorBasedBuilder):
|
15 |
BUILDER_CONFIGS = [
|
16 |
+
MedQaMazeConfig(name="default", description="A default config"),
|
17 |
MedQaMazeConfig(name="advance", description="Advanced-level test data"),
|
18 |
MedQaMazeConfig(name="all", description="Full dataset with train and test"),
|
19 |
MedQaMazeConfig(name="basic", description="Basic-level test data"),
|
|
|
34 |
)
|
35 |
|
36 |
def _split_generators(self, dl_manager):
|
37 |
+
base_path = os.path.dirname(os.path.realpath(__file__))
|
38 |
config_name = self.config.name
|
39 |
|
40 |
if config_name == "advance":
|
41 |
return [
|
42 |
datasets.SplitGenerator(
|
43 |
name=datasets.Split.TEST,
|
44 |
+
gen_kwargs={"filepath": os.path.join(base_path, "advance", "test.jsonl")}
|
45 |
)
|
46 |
]
|
47 |
elif config_name == "all":
|
48 |
return [
|
49 |
datasets.SplitGenerator(
|
50 |
name=datasets.Split.TRAIN,
|
51 |
+
gen_kwargs={"filepath": os.path.join(base_path, "all", "train.jsonl")}
|
52 |
),
|
53 |
datasets.SplitGenerator(
|
54 |
name=datasets.Split.TEST,
|
55 |
+
gen_kwargs={"filepath": os.path.join(base_path, "all", "test.jsonl")}
|
56 |
)
|
57 |
]
|
58 |
elif config_name == "basic":
|
59 |
return [
|
60 |
datasets.SplitGenerator(
|
61 |
name=datasets.Split.TEST,
|
62 |
+
gen_kwargs={"filepath": os.path.join(base_path, "basic", "test.jsonl")}
|
63 |
)
|
64 |
]
|
65 |
elif config_name == "challenge":
|
66 |
return [
|
67 |
datasets.SplitGenerator(
|
68 |
name=datasets.Split.TEST,
|
69 |
+
gen_kwargs={"filepath": os.path.join(base_path, "challenge", "test.jsonl")}
|
70 |
)
|
71 |
]
|
72 |
|
73 |
def _generate_examples(self, filepath):
|
74 |
+
"""Yields examples."""
|
75 |
with open(filepath, "r", encoding="utf-8") as f:
|
76 |
for idx, line in enumerate(f):
|
77 |
data = json.loads(line)
|
|
|
78 |
yield idx, {
|
79 |
"context": data.get("context", ""),
|
80 |
"question": data.get("question", ""),
|
|
|
82 |
"groundtruth_zoo": data.get("groundtruth_zoo", []),
|
83 |
"answer": data.get("answer", ""),
|
84 |
}
|
85 |
+
|
|
|
|
|
|