holylovenia commited on
Commit
832fdcc
1 Parent(s): 8889c3d

Upload postag_su.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. postag_su.py +12 -16
postag_su.py CHANGED
@@ -19,9 +19,9 @@ from typing import Dict, List, Tuple
19
 
20
  import datasets
21
 
22
- from nusacrowd.utils import schemas
23
- from nusacrowd.utils.configs import NusantaraConfig
24
- from nusacrowd.utils.constants import Tasks
25
 
26
  _CITATION = """\
27
  @data{FK2/VTAHRH_2022,
@@ -68,14 +68,14 @@ _SUPPORTED_TASKS = [Tasks.POS_TAGGING]
68
 
69
  _SOURCE_VERSION = "1.1.0"
70
 
71
- _NUSANTARA_VERSION = "1.0.0"
72
 
73
 
74
  class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
75
  """PoSTagged Sundanese Monolingual Corpus"""
76
 
77
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
78
- NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
79
 
80
  # Based on Wicaksono, A. F., & Purwarianti, A. (2010). HMM Based Part-of-Speech Tagger for Bahasa Indonesia. On Proceedings of 4th International MALINDO (Malay and Indonesian Language) Workshop.
81
  POS_TAGS = [
@@ -164,18 +164,18 @@ class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
164
  ]
165
 
166
  BUILDER_CONFIGS = [
167
- NusantaraConfig(
168
  name=f"{_DATASETNAME}_source",
169
  version=SOURCE_VERSION,
170
  description=f"{_DATASETNAME} source schema",
171
  schema="source",
172
  subset_id=f"{_DATASETNAME}",
173
  ),
174
- NusantaraConfig(
175
- name=f"{_DATASETNAME}_nusantara_seq_label",
176
- version=NUSANTARA_VERSION,
177
  description=f"{_DATASETNAME} Nusantara Seq Label schema",
178
- schema="nusantara_seq_label",
179
  subset_id=f"{_DATASETNAME}",
180
  ),
181
  ]
@@ -186,7 +186,7 @@ class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
186
 
187
  if self.config.schema == "source":
188
  features = datasets.Features({"labeled_sentence": datasets.Value("string")})
189
- elif self.config.schema == "nusantara_seq_label":
190
  features = schemas.seq_label_features(self.POS_TAGS)
191
 
192
  else:
@@ -255,7 +255,7 @@ class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
255
  for key, example in enumerate(raw):
256
  yield key, {"labeled_sentence": example}
257
 
258
- elif self.config.schema == "nusantara_seq_label":
259
  spaced = list(map(__apply_regex, raw))
260
  data = list(map(lambda l: [__cleanse_label(tok.split("|", 1)) for tok in filter(None, l.split(" "))], spaced))
261
 
@@ -265,7 +265,3 @@ class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
265
 
266
  else:
267
  raise NotImplementedError(f"Schema '{self.config.schema}' is not defined.")
268
-
269
-
270
- if __name__ == "__main__":
271
- datasets.load_dataset(__file__)
 
19
 
20
  import datasets
21
 
22
+ from seacrowd.utils import schemas
23
+ from seacrowd.utils.configs import SEACrowdConfig
24
+ from seacrowd.utils.constants import Tasks
25
 
26
  _CITATION = """\
27
  @data{FK2/VTAHRH_2022,
 
68
 
69
  _SOURCE_VERSION = "1.1.0"
70
 
71
+ _SEACROWD_VERSION = "2024.06.20"
72
 
73
 
74
  class PosSunMonoDataset(datasets.GeneratorBasedBuilder):
75
  """PoSTagged Sundanese Monolingual Corpus"""
76
 
77
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
78
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
79
 
80
  # Based on Wicaksono, A. F., & Purwarianti, A. (2010). HMM Based Part-of-Speech Tagger for Bahasa Indonesia. On Proceedings of 4th International MALINDO (Malay and Indonesian Language) Workshop.
81
  POS_TAGS = [
 
164
  ]
165
 
166
  BUILDER_CONFIGS = [
167
+ SEACrowdConfig(
168
  name=f"{_DATASETNAME}_source",
169
  version=SOURCE_VERSION,
170
  description=f"{_DATASETNAME} source schema",
171
  schema="source",
172
  subset_id=f"{_DATASETNAME}",
173
  ),
174
+ SEACrowdConfig(
175
+ name=f"{_DATASETNAME}_seacrowd_seq_label",
176
+ version=SEACROWD_VERSION,
177
  description=f"{_DATASETNAME} Nusantara Seq Label schema",
178
+ schema="seacrowd_seq_label",
179
  subset_id=f"{_DATASETNAME}",
180
  ),
181
  ]
 
186
 
187
  if self.config.schema == "source":
188
  features = datasets.Features({"labeled_sentence": datasets.Value("string")})
189
+ elif self.config.schema == "seacrowd_seq_label":
190
  features = schemas.seq_label_features(self.POS_TAGS)
191
 
192
  else:
 
255
  for key, example in enumerate(raw):
256
  yield key, {"labeled_sentence": example}
257
 
258
+ elif self.config.schema == "seacrowd_seq_label":
259
  spaced = list(map(__apply_regex, raw))
260
  data = list(map(lambda l: [__cleanse_label(tok.split("|", 1)) for tok in filter(None, l.split(" "))], spaced))
261
 
 
265
 
266
  else:
267
  raise NotImplementedError(f"Schema '{self.config.schema}' is not defined.")