Upload code_mixed_jv_id.py with huggingface_hub
Browse files- code_mixed_jv_id.py +26 -29
code_mixed_jv_id.py
CHANGED
|
@@ -36,7 +36,7 @@ showed that the reason for the misclassified was that most of Indonesian
|
|
| 36 |
language and Javanese language consist of words that were considered as
|
| 37 |
positive in both Lexicon model.
|
| 38 |
|
| 39 |
-
[
|
| 40 |
"""
|
| 41 |
from pathlib import Path
|
| 42 |
from typing import Dict, List, Tuple
|
|
@@ -44,9 +44,9 @@ from typing import Dict, List, Tuple
|
|
| 44 |
import datasets
|
| 45 |
import pandas as pd
|
| 46 |
|
| 47 |
-
from
|
| 48 |
-
from
|
| 49 |
-
from
|
| 50 |
|
| 51 |
_CITATION = """\
|
| 52 |
@article{Tho_2021,
|
|
@@ -100,7 +100,7 @@ _SUPPORTED_TASKS = [Tasks.SENTIMENT_ANALYSIS, Tasks.MACHINE_TRANSLATION]
|
|
| 100 |
|
| 101 |
_SOURCE_VERSION = "1.0.0"
|
| 102 |
|
| 103 |
-
|
| 104 |
|
| 105 |
_LANGUAGES = ['jav', 'ind']
|
| 106 |
_LOCAL = False
|
|
@@ -115,35 +115,35 @@ class CodeMixedSenti(datasets.GeneratorBasedBuilder):
|
|
| 115 |
"""Code-mixed sentiment analysis for Indonesian and Javanese."""
|
| 116 |
|
| 117 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 118 |
-
|
| 119 |
|
| 120 |
BUILDER_CONFIGS = [
|
| 121 |
-
|
| 122 |
name="code_mixed_jv_id_source",
|
| 123 |
version=SOURCE_VERSION,
|
| 124 |
description="code_mixed_jv_id source schema for Javanese and Indonesian",
|
| 125 |
schema="source",
|
| 126 |
subset_id="code_mixed_source",
|
| 127 |
),
|
| 128 |
-
|
| 129 |
-
name="
|
| 130 |
-
version=
|
| 131 |
-
description="code_mixed_jv_id
|
| 132 |
-
schema="
|
| 133 |
subset_id="code_mixed_jv",
|
| 134 |
),
|
| 135 |
-
|
| 136 |
-
name="
|
| 137 |
-
version=
|
| 138 |
-
description="code_mixed_jv_id
|
| 139 |
-
schema="
|
| 140 |
subset_id="code_mixed_id",
|
| 141 |
),
|
| 142 |
-
|
| 143 |
-
name="
|
| 144 |
-
version=
|
| 145 |
-
description="code_mixed_jv_id
|
| 146 |
-
schema="
|
| 147 |
subset_id="code_mixed_jv_id",
|
| 148 |
)
|
| 149 |
]
|
|
@@ -157,9 +157,9 @@ class CodeMixedSenti(datasets.GeneratorBasedBuilder):
|
|
| 157 |
"text_ind": datasets.Value("string"),
|
| 158 |
"label": datasets.Value("int32")
|
| 159 |
})
|
| 160 |
-
elif self.config.schema == "
|
| 161 |
features = schemas.text_features(["-1", "0", "1"])
|
| 162 |
-
elif self.config.schema == "
|
| 163 |
features = schemas.text2text_features
|
| 164 |
|
| 165 |
return datasets.DatasetInfo(description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION,)
|
|
@@ -182,7 +182,7 @@ class CodeMixedSenti(datasets.GeneratorBasedBuilder):
|
|
| 182 |
ex = {"text_jav": row.text_jav, "text_ind": row.text_ind, "label": row.label}
|
| 183 |
yield i, ex
|
| 184 |
i += 1
|
| 185 |
-
elif self.config.schema == "
|
| 186 |
prefix_length = len(_DATASETNAME)
|
| 187 |
start = prefix_length + 1
|
| 188 |
end = prefix_length + 1 + 2
|
|
@@ -194,12 +194,9 @@ class CodeMixedSenti(datasets.GeneratorBasedBuilder):
|
|
| 194 |
ex = {"id": str(i), "text": row.text, "label": str(row.label)}
|
| 195 |
yield i, ex
|
| 196 |
i += 1
|
| 197 |
-
elif self.config.schema == "
|
| 198 |
i = 0
|
| 199 |
for row in df.itertuples():
|
| 200 |
ex = {"id": str(i), "text_1": row.text_jav, "text_2": row.text_ind, "text_1_name": "jav", "text_2_name": "ind"}
|
| 201 |
yield i, ex
|
| 202 |
i += 1
|
| 203 |
-
|
| 204 |
-
if __name__ == "__main__":
|
| 205 |
-
datasets.load_dataset(__file__)
|
|
|
|
| 36 |
language and Javanese language consist of words that were considered as
|
| 37 |
positive in both Lexicon model.
|
| 38 |
|
| 39 |
+
[seacrowd_schema_name] = (text, t2t)
|
| 40 |
"""
|
| 41 |
from pathlib import Path
|
| 42 |
from typing import Dict, List, Tuple
|
|
|
|
| 44 |
import datasets
|
| 45 |
import pandas as pd
|
| 46 |
|
| 47 |
+
from seacrowd.utils import schemas
|
| 48 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
| 49 |
+
from seacrowd.utils.constants import Tasks
|
| 50 |
|
| 51 |
_CITATION = """\
|
| 52 |
@article{Tho_2021,
|
|
|
|
| 100 |
|
| 101 |
_SOURCE_VERSION = "1.0.0"
|
| 102 |
|
| 103 |
+
_SEACROWD_VERSION = "2024.06.20"
|
| 104 |
|
| 105 |
_LANGUAGES = ['jav', 'ind']
|
| 106 |
_LOCAL = False
|
|
|
|
| 115 |
"""Code-mixed sentiment analysis for Indonesian and Javanese."""
|
| 116 |
|
| 117 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 118 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
| 119 |
|
| 120 |
BUILDER_CONFIGS = [
|
| 121 |
+
SEACrowdConfig(
|
| 122 |
name="code_mixed_jv_id_source",
|
| 123 |
version=SOURCE_VERSION,
|
| 124 |
description="code_mixed_jv_id source schema for Javanese and Indonesian",
|
| 125 |
schema="source",
|
| 126 |
subset_id="code_mixed_source",
|
| 127 |
),
|
| 128 |
+
SEACrowdConfig(
|
| 129 |
+
name="code_mixed_jv_id_jv_seacrowd_text",
|
| 130 |
+
version=SEACROWD_VERSION,
|
| 131 |
+
description="code_mixed_jv_id seacrowd_text schema for Javanese",
|
| 132 |
+
schema="seacrowd_text",
|
| 133 |
subset_id="code_mixed_jv",
|
| 134 |
),
|
| 135 |
+
SEACrowdConfig(
|
| 136 |
+
name="code_mixed_jv_id_id_seacrowd_text",
|
| 137 |
+
version=SEACROWD_VERSION,
|
| 138 |
+
description="code_mixed_jv_id seacrowd_text schema for Indonesian",
|
| 139 |
+
schema="seacrowd_text",
|
| 140 |
subset_id="code_mixed_id",
|
| 141 |
),
|
| 142 |
+
SEACrowdConfig(
|
| 143 |
+
name="code_mixed_jv_id_seacrowd_t2t",
|
| 144 |
+
version=SEACROWD_VERSION,
|
| 145 |
+
description="code_mixed_jv_id seacrowd_t2t schema for Javanese and Indonesian",
|
| 146 |
+
schema="seacrowd_t2t",
|
| 147 |
subset_id="code_mixed_jv_id",
|
| 148 |
)
|
| 149 |
]
|
|
|
|
| 157 |
"text_ind": datasets.Value("string"),
|
| 158 |
"label": datasets.Value("int32")
|
| 159 |
})
|
| 160 |
+
elif self.config.schema == "seacrowd_text":
|
| 161 |
features = schemas.text_features(["-1", "0", "1"])
|
| 162 |
+
elif self.config.schema == "seacrowd_t2t":
|
| 163 |
features = schemas.text2text_features
|
| 164 |
|
| 165 |
return datasets.DatasetInfo(description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION,)
|
|
|
|
| 182 |
ex = {"text_jav": row.text_jav, "text_ind": row.text_ind, "label": row.label}
|
| 183 |
yield i, ex
|
| 184 |
i += 1
|
| 185 |
+
elif self.config.schema == "seacrowd_text":
|
| 186 |
prefix_length = len(_DATASETNAME)
|
| 187 |
start = prefix_length + 1
|
| 188 |
end = prefix_length + 1 + 2
|
|
|
|
| 194 |
ex = {"id": str(i), "text": row.text, "label": str(row.label)}
|
| 195 |
yield i, ex
|
| 196 |
i += 1
|
| 197 |
+
elif self.config.schema == "seacrowd_t2t":
|
| 198 |
i = 0
|
| 199 |
for row in df.itertuples():
|
| 200 |
ex = {"id": str(i), "text_1": row.text_jav, "text_2": row.text_ind, "text_1_name": "jav", "text_2_name": "ind"}
|
| 201 |
yield i, ex
|
| 202 |
i += 1
|
|
|
|
|
|
|
|
|