elenanereiss commited on
Commit
245ce3b
1 Parent(s): e30e13f

Update german-ler.py

Browse files

add coarse-grained tags

Files changed (1) hide show
  1. german-ler.py +13 -13
german-ler.py CHANGED
@@ -158,18 +158,7 @@ class German_LER(datasets.GeneratorBasedBuilder):
158
  gen_kwargs={"datapath": data_dir["dev"], "split": "dev"},
159
  ),
160
  ]
161
-
162
- def _generate_coarse_tags(label):
163
- if label == 'O': return label
164
-
165
- bio, fine_tag = label.split("-")
166
- if fine_tag in ['PER', 'RR', 'AN']: return bio + '-PER'
167
- elif fine_tag in ['LD', 'ST', 'STR', 'LDS']: return bio + '-LOC'
168
- elif fine_tag in ['ORG', 'UN', 'INN', 'GRT', 'MRK']: return bio + '-ORG'
169
- elif fine_tag in ['GS', 'VO', 'EUN']: return bio + '-NRM'
170
- elif fine_tag in ['VS', 'VT']: return bio + '-REG'
171
- else: return label
172
-
173
  def _generate_examples(self, datapath, split):
174
  sentence_counter = 0
175
  with open(datapath, encoding="utf-8") as f:
@@ -183,7 +172,18 @@ class German_LER(datasets.GeneratorBasedBuilder):
183
  token, label = row_split
184
  current_words.append(token)
185
  current_labels.append(label)
186
- current_coarse_labels.append(generate_coarse_tags(label))
 
 
 
 
 
 
 
 
 
 
 
187
  else:
188
  if not current_words:
189
  continue
 
158
  gen_kwargs={"datapath": data_dir["dev"], "split": "dev"},
159
  ),
160
  ]
161
+
 
 
 
 
 
 
 
 
 
 
 
162
  def _generate_examples(self, datapath, split):
163
  sentence_counter = 0
164
  with open(datapath, encoding="utf-8") as f:
 
172
  token, label = row_split
173
  current_words.append(token)
174
  current_labels.append(label)
175
+
176
+ # generate coarse-grained tags
177
+ if label == 'O': continue
178
+ else:
179
+ bio, fine_tag = label.split("-")
180
+ if fine_tag in ['PER', 'RR', 'AN']: label = bio + '-PER'
181
+ elif fine_tag in ['LD', 'ST', 'STR', 'LDS']: label = bio + '-LOC'
182
+ elif fine_tag in ['ORG', 'UN', 'INN', 'GRT', 'MRK']: label = bio + '-ORG'
183
+ elif fine_tag in ['GS', 'VO', 'EUN']: label = bio + '-NRM'
184
+ elif fine_tag in ['VS', 'VT']: label = bio + '-REG'
185
+ current_coarse_labels.append(label)
186
+
187
  else:
188
  if not current_words:
189
  continue