holylovenia commited on
Commit
2f95f9a
·
verified ·
1 Parent(s): 0e21724

Upload term_a.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. term_a.py +13 -13
term_a.py CHANGED
@@ -3,15 +3,15 @@ from typing import List
3
 
4
  import datasets
5
 
6
- from nusacrowd.utils import schemas
7
- from nusacrowd.utils.common_parser import load_conll_data
8
- from nusacrowd.utils.configs import NusantaraConfig
9
- from nusacrowd.utils.constants import (DEFAULT_NUSANTARA_VIEW_NAME,
10
  DEFAULT_SOURCE_VIEW_NAME, Tasks)
11
 
12
  _DATASETNAME = "term_a"
13
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
14
- _UNIFIED_VIEW_NAME = DEFAULT_NUSANTARA_VIEW_NAME
15
 
16
  _LANGUAGES = ["ind"]
17
  _LOCAL = False
@@ -54,7 +54,7 @@ _URLs = {
54
  _SUPPORTED_TASKS = [Tasks.KEYWORD_TAGGING]
55
 
56
  _SOURCE_VERSION = "1.0.0"
57
- _NUSANTARA_VERSION = "1.0.0"
58
 
59
 
60
  class BaPOSDataset(datasets.GeneratorBasedBuilder):
@@ -63,18 +63,18 @@ class BaPOSDataset(datasets.GeneratorBasedBuilder):
63
  label_classes = ["B-ASPECT", "I-ASPECT", "B-SENTIMENT", "I-SENTIMENT", "O"]
64
 
65
  BUILDER_CONFIGS = [
66
- NusantaraConfig(
67
  name="term_a_source",
68
  version=datasets.Version(_SOURCE_VERSION),
69
  description="TermA source schema",
70
  schema="source",
71
  subset_id="term_a",
72
  ),
73
- NusantaraConfig(
74
- name="term_a_nusantara_seq_label",
75
- version=datasets.Version(_NUSANTARA_VERSION),
76
  description="TermA Nusantara schema",
77
- schema="nusantara_seq_label",
78
  subset_id="term_a",
79
  ),
80
  ]
@@ -84,7 +84,7 @@ class BaPOSDataset(datasets.GeneratorBasedBuilder):
84
  def _info(self):
85
  if self.config.schema == "source":
86
  features = datasets.Features({"index": datasets.Value("string"), "tokens": [datasets.Value("string")], "token_tag": [datasets.Value("string")]})
87
- elif self.config.schema == "nusantara_seq_label":
88
  features = schemas.seq_label_features(self.label_classes)
89
 
90
  return datasets.DatasetInfo(
@@ -127,7 +127,7 @@ class BaPOSDataset(datasets.GeneratorBasedBuilder):
127
  for i, row in enumerate(conll_dataset):
128
  ex = {"index": str(i), "tokens": row["sentence"], "token_tag": row["label"]}
129
  yield i, ex
130
- elif self.config.schema == "nusantara_seq_label":
131
  for i, row in enumerate(conll_dataset):
132
  ex = {"id": str(i), "tokens": row["sentence"], "labels": row["label"]}
133
  yield i, ex
 
3
 
4
  import datasets
5
 
6
+ from seacrowd.utils import schemas
7
+ from seacrowd.utils.common_parser import load_conll_data
8
+ from seacrowd.utils.configs import SEACrowdConfig
9
+ from seacrowd.utils.constants import (DEFAULT_SEACROWD_VIEW_NAME,
10
  DEFAULT_SOURCE_VIEW_NAME, Tasks)
11
 
12
  _DATASETNAME = "term_a"
13
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
14
+ _UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
15
 
16
  _LANGUAGES = ["ind"]
17
  _LOCAL = False
 
54
  _SUPPORTED_TASKS = [Tasks.KEYWORD_TAGGING]
55
 
56
  _SOURCE_VERSION = "1.0.0"
57
+ _SEACROWD_VERSION = "2024.06.20"
58
 
59
 
60
  class BaPOSDataset(datasets.GeneratorBasedBuilder):
 
63
  label_classes = ["B-ASPECT", "I-ASPECT", "B-SENTIMENT", "I-SENTIMENT", "O"]
64
 
65
  BUILDER_CONFIGS = [
66
+ SEACrowdConfig(
67
  name="term_a_source",
68
  version=datasets.Version(_SOURCE_VERSION),
69
  description="TermA source schema",
70
  schema="source",
71
  subset_id="term_a",
72
  ),
73
+ SEACrowdConfig(
74
+ name="term_a_seacrowd_seq_label",
75
+ version=datasets.Version(_SEACROWD_VERSION),
76
  description="TermA Nusantara schema",
77
+ schema="seacrowd_seq_label",
78
  subset_id="term_a",
79
  ),
80
  ]
 
84
  def _info(self):
85
  if self.config.schema == "source":
86
  features = datasets.Features({"index": datasets.Value("string"), "tokens": [datasets.Value("string")], "token_tag": [datasets.Value("string")]})
87
+ elif self.config.schema == "seacrowd_seq_label":
88
  features = schemas.seq_label_features(self.label_classes)
89
 
90
  return datasets.DatasetInfo(
 
127
  for i, row in enumerate(conll_dataset):
128
  ex = {"index": str(i), "tokens": row["sentence"], "token_tag": row["label"]}
129
  yield i, ex
130
+ elif self.config.schema == "seacrowd_seq_label":
131
  for i, row in enumerate(conll_dataset):
132
  ex = {"id": str(i), "tokens": row["sentence"], "labels": row["label"]}
133
  yield i, ex