Datasets:
Tasks:
Text Classification
Modalities:
Text
Sub-tasks:
sentiment-analysis
Languages:
Chinese
Size:
1K - 10K
Tags:
stance-detection
License:
initial dataloader
Browse files
NLPCC2016_Stance_Detection_Task_A_Testdata.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bda780fb9ec241f8c2d3fdb2d0ccfe24bead13e36a9d41455db045aa279f6a34
|
3 |
+
size 3492261
|
NLPCC2016_Stance_Detection_Task_B_Testdata.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:69fede318c337d49e0fbbe277aa66d25d3e7ce5451f4b3d56d47ae5126ec8492
|
3 |
+
size 1850423
|
evasampledata4-TaskBR.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f8dd4a444ee3c20a7236a23ee3bb9490b052f1a4d9b337697593312ed9b19bfd
|
3 |
+
size 419068
|
nlpcc_stance.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2022 Mads Kongsbak and Leon Derczynski
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
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
|
18 |
+
import json
|
19 |
+
import os
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
|
23 |
+
_CITATION = """\
|
24 |
+
"""
|
25 |
+
|
26 |
+
_DESCRIPTION = """\
|
27 |
+
"""
|
28 |
+
|
29 |
+
_HOMEPAGE = ""
|
30 |
+
|
31 |
+
_LICENSE = "cc-by-4.0"
|
32 |
+
|
33 |
+
class NLPCCConfig(datasets.BuilderConfig):
|
34 |
+
|
35 |
+
def __init__(self, **kwargs):
|
36 |
+
super(NLPCCConfig, self).__init__(**kwargs)
|
37 |
+
|
38 |
+
class XStance(datasets.GeneratorBasedBuilder):
|
39 |
+
"""The x-stance dataset split into two datasets in German and French/Italian"""
|
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 |
+
if self.config.name == "task_a":
|
50 |
+
features = datasets.Features(
|
51 |
+
{
|
52 |
+
"id": datasets.Value("string"),
|
53 |
+
"target": datasets.Value("string"),
|
54 |
+
"text": datasets.Value("string"),
|
55 |
+
"stance": datasets.features.ClassLabel(
|
56 |
+
names=[
|
57 |
+
"AGAINST",
|
58 |
+
"FAVOR",
|
59 |
+
"NONE",
|
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,
|
75 |
+
features=features,
|
76 |
+
homepage=_HOMEPAGE,
|
77 |
+
license=_LICENSE,
|
78 |
+
citation=_CITATION,
|
79 |
+
)
|
80 |
+
|
81 |
+
def _split_generators(self, dl_manager):
|
82 |
+
if self.config.name == "task_a":
|
83 |
+
train_text = dl_manager.download_and_extract("evasampledata4-TaskAA.tsv")
|
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"}),
|
91 |
+
]
|
92 |
+
|
93 |
+
def _generate_examples(self, filepath, split):
|
94 |
+
with open(filepath, encoding="utf-8") as f:
|
95 |
+
reader = csv.DictReader(f, delimiter=",")
|
96 |
+
guid = 0
|
97 |
+
if self.config.name == "task_a":
|
98 |
+
for instance in reader:
|
99 |
+
instance["target"] = instance.pop("TARGET")
|
100 |
+
instance["text"] = instance.pop("TEXT")
|
101 |
+
instance["stance"] = instance.pop("STANCE")
|
102 |
+
instance['id'] = str(guid)
|
103 |
+
yield guid, instance
|
104 |
+
guid += 1
|
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 |
+
|