Initial commit
Browse files- .gitattributes +1 -0
- data/label.txt +3 -0
- data/test.tsv +3 -0
- data/train.tsv +3 -0
- data/valid.tsv +3 -0
- sst2.py +60 -0
.gitattributes
CHANGED
@@ -14,3 +14,4 @@
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
|
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
17 |
+
data/*.tsv filter=lfs diff=lfs merge=lfs -text
|
data/label.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
negative
|
2 |
+
neutral
|
3 |
+
positive
|
data/test.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a4d98e09975d839768390474782dd41ac659500e6457ad4effd80bca99377f54
|
3 |
+
size 206309
|
data/train.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ad7c45acfd7b940cd700cdfd97c7d4b68de665f30f706db0c4b5fad412d3482
|
3 |
+
size 787281
|
data/valid.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a647699f3f4d953ea2fe7cd1be7c78ef3e7651b2027f1a1e24763994df8b6620
|
3 |
+
size 100504
|
sst2.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import absolute_import, division, print_function
|
2 |
+
|
3 |
+
import datasets
|
4 |
+
|
5 |
+
|
6 |
+
_URL = "data/"
|
7 |
+
_URLs = {
|
8 |
+
"train": _URL + "train.tsv",
|
9 |
+
"valid": _URL + "valid.tsv",
|
10 |
+
"test": _URL + "test.tsv",
|
11 |
+
}
|
12 |
+
|
13 |
+
|
14 |
+
class SST2(datasets.GeneratorBasedBuilder):
|
15 |
+
def _info(self):
|
16 |
+
return datasets.DatasetInfo(
|
17 |
+
description="SST2 Dataset",
|
18 |
+
features=datasets.Features(
|
19 |
+
{
|
20 |
+
"text": datasets.Value("string"),
|
21 |
+
"label": datasets.features.ClassLabel(names=["positive", "negative"]),
|
22 |
+
}
|
23 |
+
),
|
24 |
+
supervised_keys=None,
|
25 |
+
license="",
|
26 |
+
homepage="",
|
27 |
+
citation="",
|
28 |
+
)
|
29 |
+
|
30 |
+
def _split_generators(self, dl_manager):
|
31 |
+
downloaded_files = dl_manager.download_and_extract(_URLs)
|
32 |
+
|
33 |
+
return [
|
34 |
+
datasets.SplitGenerator(
|
35 |
+
name=datasets.Split.TRAIN,
|
36 |
+
gen_kwargs={
|
37 |
+
"filepath": downloaded_files["train"],
|
38 |
+
}
|
39 |
+
),
|
40 |
+
datasets.SplitGenerator(
|
41 |
+
name=datasets.Split.VALIDATION,
|
42 |
+
gen_kwargs={
|
43 |
+
"filepath": downloaded_files["valid"],
|
44 |
+
}
|
45 |
+
),
|
46 |
+
datasets.SplitGenerator(
|
47 |
+
name=datasets.Split.TEST,
|
48 |
+
gen_kwargs={
|
49 |
+
"filepath": downloaded_files["test"],
|
50 |
+
}
|
51 |
+
),
|
52 |
+
]
|
53 |
+
|
54 |
+
def _generate_examples(self, filepath):
|
55 |
+
|
56 |
+
with open(filepath, "r") as f:
|
57 |
+
for idx, line in enumerate(f):
|
58 |
+
text, label = line.split("\t")
|
59 |
+
|
60 |
+
yield idx, {"text": text.strip(), "label": label.strip()}
|