gsarti commited on
Commit
e958fd0
1 Parent(s): dc0b718

Update magpie.py

Browse files
Files changed (1) hide show
  1. magpie.py +4 -20
magpie.py CHANGED
@@ -72,12 +72,6 @@ class Magpie(datasets.GeneratorBasedBuilder):
72
  version=datasets.Version("1.0.0"),
73
  features=["sentence", "annotation", "idiom", "usage", "variant", "pos_tags"],
74
  data_url="https://huggingface.co/datasets/gsarti/magpie/resolve/main/magpie.tsv"
75
- ),
76
- MagpieConfig(
77
- name="keywords",
78
- version=datasets.Version("1.0.0"),
79
- features=["idiom", "contains_noun", "pos_tags", "nouns"],
80
- data_url="https://huggingface.co/datasets/gsarti/magpie/resolve/main/keywords.tsv"
81
  )
82
  ]
83
 
@@ -85,13 +79,8 @@ class Magpie(datasets.GeneratorBasedBuilder):
85
 
86
  def _info(self):
87
  features = {feature: datasets.Value("string") for feature in self.config.features}
88
- if self.config.name == "magpie":
89
- features["annotation"] = datasets.features.Sequence(datasets.Value("uint8"))
90
- features["pos_tags"] = datasets.features.Sequence(datasets.Value("string"))
91
- else:
92
- features["contains_noun"] = datasets.Value("bool")
93
- features["nouns"] = datasets.features.Sequence(datasets.Value("string"))
94
- features["pos_tags"] = datasets.Value("string")
95
  return datasets.DatasetInfo(
96
  description=_DESCRIPTION,
97
  features=datasets.Features(features),
@@ -120,13 +109,8 @@ class Magpie(datasets.GeneratorBasedBuilder):
120
  if id_ == 0:
121
  continue
122
  fields = row.strip().split("\t")
123
- if len(fields) < 5:
124
- fields[1] = True if fields[1] == "yes" else False
125
- fields[2] = fields[2].strip().split()
126
- fields[3] = fields[3].strip().split() if fields[1] else []
127
- else:
128
- fields[1] = fields[1].strip().split()
129
- fields[-1] = fields[-1].strip().split()
130
  yield id_, {
131
  k:v for k,v in zip(features, fields)
132
  }
 
72
  version=datasets.Version("1.0.0"),
73
  features=["sentence", "annotation", "idiom", "usage", "variant", "pos_tags"],
74
  data_url="https://huggingface.co/datasets/gsarti/magpie/resolve/main/magpie.tsv"
 
 
 
 
 
 
75
  )
76
  ]
77
 
 
79
 
80
  def _info(self):
81
  features = {feature: datasets.Value("string") for feature in self.config.features}
82
+ features["annotation"] = datasets.features.Sequence(datasets.Value("uint8"))
83
+ features["pos_tags"] = datasets.features.Sequence(datasets.Value("string"))
 
 
 
 
 
84
  return datasets.DatasetInfo(
85
  description=_DESCRIPTION,
86
  features=datasets.Features(features),
 
109
  if id_ == 0:
110
  continue
111
  fields = row.strip().split("\t")
112
+ fields[1] = fields[1].strip().split()
113
+ fields[-1] = fields[-1].strip().split()
 
 
 
 
 
114
  yield id_, {
115
  k:v for k,v in zip(features, fields)
116
  }