Pierre Lepagnol
commited on
Commit
·
2d791da
1
Parent(s):
b109984
updating paths
Browse files
wrench.py
CHANGED
@@ -4,6 +4,7 @@ import json
|
|
4 |
|
5 |
import datasets
|
6 |
|
|
|
7 |
class WrenchConfig(datasets.BuilderConfig):
|
8 |
"""BuilderConfig for WRENCH."""
|
9 |
|
@@ -12,7 +13,9 @@ class WrenchConfig(datasets.BuilderConfig):
|
|
12 |
dataset_path,
|
13 |
**kwargs,
|
14 |
):
|
15 |
-
super(WrenchConfig, self).__init__(
|
|
|
|
|
16 |
self.dataset_path = dataset_path
|
17 |
|
18 |
|
@@ -22,39 +25,39 @@ class Wrench(datasets.GeneratorBasedBuilder):
|
|
22 |
BUILDER_CONFIGS = [
|
23 |
WrenchConfig(
|
24 |
name="imdb",
|
25 |
-
dataset_path="./imdb",
|
26 |
),
|
27 |
WrenchConfig(
|
28 |
name="yelp",
|
29 |
-
dataset_path="./yelp",
|
30 |
),
|
31 |
WrenchConfig(
|
32 |
name="youtube",
|
33 |
-
dataset_path="./youtube",
|
34 |
),
|
35 |
WrenchConfig(
|
36 |
name="sms",
|
37 |
-
dataset_path="./sms",
|
38 |
),
|
39 |
WrenchConfig(
|
40 |
name="agnews",
|
41 |
-
dataset_path="./agnews",
|
42 |
),
|
43 |
WrenchConfig(
|
44 |
name="trec",
|
45 |
-
dataset_path="./trec",
|
46 |
),
|
47 |
WrenchConfig(
|
48 |
name="cdr",
|
49 |
-
dataset_path="./cdr",
|
50 |
),
|
51 |
WrenchConfig(
|
52 |
name="semeval",
|
53 |
-
dataset_path="./semeval",
|
54 |
),
|
55 |
WrenchConfig(
|
56 |
name="chemprot",
|
57 |
-
dataset_path="./chemprot",
|
58 |
),
|
59 |
]
|
60 |
|
@@ -64,7 +67,7 @@ class Wrench(datasets.GeneratorBasedBuilder):
|
|
64 |
{
|
65 |
"text": datasets.Value("string"),
|
66 |
"label": datasets.Value("int8"),
|
67 |
-
"weak_labels":
|
68 |
}
|
69 |
)
|
70 |
)
|
@@ -90,7 +93,6 @@ class Wrench(datasets.GeneratorBasedBuilder):
|
|
90 |
"""Generate Custom examples."""
|
91 |
|
92 |
with open(filepath, encoding="utf-8") as f:
|
93 |
-
|
94 |
json_data = json.load(f)
|
95 |
|
96 |
for idx in json_data:
|
@@ -100,4 +102,8 @@ class Wrench(datasets.GeneratorBasedBuilder):
|
|
100 |
weak_labels = data["weak_labels"]
|
101 |
label = data["label"]
|
102 |
|
103 |
-
yield int(idx), {
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
import datasets
|
6 |
|
7 |
+
|
8 |
class WrenchConfig(datasets.BuilderConfig):
|
9 |
"""BuilderConfig for WRENCH."""
|
10 |
|
|
|
13 |
dataset_path,
|
14 |
**kwargs,
|
15 |
):
|
16 |
+
super(WrenchConfig, self).__init__(
|
17 |
+
version=datasets.Version("1.0.0", ""), **kwargs
|
18 |
+
)
|
19 |
self.dataset_path = dataset_path
|
20 |
|
21 |
|
|
|
25 |
BUILDER_CONFIGS = [
|
26 |
WrenchConfig(
|
27 |
name="imdb",
|
28 |
+
dataset_path="./classification/imdb",
|
29 |
),
|
30 |
WrenchConfig(
|
31 |
name="yelp",
|
32 |
+
dataset_path="./classification/yelp",
|
33 |
),
|
34 |
WrenchConfig(
|
35 |
name="youtube",
|
36 |
+
dataset_path="./classification/youtube",
|
37 |
),
|
38 |
WrenchConfig(
|
39 |
name="sms",
|
40 |
+
dataset_path="./classification/sms",
|
41 |
),
|
42 |
WrenchConfig(
|
43 |
name="agnews",
|
44 |
+
dataset_path="./classification/agnews",
|
45 |
),
|
46 |
WrenchConfig(
|
47 |
name="trec",
|
48 |
+
dataset_path="./classification/trec",
|
49 |
),
|
50 |
WrenchConfig(
|
51 |
name="cdr",
|
52 |
+
dataset_path="./classification/cdr",
|
53 |
),
|
54 |
WrenchConfig(
|
55 |
name="semeval",
|
56 |
+
dataset_path="./classification/semeval",
|
57 |
),
|
58 |
WrenchConfig(
|
59 |
name="chemprot",
|
60 |
+
dataset_path="./classification/chemprot",
|
61 |
),
|
62 |
]
|
63 |
|
|
|
67 |
{
|
68 |
"text": datasets.Value("string"),
|
69 |
"label": datasets.Value("int8"),
|
70 |
+
"weak_labels": datasets.Sequence(datasets.Value("int8")),
|
71 |
}
|
72 |
)
|
73 |
)
|
|
|
93 |
"""Generate Custom examples."""
|
94 |
|
95 |
with open(filepath, encoding="utf-8") as f:
|
|
|
96 |
json_data = json.load(f)
|
97 |
|
98 |
for idx in json_data:
|
|
|
102 |
weak_labels = data["weak_labels"]
|
103 |
label = data["label"]
|
104 |
|
105 |
+
yield int(idx), {
|
106 |
+
"text": text,
|
107 |
+
"label": label,
|
108 |
+
"weak_labels": weak_labels,
|
109 |
+
}
|