@thien
commited on
Commit
•
1975910
1
Parent(s):
cc4eb1a
initial commit
Browse files- .gitattributes +59 -0
- README.md +40 -0
- political.py +134 -0
- political_data/classtrain.txt +0 -0
- political_data/democratic_only.dev.en +3 -0
- political_data/democratic_only.test.en +3 -0
- political_data/democratic_only.train.en +3 -0
- political_data/republican_only.dev.en +3 -0
- political_data/republican_only.test.en +3 -0
- political_data/republican_only.train.en +3 -0
.gitattributes
CHANGED
@@ -53,3 +53,62 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
||||||| (empty tree)
|
57 |
+
=======
|
58 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
59 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
60 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
61 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
62 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
63 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
64 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
65 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
66 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
67 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
68 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
69 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
70 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
71 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
72 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
73 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
74 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
75 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
76 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
77 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
78 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
79 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
80 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
81 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
82 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
83 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
84 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
85 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
86 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
87 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
88 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
89 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
90 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
91 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
92 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
93 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
94 |
+
# Audio files - uncompressed
|
95 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
96 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
97 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
98 |
+
# Audio files - compressed
|
99 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
100 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
101 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
102 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
103 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
104 |
+
# Image files - uncompressed
|
105 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
106 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
107 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
108 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
109 |
+
# Image files - compressed
|
110 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
111 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
112 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
113 |
+
political_data filter=lfs diff=lfs merge=lfs -text
|
114 |
+
*.en filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
task_categories:
|
4 |
+
- text-classification
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- politics
|
9 |
+
- tweets
|
10 |
+
pretty_name: Political Slant Tweets Dataset
|
11 |
+
size_categories:
|
12 |
+
- 100K<n<1M
|
13 |
+
---
|
14 |
+
|
15 |
+
## Political Slant Tweets Dataset
|
16 |
+
|
17 |
+
Political slant transfer dataset. Contains two classes of political tweets between Democratic and Republican Politicans. This dataset can be used for classification tasks.
|
18 |
+
|
19 |
+
This is taken directly from:
|
20 |
+
|
21 |
+
http://tts.speech.cs.cmu.edu/style_models/political_data.tar
|
22 |
+
tar -xvf political_data.tar
|
23 |
+
|
24 |
+
I can't take credit for this dataset; this is largely the work of Prabhumoye et al. This is simply a Wrapper for that dataset. See References below.
|
25 |
+
|
26 |
+
## Reference
|
27 |
+
|
28 |
+
@inproceedings{style_transfer_acl18,
|
29 |
+
title={Style Transfer Through Back-Translation},
|
30 |
+
author={Prabhumoye, Shrimai and Tsvetkov, Yulia and Salakhutdinov, Ruslan and Black, Alan W},
|
31 |
+
year={2018},
|
32 |
+
booktitle={Proc. ACL}
|
33 |
+
}
|
34 |
+
|
35 |
+
@inproceedings{rtgender,
|
36 |
+
title={{RtGender}: A Corpus for Studying Differential Responses to Gender},
|
37 |
+
author={Voigt, Rob and Jurgens, David and Prabhakaran, Vinodkumar and Jurafsky, Dan and Tsvetkov, Yulia},
|
38 |
+
year={2018},
|
39 |
+
booktitle={Proc. LREC},
|
40 |
+
}
|
political.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from pathlib import Path
|
3 |
+
import datasets
|
4 |
+
from typing import List
|
5 |
+
|
6 |
+
STYLE, CLASSIFIER = "style", "classifier"
|
7 |
+
_CITATION = """\
|
8 |
+
@inproceedings{style_transfer_acl18,
|
9 |
+
title={Style Transfer Through Back-Translation},
|
10 |
+
author={Prabhumoye, Shrimai and Tsvetkov, Yulia and Salakhutdinov, Ruslan and Black, Alan W},
|
11 |
+
year={2018},
|
12 |
+
booktitle={Proc. ACL}
|
13 |
+
}
|
14 |
+
"""
|
15 |
+
|
16 |
+
_DESCRIPTION = """\
|
17 |
+
Political slant transfer dataset. Contains two classes of political tweets between Democratic and Republican Politicans. This dataset can be used for classification tasks.
|
18 |
+
"""
|
19 |
+
_HOMEPAGE = "https://github.com/shrimai/Style-Transfer-Through-Back-Translation"
|
20 |
+
_LICENSE = "" # could not find.
|
21 |
+
|
22 |
+
|
23 |
+
class PoliticalDataset(datasets.GeneratorBasedBuilder):
|
24 |
+
VERSION = datasets.Version("1.0.0")
|
25 |
+
DEFAULT_CONFIG_NAME = STYLE
|
26 |
+
|
27 |
+
BUILDER_CONFIGS = [
|
28 |
+
datasets.BuilderConfig(
|
29 |
+
name=STYLE,
|
30 |
+
version=VERSION,
|
31 |
+
description="Political Tweets Dataset, used for Style Transfer tasks.",
|
32 |
+
),
|
33 |
+
datasets.BuilderConfig(
|
34 |
+
name=CLASSIFIER,
|
35 |
+
version=VERSION,
|
36 |
+
description="Political Tweets Dataset, Used for classification tasks.",
|
37 |
+
),
|
38 |
+
]
|
39 |
+
|
40 |
+
def _info(self):
|
41 |
+
features = datasets.Features(
|
42 |
+
{
|
43 |
+
"text": datasets.Value("string"),
|
44 |
+
"label": datasets.Value("string"),
|
45 |
+
}
|
46 |
+
)
|
47 |
+
return datasets.DatasetInfo(
|
48 |
+
description=_DESCRIPTION,
|
49 |
+
features=features,
|
50 |
+
supervised_keys=("text", "label"),
|
51 |
+
homepage=_HOMEPAGE,
|
52 |
+
license=_LICENSE,
|
53 |
+
citation=_CITATION,
|
54 |
+
)
|
55 |
+
|
56 |
+
def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
|
57 |
+
data_dir = "political_data"
|
58 |
+
|
59 |
+
splits: List[datasets.SplitGenerator] = []
|
60 |
+
if self.config.name == STYLE:
|
61 |
+
splits.append(
|
62 |
+
datasets.SplitGenerator(
|
63 |
+
name=datasets.Split.TRAIN,
|
64 |
+
gen_kwargs={
|
65 |
+
"filepaths": [
|
66 |
+
os.path.join(data_dir, "republican_only.train.en"),
|
67 |
+
os.path.join(data_dir, "democratic_only.train.en"),
|
68 |
+
],
|
69 |
+
"split": "train",
|
70 |
+
},
|
71 |
+
)
|
72 |
+
)
|
73 |
+
else:
|
74 |
+
splits.append(
|
75 |
+
datasets.SplitGenerator(
|
76 |
+
name=datasets.Split.TRAIN,
|
77 |
+
gen_kwargs={
|
78 |
+
"filepaths": [os.path.join(data_dir, "classtrain.txt")],
|
79 |
+
"split": "train",
|
80 |
+
},
|
81 |
+
)
|
82 |
+
)
|
83 |
+
|
84 |
+
splits += [
|
85 |
+
datasets.SplitGenerator(
|
86 |
+
name=datasets.Split.VALIDATION,
|
87 |
+
gen_kwargs={
|
88 |
+
"filepaths": [
|
89 |
+
os.path.join(data_dir, "republican_only.dev.en"),
|
90 |
+
os.path.join(data_dir, "democratic_only.dev.en"),
|
91 |
+
],
|
92 |
+
"split": "dev",
|
93 |
+
},
|
94 |
+
),
|
95 |
+
datasets.SplitGenerator(
|
96 |
+
name=datasets.Split.TEST,
|
97 |
+
gen_kwargs={
|
98 |
+
"filepaths": [
|
99 |
+
os.path.join(data_dir, "republican_only.test.en"),
|
100 |
+
os.path.join(data_dir, "democratic_only.test.en"),
|
101 |
+
],
|
102 |
+
"split": "test",
|
103 |
+
},
|
104 |
+
),
|
105 |
+
]
|
106 |
+
return splits
|
107 |
+
|
108 |
+
def _generate_examples(self, filepaths: List[str], split: str):
|
109 |
+
for filepath in filepaths:
|
110 |
+
filename = Path(filepath).name
|
111 |
+
label = filename.split(".")[0].split("_")[0]
|
112 |
+
with open(filepath, encoding="utf-8") as f:
|
113 |
+
for key, row in enumerate(f):
|
114 |
+
text = row.strip()
|
115 |
+
if split != "test":
|
116 |
+
# label only exists in train/eval files.
|
117 |
+
text = text.split()
|
118 |
+
label, text = text[0], text[1:]
|
119 |
+
text = " ".join(text)
|
120 |
+
|
121 |
+
yield (
|
122 |
+
key,
|
123 |
+
{"text": text, "label": label},
|
124 |
+
)
|
125 |
+
|
126 |
+
|
127 |
+
if __name__ == "__main__":
|
128 |
+
from tqdm import tqdm
|
129 |
+
|
130 |
+
dataset = PoliticalDataset(config_name="classifier")
|
131 |
+
dataset = dataset.as_streaming_dataset()
|
132 |
+
print(dataset)
|
133 |
+
for row in tqdm(dataset["train"]):
|
134 |
+
row["text"] = "hello"
|
political_data/classtrain.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
political_data/democratic_only.dev.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:67b0e9358ff8b75a49c761ee3c0f4491fe85cadb486d535d29f814decd77f5b2
|
3 |
+
size 186804
|
political_data/democratic_only.test.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:100b382aefbde27b34bb00bbd14fe5c187c16bbdc687557c598111746ab7cc46
|
3 |
+
size 2358533
|
political_data/democratic_only.train.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3705adeecd8758859f6b1729ea55cdd327efdbde8b00938d2477b139f45ecc66
|
3 |
+
size 25559362
|
political_data/republican_only.dev.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:da2a8ac301562b521dc9922d9635ca030ee5e6dd3846183ae5848266df55ead9
|
3 |
+
size 186309
|
political_data/republican_only.test.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:15ca942110dcb8d0690ddd8b292d1284bab974087a3bfef5113256ecdb05a38f
|
3 |
+
size 2292494
|
political_data/republican_only.train.en
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c8e609ecabcaee7d1fb96c12a523b9259718b5f4a00a323d24bfdea57457944e
|
3 |
+
size 25145176
|