tyqiangz commited on
Commit
396e65e
1 Parent(s): e1f28bb

changed headers for Indonesian dataset

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. multilingual-sentiments.py +35 -8
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
multilingual-sentiments.py CHANGED
@@ -20,11 +20,10 @@ import textwrap
20
 
21
  import datasets
22
 
23
- LANGUAGES = [
24
- 'malay', 'hindi', 'japanese', 'german',
25
- 'italian', 'english', 'portuguese', 'french',
26
- 'spanish', 'chinese', 'indonesian', 'arabic'
27
- ]
28
 
29
 
30
  class MultilingualSentimentsConfig(datasets.BuilderConfig):
@@ -71,6 +70,26 @@ class MultilingualSentiments(datasets.GeneratorBasedBuilder):
71
 
72
  BUILDER_CONFIGS = []
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  for lang in LANGUAGES:
75
  BUILDER_CONFIGS.append(
76
  MultilingualSentimentsConfig(
@@ -127,7 +146,15 @@ class MultilingualSentiments(datasets.GeneratorBasedBuilder):
127
  next(reader, None) # skip the headers
128
 
129
  for id_, row in enumerate(reader):
130
- text = '\t'.join(row[:-1])
131
- label = row[-1]
 
 
 
 
 
 
 
 
132
 
133
- yield id_, {"text": text, "label": label}
 
20
 
21
  import datasets
22
 
23
+ LANGUAGES = ['malay', 'hindi', 'japanese', 'german',
24
+ 'italian', 'english', 'portuguese', 'french',
25
+ 'spanish', 'chinese', 'indonesian', 'arabic'
26
+ ]
 
27
 
28
 
29
  class MultilingualSentimentsConfig(datasets.BuilderConfig):
 
70
 
71
  BUILDER_CONFIGS = []
72
 
73
+ BUILDER_CONFIGS.append(
74
+ MultilingualSentimentsConfig(
75
+ name="all",
76
+ description=textwrap.dedent(
77
+ f"""\
78
+ All datasets."""
79
+ ),
80
+ text_features={"text": "text", "language": "language"},
81
+ label_classes=["positive", "neutral", "negative"],
82
+ label_column="label",
83
+ train_url=f"https://raw.githubusercontent.com/tyqiangz/multilingual-sentiment-datasets/main/data/all/train.tsv",
84
+ valid_url=f"https://raw.githubusercontent.com/tyqiangz/multilingual-sentiment-datasets/main/data/all/valid.tsv",
85
+ test_url=f"https://raw.githubusercontent.com/tyqiangz/multilingual-sentiment-datasets/main/data/all/test.tsv",
86
+ citation=textwrap.dedent(
87
+ f"""\
88
+ All citation"""
89
+ ),
90
+ ),
91
+ )
92
+
93
  for lang in LANGUAGES:
94
  BUILDER_CONFIGS.append(
95
  MultilingualSentimentsConfig(
 
146
  next(reader, None) # skip the headers
147
 
148
  for id_, row in enumerate(reader):
149
+ if self.config.name != "all":
150
+ text = '\t'.join(row[:-1])
151
+ label = row[-1]
152
+
153
+ yield id_, {"text": text, "label": label}
154
+
155
+ else:
156
+ text = '\t'.join(row[:-3])
157
+ label = row[-2]
158
+ language = row[-1]
159
 
160
+ yield id_, {"text": text, "label": label, "language": language}