Datasets:
Tasks:
Text Classification
Modalities:
Text
Sub-tasks:
sentiment-analysis
Languages:
Chinese
Size:
1K - 10K
Tags:
stance-detection
License:
lfs for csv
Browse files- .gitattributes +1 -0
- nlpcc_stance.py +28 -59
.gitattributes
CHANGED
@@ -36,3 +36,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
*.tsv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
*.tsv filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.csv filter=lfs diff=lfs merge=lfs -text
|
nlpcc_stance.py
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
-
"""NLPCC Shared Task 4, Stance Detection in Chinese Microblogs"""
|
15 |
|
16 |
|
17 |
import csv
|
@@ -35,40 +35,30 @@ class NLPCCConfig(datasets.BuilderConfig):
|
|
35 |
def __init__(self, **kwargs):
|
36 |
super(NLPCCConfig, self).__init__(**kwargs)
|
37 |
|
38 |
-
class
|
39 |
-
"""The
|
40 |
|
41 |
VERSION = datasets.Version("1.0.0")
|
42 |
|
43 |
BUILDER_CONFIGS = [
|
44 |
-
NLPCCConfig(name="task_a", version=VERSION, description=""),
|
45 |
-
NLPCCConfig(name="task_b", version=VERSION, description="")
|
46 |
]
|
47 |
|
48 |
def _info(self):
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
)
|
64 |
-
elif self.config.name == "task_b":
|
65 |
-
features = datasets.Features(
|
66 |
-
{
|
67 |
-
"id": datasets.Value("string"),
|
68 |
-
"target": datasets.Value("string"),
|
69 |
-
"text": datasets.Value("string"),
|
70 |
-
}
|
71 |
-
)
|
72 |
|
73 |
return datasets.DatasetInfo(
|
74 |
description=_DESCRIPTION,
|
@@ -79,12 +69,8 @@ class XStance(datasets.GeneratorBasedBuilder):
|
|
79 |
)
|
80 |
|
81 |
def _split_generators(self, dl_manager):
|
82 |
-
|
83 |
-
|
84 |
-
test_text = dl_manager.download_and_extract("NLPCC2016_Stance_Detection_Task_A_Testdata.tsv")
|
85 |
-
elif self.config.name == "task_b":
|
86 |
-
train_text = dl_manager.download_and_extract("evasampledata4-TaskBR.tsv")
|
87 |
-
test_text = dl_manager.download_and_extract("NLPCC2016_Stance_Detection_Task_B_Testdata.tsv")
|
88 |
return [
|
89 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text, "split": "train"}),
|
90 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_text, "split": "test"}),
|
@@ -94,28 +80,11 @@ class XStance(datasets.GeneratorBasedBuilder):
|
|
94 |
with open(filepath, encoding="utf-8") as f:
|
95 |
reader = csv.DictReader(f, delimiter=",")
|
96 |
guid = 0
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
elif self.config.name == "task_b":
|
106 |
-
if split == "train":
|
107 |
-
for instance in reader:
|
108 |
-
instance["target"] = instance.pop("TARGET")
|
109 |
-
instance["text"] = instance.pop("TEXT")
|
110 |
-
instance['id'] = str(guid)
|
111 |
-
yield guid, instance
|
112 |
-
guid += 1
|
113 |
-
else:
|
114 |
-
for instance in reader:
|
115 |
-
instance["target"] = instance.pop("TARGET")
|
116 |
-
instance["text"] = instance.pop("TEXT")
|
117 |
-
instance["stance"] = instance.pop("STANCE")
|
118 |
-
instance['id'] = str(guid)
|
119 |
-
yield guid, instance
|
120 |
-
guid += 1
|
121 |
-
|
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
+
"""NLPCC Shared Task 4, Stance Detection in Chinese Microblogs (Task A)"""
|
15 |
|
16 |
|
17 |
import csv
|
|
|
35 |
def __init__(self, **kwargs):
|
36 |
super(NLPCCConfig, self).__init__(**kwargs)
|
37 |
|
38 |
+
class NLPCCStance(datasets.GeneratorBasedBuilder):
|
39 |
+
"""The NLPCC Shared Task 4 dataset regarding Stance Detection in Chinese Microblogs (Task A)"""
|
40 |
|
41 |
VERSION = datasets.Version("1.0.0")
|
42 |
|
43 |
BUILDER_CONFIGS = [
|
44 |
+
NLPCCConfig(name="task_a", version=VERSION, description="Task A, the supervised learning task."),
|
|
|
45 |
]
|
46 |
|
47 |
def _info(self):
|
48 |
+
features = datasets.Features(
|
49 |
+
{
|
50 |
+
"id": datasets.Value("string"),
|
51 |
+
"target": datasets.Value("string"),
|
52 |
+
"text": datasets.Value("string"),
|
53 |
+
"stance": datasets.features.ClassLabel(
|
54 |
+
names=[
|
55 |
+
"AGAINST",
|
56 |
+
"FAVOR",
|
57 |
+
"NONE",
|
58 |
+
]
|
59 |
+
)
|
60 |
+
}
|
61 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
return datasets.DatasetInfo(
|
64 |
description=_DESCRIPTION,
|
|
|
69 |
)
|
70 |
|
71 |
def _split_generators(self, dl_manager):
|
72 |
+
train_text = dl_manager.download_and_extract("nlpcc_taska.csv")
|
73 |
+
test_text = dl_manager.download_and_extract("NLPCC2016_Stance_Detection_Task_A_Testdata.tsv")
|
|
|
|
|
|
|
|
|
74 |
return [
|
75 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text, "split": "train"}),
|
76 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_text, "split": "test"}),
|
|
|
80 |
with open(filepath, encoding="utf-8") as f:
|
81 |
reader = csv.DictReader(f, delimiter=",")
|
82 |
guid = 0
|
83 |
+
for instance in reader:
|
84 |
+
print(f"At iteration: {guid}")
|
85 |
+
instance["target"] = instance.pop("TARGET")
|
86 |
+
instance["text"] = instance.pop("TEXT")
|
87 |
+
instance["stance"] = instance.pop("STANCE")
|
88 |
+
instance['id'] = str(guid)
|
89 |
+
yield guid, instance
|
90 |
+
guid += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|