Datasets:
Tasks:
Text Classification
Modalities:
Text
Sub-tasks:
sentiment-classification
Languages:
Javanese
Size:
100K - 1M
License:
First version of imdb-javanese.
Browse files- imdb-javanese.py +87 -0
imdb-javanese.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Javanese IMDB movie reviews dataset."""
|
2 |
+
|
3 |
+
from __future__ import absolute_import, division, print_function
|
4 |
+
|
5 |
+
import csv
|
6 |
+
import os
|
7 |
+
|
8 |
+
import datasets
|
9 |
+
|
10 |
+
|
11 |
+
_CITATION = """\
|
12 |
+
@InProceedings{maas-EtAl:2011:ACL-HLT2011,
|
13 |
+
author = {Maas, Andrew L. and Daly, Raymond E. and Pham, Peter T. and Huang, Dan and Ng, Andrew Y. and Potts, Christopher},
|
14 |
+
title = {Learning Word Vectors for Sentiment Analysis},
|
15 |
+
booktitle = {Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies},
|
16 |
+
month = {June},
|
17 |
+
year = {2011},
|
18 |
+
address = {Portland, Oregon, USA},
|
19 |
+
publisher = {Association for Computational Linguistics},
|
20 |
+
pages = {142--150},
|
21 |
+
url = {http://www.aclweb.org/anthology/P11-1015}
|
22 |
+
}
|
23 |
+
"""
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
Large Movie Review Dataset translated to Javanese.
|
27 |
+
This is a dataset for binary sentiment classification containing substantially \
|
28 |
+
more data than previous benchmark datasets. We provide a set of 25,000 highly \
|
29 |
+
polar movie reviews for training, and 25,000 for testing. There is additional \
|
30 |
+
unlabeled data for use as well. We translated the original IMDB Dataset to \
|
31 |
+
Javanese using the multi-lingual MarianMT Transformer model from \
|
32 |
+
`Helsinki-NLP/opus-mt-en-mul`.
|
33 |
+
"""
|
34 |
+
|
35 |
+
_URL = "https://github.com/w11wo/javanese-nlp/blob/main/imdb-javanese/javanese_imdb_csv.zip?raw=true"
|
36 |
+
|
37 |
+
_HOMEPAGE = "https://github.com/w11wo/javanese-nlp"
|
38 |
+
|
39 |
+
|
40 |
+
class JavaneseImdbReviews(datasets.GeneratorBasedBuilder):
|
41 |
+
VERSION = datasets.Version("1.0.0")
|
42 |
+
|
43 |
+
def _info(self):
|
44 |
+
return datasets.DatasetInfo(
|
45 |
+
description=_DESCRIPTION,
|
46 |
+
features=datasets.Features(
|
47 |
+
{
|
48 |
+
"text": datasets.Value("string"),
|
49 |
+
"label": datasets.ClassLabel(names=["0", "1", "-1"]),
|
50 |
+
}
|
51 |
+
),
|
52 |
+
citation=_CITATION,
|
53 |
+
homepage=_HOMEPAGE,
|
54 |
+
)
|
55 |
+
|
56 |
+
def _split_generators(self, dl_manager):
|
57 |
+
"""Returns SplitGenerators."""
|
58 |
+
dl_path = dl_manager.download_and_extract(_URL)
|
59 |
+
return [
|
60 |
+
datasets.SplitGenerator(
|
61 |
+
name=datasets.Split.TRAIN,
|
62 |
+
gen_kwargs={
|
63 |
+
"filepath": os.path.join(dl_path, "javanese_imdb_train.csv")
|
64 |
+
},
|
65 |
+
),
|
66 |
+
datasets.SplitGenerator(
|
67 |
+
name=datasets.Split.TEST,
|
68 |
+
gen_kwargs={
|
69 |
+
"filepath": os.path.join(dl_path, "javanese_imdb_test.csv")
|
70 |
+
},
|
71 |
+
),
|
72 |
+
datasets.SplitGenerator(
|
73 |
+
name=datasets.Split("unsupervised"),
|
74 |
+
gen_kwargs={
|
75 |
+
"filepath": os.path.join(dl_path, "javanese_imdb_unsup.csv")
|
76 |
+
},
|
77 |
+
),
|
78 |
+
]
|
79 |
+
|
80 |
+
def _generate_examples(self, filepath):
|
81 |
+
"""Yields examples."""
|
82 |
+
with open(filepath, encoding="utf-8") as f:
|
83 |
+
reader = csv.reader(f, delimiter=",")
|
84 |
+
for id_, row in enumerate(reader):
|
85 |
+
if id_ == 0:
|
86 |
+
continue
|
87 |
+
yield id_, {"label": row[0], "text": row[1]}
|