thanakritbright commited on
Commit
1e646b0
·
verified ·
1 Parent(s): a64fd2f

Create test

Browse files
Files changed (1) hide show
  1. test +118 -0
test ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Args:
57
+ **kwargs: keyword arguments forwarded to super.
58
+ """
59
+ super(WisesightSentimentConfig, self).__init__(**kwargs)
60
+
61
+
62
+ class WisesightSentiment(datasets.GeneratorBasedBuilder):
63
+ """Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)"""
64
+
65
+ _DOWNLOAD_URL = "https://github.com/PyThaiNLP/wisesight-sentiment/raw/master/huggingface/data.zip"
66
+ _TRAIN_FILE = "train.jsonl"
67
+ _VAL_FILE = "valid.jsonl"
68
+ _TEST_FILE = "test.jsonl"
69
+
70
+ BUILDER_CONFIGS = [
71
+ WisesightSentimentConfig(
72
+ name="wisesight_sentiment",
73
+ version=datasets.Version("1.0.0"),
74
+ description="Wisesight Sentiment Corpus: Social media messages in Thai language with sentiment category (positive, neutral, negative, question)",
75
+ ),
76
+ ]
77
+
78
+ def _info(self):
79
+ return datasets.DatasetInfo(
80
+ description=_DESCRIPTION,
81
+ features=datasets.Features(
82
+ {
83
+ "texts": datasets.Value("string"),
84
+ "category": datasets.features.ClassLabel(names=["pos", "neu", "neg", "q"]),
85
+ }
86
+ ),
87
+ supervised_keys=None,
88
+ homepage="https://github.com/PyThaiNLP/wisesight-sentiment",
89
+ citation=_CITATION,
90
+ task_templates=[TextClassification(text_column="texts", label_column="category")],
91
+ )
92
+
93
+ def _split_generators(self, dl_manager):
94
+ arch_path = dl_manager.download_and_extract(self._DOWNLOAD_URL)
95
+ data_dir = os.path.join(arch_path, "data")
96
+ return [
97
+ datasets.SplitGenerator(
98
+ name=datasets.Split.TRAIN,
99
+ gen_kwargs={"filepath": os.path.join(data_dir, self._TRAIN_FILE)},
100
+ ),
101
+ datasets.SplitGenerator(
102
+ name=datasets.Split.VALIDATION,
103
+ gen_kwargs={"filepath": os.path.join(data_dir, self._VAL_FILE)},
104
+ ),
105
+ datasets.SplitGenerator(
106
+ name=datasets.Split.TEST,
107
+ gen_kwargs={"filepath": os.path.join(data_dir, self._TEST_FILE)},
108
+ ),
109
+ ]
110
+
111
+ def _generate_examples(self, filepath):
112
+ """Generate WisesightSentiment examples."""
113
+ with open(filepath, encoding="utf-8") as f:
114
+ for id_, row in enumerate(f):
115
+ data = json.loads(row)
116
+ texts = data["texts"]
117
+ category = data["category"]
118
+ yield id_, {"texts": texts, "category": category}