Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Thai
Size:
10K - 100K
License:
Commit
•
27a383a
1
Parent(s):
dc9080a
Delete loading script
Browse files- wisesight_sentiment.py +0 -119
wisesight_sentiment.py
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
"""Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)"""
|
2 |
-
|
3 |
-
|
4 |
-
import json
|
5 |
-
import os
|
6 |
-
|
7 |
-
import datasets
|
8 |
-
from datasets.tasks import TextClassification
|
9 |
-
|
10 |
-
|
11 |
-
_CITATION = """\
|
12 |
-
@software{bact_2019_3457447,
|
13 |
-
author = {Suriyawongkul, Arthit and
|
14 |
-
Chuangsuwanich, Ekapol and
|
15 |
-
Chormai, Pattarawat and
|
16 |
-
Polpanumas, Charin},
|
17 |
-
title = {PyThaiNLP/wisesight-sentiment: First release},
|
18 |
-
month = sep,
|
19 |
-
year = 2019,
|
20 |
-
publisher = {Zenodo},
|
21 |
-
version = {v1.0},
|
22 |
-
doi = {10.5281/zenodo.3457447},
|
23 |
-
url = {https://doi.org/10.5281/zenodo.3457447}
|
24 |
-
}
|
25 |
-
"""
|
26 |
-
|
27 |
-
_DESCRIPTION = """\
|
28 |
-
Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)
|
29 |
-
* Released to public domain under Creative Commons Zero v1.0 Universal license.
|
30 |
-
* Category (Labels): {"pos": 0, "neu": 1, "neg": 2, "q": 3}
|
31 |
-
* Size: 26,737 messages
|
32 |
-
* Language: Central Thai
|
33 |
-
* Style: Informal and conversational. With some news headlines and advertisement.
|
34 |
-
* Time period: Around 2016 to early 2019. With small amount from other period.
|
35 |
-
* Domains: Mixed. Majority are consumer products and services (restaurants, cosmetics, drinks, car, hotels), with some current affairs.
|
36 |
-
* Privacy:
|
37 |
-
* Only messages that made available to the public on the internet (websites, blogs, social network sites).
|
38 |
-
* For Facebook, this means the public comments (everyone can see) that made on a public page.
|
39 |
-
* Private/protected messages and messages in groups, chat, and inbox are not included.
|
40 |
-
* Alternations and modifications:
|
41 |
-
* Keep in mind that this corpus does not statistically represent anything in the language register.
|
42 |
-
* Large amount of messages are not in their original form. Personal data are removed or masked.
|
43 |
-
* Duplicated, leading, and trailing whitespaces are removed. Other punctuations, symbols, and emojis are kept intact.
|
44 |
-
(Mis)spellings are kept intact.
|
45 |
-
* Messages longer than 2,000 characters are removed.
|
46 |
-
* Long non-Thai messages are removed. Duplicated message (exact match) are removed.
|
47 |
-
* More characteristics of the data can be explore: https://github.com/PyThaiNLP/wisesight-sentiment/blob/master/exploration.ipynb
|
48 |
-
"""
|
49 |
-
|
50 |
-
|
51 |
-
class WisesightSentimentConfig(datasets.BuilderConfig):
|
52 |
-
"""BuilderConfig for WisesightSentiment."""
|
53 |
-
|
54 |
-
def __init__(self, **kwargs):
|
55 |
-
"""BuilderConfig for WisesightSentiment.
|
56 |
-
|
57 |
-
Args:
|
58 |
-
**kwargs: keyword arguments forwarded to super.
|
59 |
-
"""
|
60 |
-
super(WisesightSentimentConfig, self).__init__(**kwargs)
|
61 |
-
|
62 |
-
|
63 |
-
class WisesightSentiment(datasets.GeneratorBasedBuilder):
|
64 |
-
"""Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)"""
|
65 |
-
|
66 |
-
_DOWNLOAD_URL = "https://github.com/PyThaiNLP/wisesight-sentiment/raw/master/huggingface/data.zip"
|
67 |
-
_TRAIN_FILE = "train.jsonl"
|
68 |
-
_VAL_FILE = "valid.jsonl"
|
69 |
-
_TEST_FILE = "test.jsonl"
|
70 |
-
|
71 |
-
BUILDER_CONFIGS = [
|
72 |
-
WisesightSentimentConfig(
|
73 |
-
name="wisesight_sentiment",
|
74 |
-
version=datasets.Version("1.0.0"),
|
75 |
-
description="Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)",
|
76 |
-
),
|
77 |
-
]
|
78 |
-
|
79 |
-
def _info(self):
|
80 |
-
return datasets.DatasetInfo(
|
81 |
-
description=_DESCRIPTION,
|
82 |
-
features=datasets.Features(
|
83 |
-
{
|
84 |
-
"texts": datasets.Value("string"),
|
85 |
-
"category": datasets.features.ClassLabel(names=["pos", "neu", "neg", "q"]),
|
86 |
-
}
|
87 |
-
),
|
88 |
-
supervised_keys=None,
|
89 |
-
homepage="https://github.com/PyThaiNLP/wisesight-sentiment",
|
90 |
-
citation=_CITATION,
|
91 |
-
task_templates=[TextClassification(text_column="texts", label_column="category")],
|
92 |
-
)
|
93 |
-
|
94 |
-
def _split_generators(self, dl_manager):
|
95 |
-
arch_path = dl_manager.download_and_extract(self._DOWNLOAD_URL)
|
96 |
-
data_dir = os.path.join(arch_path, "data")
|
97 |
-
return [
|
98 |
-
datasets.SplitGenerator(
|
99 |
-
name=datasets.Split.TRAIN,
|
100 |
-
gen_kwargs={"filepath": os.path.join(data_dir, self._TRAIN_FILE)},
|
101 |
-
),
|
102 |
-
datasets.SplitGenerator(
|
103 |
-
name=datasets.Split.VALIDATION,
|
104 |
-
gen_kwargs={"filepath": os.path.join(data_dir, self._VAL_FILE)},
|
105 |
-
),
|
106 |
-
datasets.SplitGenerator(
|
107 |
-
name=datasets.Split.TEST,
|
108 |
-
gen_kwargs={"filepath": os.path.join(data_dir, self._TEST_FILE)},
|
109 |
-
),
|
110 |
-
]
|
111 |
-
|
112 |
-
def _generate_examples(self, filepath):
|
113 |
-
"""Generate WisesightSentiment examples."""
|
114 |
-
with open(filepath, encoding="utf-8") as f:
|
115 |
-
for id_, row in enumerate(f):
|
116 |
-
data = json.loads(row)
|
117 |
-
texts = data["texts"]
|
118 |
-
category = data["category"]
|
119 |
-
yield id_, {"texts": texts, "category": category}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|