Upload smsa.py with huggingface_hub
Browse files
smsa.py
CHANGED
@@ -4,13 +4,13 @@ from typing import List
|
|
4 |
import datasets
|
5 |
import pandas as pd
|
6 |
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
|
11 |
_DATASETNAME = "smsa"
|
12 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
13 |
-
_UNIFIED_VIEW_NAME =
|
14 |
|
15 |
_LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
16 |
_LOCAL = False
|
@@ -53,25 +53,25 @@ _URLs = {
|
|
53 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
54 |
|
55 |
_SOURCE_VERSION = "1.0.0"
|
56 |
-
|
57 |
|
58 |
|
59 |
class SMSA(datasets.GeneratorBasedBuilder):
|
60 |
"""SMSA is a sentiment analysis dataset consisting of 3 labels (positive, neutral, and negative) which comes from comments and reviews collected from multiple online platforms."""
|
61 |
|
62 |
BUILDER_CONFIGS = [
|
63 |
-
|
64 |
name="smsa_source",
|
65 |
version=datasets.Version(_SOURCE_VERSION),
|
66 |
description="SMSA source schema",
|
67 |
schema="source",
|
68 |
subset_id="smsa",
|
69 |
),
|
70 |
-
|
71 |
-
name="
|
72 |
-
version=datasets.Version(
|
73 |
description="SMSA Nusantara schema",
|
74 |
-
schema="
|
75 |
subset_id="smsa",
|
76 |
),
|
77 |
]
|
@@ -81,7 +81,7 @@ class SMSA(datasets.GeneratorBasedBuilder):
|
|
81 |
def _info(self):
|
82 |
if self.config.schema == "source":
|
83 |
features = datasets.Features({"index": datasets.Value("string"), "sentence": datasets.Value("string"), "label": datasets.Value("string")})
|
84 |
-
elif self.config.schema == "
|
85 |
features = schemas.text_features(["negative", "neutral", "positive"])
|
86 |
|
87 |
return datasets.DatasetInfo(
|
@@ -125,7 +125,7 @@ class SMSA(datasets.GeneratorBasedBuilder):
|
|
125 |
for row in df.itertuples():
|
126 |
ex = {"index": str(row.id), "sentence": row.sentence, "label": row.label}
|
127 |
yield row.id, ex
|
128 |
-
elif self.config.schema == "
|
129 |
for row in df.itertuples():
|
130 |
ex = {
|
131 |
"id": str(row.id),
|
|
|
4 |
import datasets
|
5 |
import pandas as pd
|
6 |
|
7 |
+
from seacrowd.utils import schemas
|
8 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
9 |
+
from seacrowd.utils.constants import Tasks, DEFAULT_SOURCE_VIEW_NAME, DEFAULT_SEACROWD_VIEW_NAME
|
10 |
|
11 |
_DATASETNAME = "smsa"
|
12 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
13 |
+
_UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
|
14 |
|
15 |
_LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
|
16 |
_LOCAL = False
|
|
|
53 |
_SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS]
|
54 |
|
55 |
_SOURCE_VERSION = "1.0.0"
|
56 |
+
_SEACROWD_VERSION = "2024.06.20"
|
57 |
|
58 |
|
59 |
class SMSA(datasets.GeneratorBasedBuilder):
|
60 |
"""SMSA is a sentiment analysis dataset consisting of 3 labels (positive, neutral, and negative) which comes from comments and reviews collected from multiple online platforms."""
|
61 |
|
62 |
BUILDER_CONFIGS = [
|
63 |
+
SEACrowdConfig(
|
64 |
name="smsa_source",
|
65 |
version=datasets.Version(_SOURCE_VERSION),
|
66 |
description="SMSA source schema",
|
67 |
schema="source",
|
68 |
subset_id="smsa",
|
69 |
),
|
70 |
+
SEACrowdConfig(
|
71 |
+
name="smsa_seacrowd_text",
|
72 |
+
version=datasets.Version(_SEACROWD_VERSION),
|
73 |
description="SMSA Nusantara schema",
|
74 |
+
schema="seacrowd_text",
|
75 |
subset_id="smsa",
|
76 |
),
|
77 |
]
|
|
|
81 |
def _info(self):
|
82 |
if self.config.schema == "source":
|
83 |
features = datasets.Features({"index": datasets.Value("string"), "sentence": datasets.Value("string"), "label": datasets.Value("string")})
|
84 |
+
elif self.config.schema == "seacrowd_text":
|
85 |
features = schemas.text_features(["negative", "neutral", "positive"])
|
86 |
|
87 |
return datasets.DatasetInfo(
|
|
|
125 |
for row in df.itertuples():
|
126 |
ex = {"index": str(row.id), "sentence": row.sentence, "label": row.label}
|
127 |
yield row.id, ex
|
128 |
+
elif self.config.schema == "seacrowd_text":
|
129 |
for row in df.itertuples():
|
130 |
ex = {
|
131 |
"id": str(row.id),
|