Datasets:
Add dataset loading script
Browse files- vietnamese_students_feedback.py +112 -0
vietnamese_students_feedback.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Vietnamese Students’ Feedback Corpus."""
|
16 |
+
|
17 |
+
import datasets
|
18 |
+
|
19 |
+
|
20 |
+
_CITATION = """\
|
21 |
+
@InProceedings{8573337,
|
22 |
+
author={Nguyen, Kiet Van and Nguyen, Vu Duc and Nguyen, Phu X. V. and Truong, Tham T. H. and Nguyen, Ngan Luu-Thuy},
|
23 |
+
booktitle={2018 10th International Conference on Knowledge and Systems Engineering (KSE)},
|
24 |
+
title={UIT-VSFC: Vietnamese Students’ Feedback Corpus for Sentiment Analysis},
|
25 |
+
year={2018},
|
26 |
+
volume={},
|
27 |
+
number={},
|
28 |
+
pages={19-24},
|
29 |
+
doi={10.1109/KSE.2018.8573337}
|
30 |
+
}
|
31 |
+
"""
|
32 |
+
|
33 |
+
_DESCRIPTION = """\
|
34 |
+
Students’ feedback is a vital resource for the interdisciplinary research involving the combining of two different
|
35 |
+
research fields between sentiment analysis and education.
|
36 |
+
|
37 |
+
Vietnamese Students’ Feedback Corpus (UIT-VSFC) is the resource consists of over 16,000 sentences which are
|
38 |
+
human-annotated with two different tasks: sentiment-based and topic-based classifications.
|
39 |
+
|
40 |
+
To assess the quality of our corpus, we measure the annotator agreements and classification evaluation on the
|
41 |
+
UIT-VSFC corpus. As a result, we obtained the inter-annotator agreement of sentiments and topics with more than over
|
42 |
+
91% and 71% respectively. In addition, we built the baseline model with the Maximum Entropy classifier and achieved
|
43 |
+
approximately 88% of the sentiment F1-score and over 84% of the topic F1-score.
|
44 |
+
"""
|
45 |
+
|
46 |
+
_HOMEPAGE = "https://sites.google.com/uit.edu.vn/uit-nlp/datasets-projects#h.p_4Brw8L-cbfTe"
|
47 |
+
|
48 |
+
# TODO: Add the licence for the dataset here if you can find it
|
49 |
+
# _LICENSE = ""
|
50 |
+
|
51 |
+
_URLS = {
|
52 |
+
datasets.Split.TRAIN: {
|
53 |
+
"sentences": "https://drive.google.com/uc?id=1nzak5OkrheRV1ltOGCXkT671bmjODLhP&export=download",
|
54 |
+
"sentiments": "https://drive.google.com/uc?id=1ye-gOZIBqXdKOoi_YxvpT6FeRNmViPPv&export=down load",
|
55 |
+
"topics": "https://drive.google.com/uc?id=14MuDtwMnNOcr4z_8KdpxprjbwaQ7lJ_C&export=download",
|
56 |
+
},
|
57 |
+
datasets.Split.VALIDATION: {
|
58 |
+
"sentences": "https://drive.google.com/uc?id=1sMJSR3oRfPc3fe1gK-V3W5F24tov_517&export=download",
|
59 |
+
"sentiments": "https://drive.google.com/uc?id=1GiY1AOp41dLXIIkgES4422AuDwmbUseL&export=download",
|
60 |
+
"topics": "https://drive.google.com/uc?id=1DwLgDEaFWQe8mOd7EpF-xqMEbDLfdT-W&export=download",
|
61 |
+
},
|
62 |
+
datasets.Split.TEST: {
|
63 |
+
"sentences": "https://drive.google.com/uc?id=1aNMOeZZbNwSRkjyCWAGtNCMa3YrshR-n&export=download",
|
64 |
+
"sentiments": "https://drive.google.com/uc?id=1vkQS5gI0is4ACU58-AbWusnemw7KZNfO&export=download",
|
65 |
+
"topics": "https://drive.google.com/uc?id=1_ArMpDguVsbUGl-xSMkTF_p5KpZrmpSB&export=download",
|
66 |
+
},
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
class VietnameseStudentsFeedback(datasets.GeneratorBasedBuilder):
|
71 |
+
"""Vietnamese Students’ Feedback Corpus."""
|
72 |
+
|
73 |
+
VERSION = datasets.Version("1.0.0")
|
74 |
+
|
75 |
+
def _info(self):
|
76 |
+
return datasets.DatasetInfo(
|
77 |
+
description=_DESCRIPTION,
|
78 |
+
features=datasets.Features(
|
79 |
+
{
|
80 |
+
"sentence": datasets.Value("string"),
|
81 |
+
"sentiment": datasets.ClassLabel(names=["negative", "neutral", "positive"]),
|
82 |
+
"topic": datasets.ClassLabel(names=["lecturer", "training_program", "facility", "others"]),
|
83 |
+
}
|
84 |
+
),
|
85 |
+
homepage=_HOMEPAGE,
|
86 |
+
# license=_LICENSE,
|
87 |
+
citation=_CITATION,
|
88 |
+
)
|
89 |
+
|
90 |
+
def _split_generators(self, dl_manager):
|
91 |
+
data_dir = dl_manager.download(_URLS)
|
92 |
+
return [
|
93 |
+
datasets.SplitGenerator(
|
94 |
+
name=split,
|
95 |
+
gen_kwargs={
|
96 |
+
"sentences_path": data_dir[split]["sentences"],
|
97 |
+
"sentiments_path": data_dir[split]["sentiments"],
|
98 |
+
"topics_path": data_dir[split]["topics"],
|
99 |
+
},
|
100 |
+
) for split in _URLS
|
101 |
+
]
|
102 |
+
|
103 |
+
def _generate_examples(self, sentences_path, sentiments_path, topics_path):
|
104 |
+
with open(sentences_path, encoding="utf-8") as sentences, open(
|
105 |
+
sentiments_path, encoding="utf-8"
|
106 |
+
) as sentiments, open(topics_path, encoding="utf-8") as topics:
|
107 |
+
for key, (sentence, sentiment, topic) in enumerate(zip(sentences, sentiments, topics)):
|
108 |
+
yield key, {
|
109 |
+
"sentence": sentence.strip(),
|
110 |
+
"sentiment": int(sentiment.strip()),
|
111 |
+
"topic": int(topic.strip()),
|
112 |
+
}
|