MrPotato commited on
Commit
cef6ab1
·
1 Parent(s): 6d7db62

changed input ids to tokens

Browse files
Files changed (1) hide show
  1. ref_seg_ger.py +14 -14
ref_seg_ger.py CHANGED
@@ -218,18 +218,18 @@ class RefSeg(datasets.GeneratorBasedBuilder):
218
  #print(tokenized_input)
219
  if len(tokens) > 1:
220
  if row['tag'] == 'B':
221
- input_ids.append(tokens[0])
222
  labels.append(row['tag'] + '-' + row['label'])
223
  for input_id in tokens[1:]:
224
- input_ids.append(input_id)
225
  labels.append('I-' + row['label'])
226
  elif row['tag'] == 'I':
227
  for input_id in tokens:
228
- input_ids.append(input_id)
229
  labels.append('I-' + row['label'])
230
  else:
231
  for input_id in tokens:
232
- input_ids.append(input_id)
233
  labels.append('O')
234
  elif len(tokens) == 1:
235
  input_ids.append(tokens[0])
@@ -247,16 +247,16 @@ class RefSeg(datasets.GeneratorBasedBuilder):
247
  # split_rgbs = rgbs[index:index + self.CHUNK_SIZE]
248
  # split_fonts = fonts[index:index + self.CHUNK_SIZE]
249
  split_labels = labels[index:max(len(input_ids), index + self.CHUNK_SIZE)]
250
- split_labels_post = [item for sublist in split_labels for item in sublist]
251
- if(len(split_ids) != len(split_labels)):
252
- print(f)
253
- print(len(input_ids), input_ids)
254
- print(len(split_labels), split_labels)
255
- for s in split_labels:
256
- if type(s) is not str:
257
- print(f)
258
- print(len(input_ids), input_ids)
259
- print(len(split_labels), split_labels)
260
  #print(len(split_labels_post), split_labels_post)
261
  #print(split_labels, len(split_labels))
262
  #print(split_ids, len(split_ids))
 
218
  #print(tokenized_input)
219
  if len(tokens) > 1:
220
  if row['tag'] == 'B':
221
+ input_ids.append(tokens[0][0])
222
  labels.append(row['tag'] + '-' + row['label'])
223
  for input_id in tokens[1:]:
224
+ input_ids.append(input_id[0])
225
  labels.append('I-' + row['label'])
226
  elif row['tag'] == 'I':
227
  for input_id in tokens:
228
+ input_ids.append(input_id[0])
229
  labels.append('I-' + row['label'])
230
  else:
231
  for input_id in tokens:
232
+ input_ids.append(input_id[0])
233
  labels.append('O')
234
  elif len(tokens) == 1:
235
  input_ids.append(tokens[0])
 
247
  # split_rgbs = rgbs[index:index + self.CHUNK_SIZE]
248
  # split_fonts = fonts[index:index + self.CHUNK_SIZE]
249
  split_labels = labels[index:max(len(input_ids), index + self.CHUNK_SIZE)]
250
+ #split_labels_post = [item for sublist in split_labels for item in sublist]
251
+ # if(len(split_ids) != len(split_labels)):
252
+ # print(f)
253
+ # print(len(input_ids), input_ids)
254
+ # print(len(split_labels), split_labels)
255
+ # for s in split_labels:
256
+ # if type(s) is not str:
257
+ # print(f)
258
+ # print(len(input_ids), input_ids)
259
+ # print(len(split_labels), split_labels)
260
  #print(len(split_labels_post), split_labels_post)
261
  #print(split_labels, len(split_labels))
262
  #print(split_ids, len(split_ids))