ramybaly commited on
Commit
774debe
·
1 Parent(s): 8762e84

fixed bug in dataset script

Browse files
Files changed (2) hide show
  1. id2fine_tags.json +2 -2
  2. nerd.py +78 -81
id2fine_tags.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:81dab34fb7c5ce53d9d16ae4fc3a76e472596bb018c7d860a7bbc051f3276e3f
3
- size 1777
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64604b88e4f94fb8d729e428302915704a04b8317c84802ae188ea41a97faaf6
3
+ size 1748
nerd.py CHANGED
@@ -73,79 +73,79 @@ class NERD(datasets.GeneratorBasedBuilder):
73
  names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
74
  )
75
  ),
76
- # "ner_tags_fine": datasets.Sequence(
77
- # datasets.features.ClassLabel(
78
- # names=[
79
- # 'O',
80
- # 'I-art-broadcastprogram',
81
- # 'I-art-film',
82
- # 'I-art-music',
83
- # 'I-art-other',
84
- # 'I-art-painting',
85
- # 'I-art-writtenart',
86
- # 'I-building-airport',
87
- # 'I-building-hospital',
88
- # 'I-building-hotel',
89
- # 'I-building-library',
90
- # 'I-building-other',
91
- # 'I-building-restaurant',
92
- # 'I-building-sportsfacility',
93
- # 'I-building-theater',
94
- # 'I-event-attack/battle/war/militaryconflict',
95
- # 'I-event-disaster',
96
- # 'I-event-election',
97
- # 'I-event-other',
98
- # 'I-event-protest',
99
- # 'I-event-sportsevent',
100
- # 'I-location-GPE',
101
- # 'I-location-bodiesofwater',
102
- # 'I-location-island',
103
- # 'I-location-mountain',
104
- # 'I-location-other',
105
- # 'I-location-park',
106
- # 'I-location-road/railway/highway/transit',
107
- # 'I-organization-company',
108
- # 'I-organization-education',
109
- # 'I-organization-government/governmentagency',
110
- # 'I-organization-media/newspaper',
111
- # 'I-organization-other',
112
- # 'I-organization-politicalparty',
113
- # 'I-organization-religion',
114
- # 'I-organization-showorganization',
115
- # 'I-organization-sportsleague',
116
- # 'I-organization-sportsteam',
117
- # 'I-other-astronomything',
118
- # 'I-other-award',
119
- # 'I-other-biologything',
120
- # 'I-other-chemicalthing',
121
- # 'I-other-currency',
122
- # 'I-other-disease',
123
- # 'I-other-educationaldegree',
124
- # 'I-other-god',
125
- # 'I-other-language',
126
- # 'I-other-law',
127
- # 'I-other-livingthing',
128
- # 'I-other-medical',
129
- # 'I-person-actor',
130
- # 'I-person-artist/author',
131
- # 'I-person-athlete',
132
- # 'I-person-director',
133
- # 'I-person-other',
134
- # 'I-person-politician',
135
- # 'I-person-scholar',
136
- # 'I-person-soldier',
137
- # 'I-product-airplane',
138
- # 'I-product-car',
139
- # 'I-product-food',
140
- # 'I-product-game',
141
- # 'I-product-other',
142
- # 'I-product-ship',
143
- # 'I-product-software',
144
- # 'I-product-train',
145
- # 'I-product-weapon'
146
- # ]
147
- # )
148
- # ),
149
  }
150
  ),
151
  supervised_keys=None,
@@ -156,9 +156,6 @@ class NERD(datasets.GeneratorBasedBuilder):
156
  def _split_generators(self, dl_manager):
157
  """Returns SplitGenerators."""
158
  urls_to_download = {
159
- # "train": f"{_URL}{_TRAINING_FILE}",
160
- # "validation": f"{_URL}{_DEV_FILE}",
161
- # "test": f"{_URL}{_TEST_FILE}",
162
  'train': 'train.txt',
163
  'validation': 'validation.txt',
164
  'test': 'test.txt',
@@ -180,7 +177,7 @@ class NERD(datasets.GeneratorBasedBuilder):
180
  guid = 0
181
  tokens = []
182
  ner_tags = []
183
- # ner_tags_fine = []
184
 
185
  for line in lines:
186
  if line.startswith("-DOCSTART-") or line.strip() == "" or line == "\n":
@@ -189,22 +186,22 @@ class NERD(datasets.GeneratorBasedBuilder):
189
  "id": str(guid),
190
  "tokens": tokens,
191
  "ner_tags": ner_tags,
192
- # "ner_tags_fine": ner_tags_fine,
193
  }
194
  guid += 1
195
  tokens = []
196
  ner_tags = []
197
- # ner_tags_fine = []
198
  else:
199
  # nerd tokens are tab- separated
200
  splits = line.split('\t')
201
  tokens.append(splits[0])
202
  ner_tags.append(splits[1])
203
- # ner_tags_fine.append(splits[2].rstrip())
204
  # last example
205
  yield guid, {
206
  "id": str(guid),
207
  "tokens": tokens,
208
  "ner_tags": ner_tags,
209
- # "ner_tags_fine": ner_tags_fine,
210
  }
 
73
  names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
74
  )
75
  ),
76
+ "ner_tags_fine": datasets.Sequence(
77
+ datasets.features.ClassLabel(
78
+ names=[
79
+ 'O',
80
+ 'I-ART-broadcastprogram',
81
+ 'I-ART-film',
82
+ 'I-ART-music',
83
+ 'I-ART-other',
84
+ 'I-ART-painting',
85
+ 'I-ART-writtenart',
86
+ 'I-BUILDING-airport',
87
+ 'I-BUILDING-hospital',
88
+ 'I-BUILDING-hotel',
89
+ 'I-BUILDING-library',
90
+ 'I-BUILDING-other',
91
+ 'I-BUILDING-restaurant',
92
+ 'I-BUILDING-sportsfacility',
93
+ 'I-BUILDING-theater',
94
+ 'I-EVENT-attack/battle/war/militaryconflict',
95
+ 'I-EVENT-disaster',
96
+ 'I-EVENT-election',
97
+ 'I-EVENT-other',
98
+ 'I-EVENT-protest',
99
+ 'I-EVENT-sportsevent',
100
+ 'I-LOC-GPE',
101
+ 'I-LOC-bodiesofwater',
102
+ 'I-LOC-island',
103
+ 'I-LOC-mountain',
104
+ 'I-LOC-other',
105
+ 'I-LOC-park',
106
+ 'I-LOC-road/railway/highway/transit',
107
+ 'I-ORG-company',
108
+ 'I-ORG-education',
109
+ 'I-ORG-government/governmentagency',
110
+ 'I-ORG-media/newspaper',
111
+ 'I-ORG-other',
112
+ 'I-ORG-politicalparty',
113
+ 'I-ORG-religion',
114
+ 'I-ORG-showorganization',
115
+ 'I-ORG-sportsleague',
116
+ 'I-ORG-sportsteam',
117
+ 'I-MISC-astronomything',
118
+ 'I-MISC-award',
119
+ 'I-MISC-biologything',
120
+ 'I-MISC-chemicalthing',
121
+ 'I-MISC-currency',
122
+ 'I-MISC-disease',
123
+ 'I-MISC-educationaldegree',
124
+ 'I-MISC-god',
125
+ 'I-MISC-language',
126
+ 'I-MISC-law',
127
+ 'I-MISC-livingthing',
128
+ 'I-MISC-medical',
129
+ 'I-PER-actor',
130
+ 'I-PER-artist/author',
131
+ 'I-PER-athlete',
132
+ 'I-PER-director',
133
+ 'I-PER-other',
134
+ 'I-PER-politician',
135
+ 'I-PER-scholar',
136
+ 'I-PER-soldier',
137
+ 'I-PRODUCT-airplane',
138
+ 'I-PRODUCT-car',
139
+ 'I-PRODUCT-food',
140
+ 'I-PRODUCT-game',
141
+ 'I-PRODUCT-other',
142
+ 'I-PRODUCT-ship',
143
+ 'I-PRODUCT-software',
144
+ 'I-PRODUCT-train',
145
+ 'I-PRODUCT-weapon'
146
+ ]
147
+ )
148
+ ),
149
  }
150
  ),
151
  supervised_keys=None,
 
156
  def _split_generators(self, dl_manager):
157
  """Returns SplitGenerators."""
158
  urls_to_download = {
 
 
 
159
  'train': 'train.txt',
160
  'validation': 'validation.txt',
161
  'test': 'test.txt',
 
177
  guid = 0
178
  tokens = []
179
  ner_tags = []
180
+ ner_tags_fine = []
181
 
182
  for line in lines:
183
  if line.startswith("-DOCSTART-") or line.strip() == "" or line == "\n":
 
186
  "id": str(guid),
187
  "tokens": tokens,
188
  "ner_tags": ner_tags,
189
+ "ner_tags_fine": ner_tags_fine,
190
  }
191
  guid += 1
192
  tokens = []
193
  ner_tags = []
194
+ ner_tags_fine = []
195
  else:
196
  # nerd tokens are tab- separated
197
  splits = line.split('\t')
198
  tokens.append(splits[0])
199
  ner_tags.append(splits[1])
200
+ ner_tags_fine.append(splits[2].rstrip())
201
  # last example
202
  yield guid, {
203
  "id": str(guid),
204
  "tokens": tokens,
205
  "ner_tags": ner_tags,
206
+ "ner_tags_fine": ner_tags_fine,
207
  }